Command-line interface for OpenOCR unified interface
()
| 298 | |
| 299 | |
| 300 | def main(): |
| 301 | """Command-line interface for OpenOCR unified interface""" |
| 302 | parser = argparse.ArgumentParser( |
| 303 | description='OpenOCR Unified Interface - Single entry point for all OCR tasks', |
| 304 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 305 | epilog=""" |
| 306 | Command-line Usage: |
| 307 | After installation, you can use OpenOCR in three ways: |
| 308 | |
| 309 | 1. Using the 'openocr' command (recommended): |
| 310 | openocr --task ocr --input_path image.jpg |
| 311 | |
| 312 | 2. Using 'python -m openocr': |
| 313 | python -m openocr --task ocr --input_path image.jpg |
| 314 | |
| 315 | 3. Running the script directly: |
| 316 | python openocr.py --task ocr --input_path image.jpg |
| 317 | |
| 318 | Examples: |
| 319 | # Detection task |
| 320 | openocr --task det --input_path image.jpg |
| 321 | |
| 322 | # Recognition task |
| 323 | openocr --task rec --input_path image.jpg --mode server |
| 324 | |
| 325 | # OCR task (detection + recognition) |
| 326 | openocr --task ocr --input_path image.jpg --is_vis |
| 327 | |
| 328 | # OCR with custom output path |
| 329 | openocr --task ocr --input_path ./images --output_path ./results |
| 330 | |
| 331 | # UniRec task (universal recognition) |
| 332 | openocr --task unirec --input_path image.jpg --max_length 2048 |
| 333 | |
| 334 | # Doc task (document OCR with layout) |
| 335 | openocr --task doc --input_path document.jpg --use_layout_detection --save_vis --save_json --save_markdown |
| 336 | |
| 337 | # Doc task with PDF input |
| 338 | openocr --task doc --input_path document.pdf --use_layout_detection --save_vis --save_json --save_markdown |
| 339 | |
| 340 | # Doc task with custom models |
| 341 | openocr --task doc --input_path doc.jpg --layout_model path/to/layout.onnx \\ |
| 342 | --encoder_model path/to/encoder.onnx --decoder_model path/to/decoder.onnx --use_layout_detection --save_vis --save_json --save_markdown |
| 343 | |
| 344 | # Launch OpenOCR Gradio demo |
| 345 | openocr --task launch_openocr_demo --share |
| 346 | |
| 347 | # Launch UniRec Gradio demo |
| 348 | openocr --task launch_unirec_demo --server_port 7861 |
| 349 | |
| 350 | # Launch OpenDoc Gradio demo |
| 351 | openocr --task launch_opendoc_demo --share --server_port 7862 |
| 352 | |
| 353 | For more information, visit: https://github.com/Topdu/OpenOCR |
| 354 | """ |
| 355 | ) |
| 356 | |
| 357 | # Task selection |
no test coverage detected