Skip to content

Commit

Permalink
feat: add is_text flag to inference yaml parser
Browse files Browse the repository at this point in the history
resolves: #2
  • Loading branch information
tuna1210 committed Jul 15, 2024
1 parent e9a95df commit b7f733c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ def get_parser(name='PNID Inference') -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description=name)
parser.add_argument('--options', default='./pnid_inference_exe.yaml', type=str)
parser.add_argument('--img_path', type=str, default='.', help='input image path')
parser.add_argument('--symbol_result_path', type=str, default='.', help='symbol inference result xml path')
return parser

def parse_options():
def parse_options(is_text: bool = False):
parser = get_parser()
args = parser.parse_args()

Expand All @@ -25,13 +26,13 @@ def parse_options():
small_symbol_options = options['small_symbol_inference'] if 'small_symbol_inference' in options else None
text_recog_options = options['text_recog_inference'] if 'text_recog_inference' in options else None

if small_symbol_options:
if small_symbol_options and not is_text:
if not os.path.exists(small_symbol_options['mmrotate_config_path']):
assert False, f"no dataset option data in {small_symbol_options['mmrotate_config_path']} !"
if not os.path.exists(small_symbol_options['mmrotate_checkpoint_path']):
assert False, f"no dataset option data in {small_symbol_options['mmrotate_checkpoint_path']} !"

if text_recog_options:
if text_recog_options and is_text:
if not os.path.exists(text_recog_options['mmocr_config_path']):
assert False, f"no dataset option data in {text_recog_options['mmocr_config_path']} !"
if not os.path.exists(text_recog_options['mmocr_checkpoint_path']):
Expand Down
2 changes: 2 additions & 0 deletions tools/inference/pnid_text_recognize.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pnid_recognition_project.inference.inference_engine.text_recog_inference_engine import TextRecogEngine
from pnid_recognition_project.inference.parse_options import parse_options


def do_inference():
options, small_symbol_options, text_recog_options = parse_options()

Expand All @@ -21,6 +22,7 @@ def do_inference():
if text_recog_options:
with open(text_recog_options['dataset_option_path']) as f:
text_dataset_options = yaml.load(f, Loader=yaml.FullLoader)
text_dataset_options = text_dataset_options['mmocr_dataset_generation']
if not text_dataset_options['params']:
assert False, "wrong dataset option file!"

Expand Down

0 comments on commit b7f733c

Please sign in to comment.