mirror of
https://github.com/tcsenpai/pensieve.git
synced 2025-06-06 03:05:25 +00:00
fix: yaml parse related
This commit is contained in:
parent
3912d165f6
commit
a30fe62bc3
@ -102,15 +102,13 @@ yaml.add_representer(OrderedDict, dict_representer)
|
||||
def secret_str_representer(dumper, data):
|
||||
return dumper.represent_scalar("tag:yaml.org,2002:str", data.get_secret_value())
|
||||
|
||||
|
||||
# Custom constructor for SecretStr
|
||||
def secret_str_constructor(loader, node):
|
||||
value = loader.construct_scalar(node)
|
||||
return SecretStr(value)
|
||||
|
||||
|
||||
# Register the representer and constructor only for specific fields
|
||||
yaml.add_representer(SecretStr, secret_str_representer)
|
||||
yaml.add_constructor("tag:yaml.org,2002:str", secret_str_constructor)
|
||||
|
||||
|
||||
def create_default_config():
|
||||
|
@ -183,10 +183,10 @@ def init_plugin(config):
|
||||
ocr_config['Cls']['model_path'] = os.path.join(model_dir, os.path.basename(ocr_config['Cls']['model_path']))
|
||||
ocr_config['Rec']['model_path'] = os.path.join(model_dir, os.path.basename(ocr_config['Rec']['model_path']))
|
||||
|
||||
# Save the updated config to a temporary file
|
||||
# Save the updated config to a temporary file with strings wrapped in double quotes
|
||||
temp_config_path = os.path.join(os.path.dirname(__file__), "temp_ppocr.yaml")
|
||||
with open(temp_config_path, 'w') as f:
|
||||
yaml.safe_dump(ocr_config, f)
|
||||
yaml.safe_dump(ocr_config, f, default_style='"')
|
||||
|
||||
ocr = RapidOCR(config_path=temp_config_path)
|
||||
thread_pool = ThreadPoolExecutor(max_workers=concurrency)
|
||||
|
Loading…
x
Reference in New Issue
Block a user