MCPcopy Create free account
hub / github.com/Topdu/OpenOCR / main

Function main

openocr.py:300–722  ·  view source on GitHub ↗

Command-line interface for OpenOCR unified interface

()

Source from the content-addressed store, hash-verified

298
299
300def 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="""
306Command-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
318Examples:
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
353For more information, visit: https://github.com/Topdu/OpenOCR
354 """
355 )
356
357 # Task selection

Callers 1

openocr.pyFile · 0.70

Calls 7

save_visualizationMethod · 0.95
save_to_jsonMethod · 0.95
save_to_markdownMethod · 0.95
launch_demoFunction · 0.90
get_image_file_listFunction · 0.90
OpenOCRClass · 0.85
parse_argsMethod · 0.45

Tested by

no test coverage detected