pluniak commited on
Commit
1ce91d0
·
verified ·
1 Parent(s): 92cd9d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -14
app.py CHANGED
@@ -59,24 +59,38 @@ def run_ocrd_pipeline(img_path, status=gr.Progress(), binarize_mode='detailed',
59
 
60
 
61
  demo_data = [
62
- './demo_data/act_image.jpg',
63
- './demo_data/newjersey2_image.jpg',
64
- './demo_data/washington_image.jpg'
65
  ]
66
 
67
 
68
- iface = gr.Interface(run_ocrd_pipeline,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  title="OCRD Pipeline",
70
- description="<ul><li>This interactive demo showcases an 'Optical Character Recognition Digitization' pipeline that processes \
71
- images to recognize text.</li> \
72
- <li>Steps include binarization, text line segmentation, extraction, filtering and deskewing as well as OCR. \
73
- Results are displayed as a generated overlay image.</li> \
74
- <li>Optimized for English; other languages (e.g. German) may require OCR model fine-tuning.</li> \
75
- <li>Uses free CPU-based compute, which is rather slow. A pipeline run will take up to 10 minutes. \
76
- For lengthy waits, pre-computed demo results are available for download: https://github.com/pluniak/ocrd/tree/main/src/demo_data.</li> \
77
- <li>Note: The demo is just a first version! OCR performance and computation speed can be optimized.</li> \
78
- <li>The demo is based on code from my GitHub repository: https://github.com/pluniak/ocrd/tree/main</li></ul>",
79
- inputs=[gr.Image(type='filepath', label='Input image')],
80
  outputs=gr.Image(label='Output image: overlay with recognized text', type='pil', format='jpeg'),
81
  examples=demo_data)
82
  iface.launch()
 
59
 
60
 
61
  demo_data = [
62
+ ['../demo_data/act_image.jpg', None],
63
+ ['../demo_data/newjersey2_image.jpg', None],
64
+ ['../demo_data/washington_image.jpg', None]
65
  ]
66
 
67
 
68
+ description = """<ul>
69
+ <li>This interactive demo showcases an 'Optical Character Recognition Digitization' pipeline that processes images to recognize text.</li>
70
+ <li>Steps include:
71
+ <ol>
72
+ <li>Image binarization</li>
73
+ <li>Text line segmentation</li>
74
+ <li>Text line extraction, filtering and deskewing</li>
75
+ <li>OCR on textlines</li>
76
+ <li>Printing recognized text on generated image for visualization</li>
77
+ </ol>
78
+ </li>
79
+ <li>Optimized for <b>English</b>; other languages (e.g., German) may require OCR model fine-tuning.</li>
80
+ <li>Uses free CPU-based compute, which is rather <b>slow</b>. A pipeline run will take up to 10 minutes.</li>
81
+ <li>For lengthy waits, click on the pre-computed examples below or look at example results at: <a href='https://github.com/pluniak/ocrd/tree/main/src/demo_data'>https://github.com/pluniak/ocrd/tree/main/src/demo_data</a></li>
82
+ <li>The demo is based on code from my GitHub repository: <a href='https://github.com/pluniak/ocrd'>https://github.com/pluniak/ocrd</a></li>
83
+ <li>Note: The demo is just a <b>first prototype</b>! OCR performance and computation speed should be optimized.</li>
84
+ </ul>"""
85
+
86
+ iface = gr.Interface(fn = run_ocrd_pipeline,
87
  title="OCRD Pipeline",
88
+ description=description,
89
+ inputs=[
90
+ gr.Image(type='filepath', label='Input image'),
91
+ gr.Dropdown(choices=['small', 'medium', 'large', 'adjusted'], label='Output image font size', value='small',
92
+ info='"adjusted" will try to mimic font sizes from the input image')
93
+ ],
 
 
 
 
94
  outputs=gr.Image(label='Output image: overlay with recognized text', type='pil', format='jpeg'),
95
  examples=demo_data)
96
  iface.launch()