Skip to content

Fix tools/infer_e2e_parallel.py crashing on startup with a TypeError - #220

Open
Anai-Guo wants to merge 1 commit into
Topdu:mainfrom
Anai-Guo:fix-infer-e2e-parallel-main-args
Open

Fix tools/infer_e2e_parallel.py crashing on startup with a TypeError#220
Anai-Guo wants to merge 1 commit into
Topdu:mainfrom
Anai-Guo:fix-infer-e2e-parallel-main-args

Conversation

@Anai-Guo

Copy link
Copy Markdown

What

tools/infer_e2e_parallel.py cannot be run at all:

$ python tools/infer_e2e_parallel.py
Traceback (most recent call last):
  File "tools/infer_e2e_parallel.py", line 184, in <module>
    main()
TypeError: main() missing 2 required positional arguments: 'cfg_det' and 'cfg_rec'

The module's entry point is

if __name__ == '__main__':
    main()

but the function is declared def main(cfg_det, cfg_rec):.

Why removing the parameters is the right fix

Neither name is used anywhere in main()'s body. The two configs are built inside
OpenOCRParallel.__init__ (:30:34), which is where the cfg_det / cfg_rec locals
actually live — a different scope:

class OpenOCRParallel:
    def __init__(self, drop_score=0.5, det_box_type='quad', max_rec_threads=1):
        cfg_det = Config('./configs/det/dbnet/repvit_db.yml').cfg
        cfg_rec = Config('./configs/rec/svtrv2/repsvtr_ch.yml').cfg
        self.text_detector = OpenDetector(cfg_det, numId=0)
        self.text_recognizer = OpenRecognizer(cfg_rec, numId=0)

and main() only does text_sys = OpenOCRParallel(drop_score=drop_score, det_box_type='quad').

The sibling end-to-end script tools/infer_e2e.py already declares def main(): with no
parameters and is called the same way, so this just brings the parallel variant in line
with it.

One line, no behaviour change beyond making the script runnable.

🤖 Generated with Claude Code

…_parallel main()

`python tools/infer_e2e_parallel.py` fails immediately with

    TypeError: main() missing 2 required positional arguments: 'cfg_det' and 'cfg_rec'

because the module's `if __name__ == '__main__':` block calls `main()` with no
arguments. Neither parameter is used inside `main()` -- the configs are built
inside `OpenOCRParallel.__init__`. The sibling script `tools/infer_e2e.py`
already declares `def main():`.

Signed-off-by: Anai-Guo <antai12232931@outlook.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant