rtr46 commited on
Commit
091981b
·
verified ·
1 Parent(s): 6c861f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -3
app.py CHANGED
@@ -172,15 +172,17 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
172
  output_text = gr.Textbox(label="recognized text", lines=5)
173
  output_json = gr.Code(label="json output", language="json", lines=5)
174
 
175
- example_image_path = os.path.join(os.path.dirname(__file__), "example.jpg")
 
 
176
 
 
177
  if os.path.exists(example_image_path):
178
  gr.Examples(
179
  examples=[example_image_path],
180
  inputs=[input_image],
181
  outputs=[output_image, output_text, output_json],
182
- # grad.io pre-loads the image into a numpy array for us.
183
- fn=lambda img: run_ocr_pipeline(img, 0.5, 0.1),
184
  cache_examples=True
185
  )
186
 
@@ -190,5 +192,15 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
190
  outputs=[output_image, output_text, output_json]
191
  )
192
 
 
 
 
 
 
 
 
 
 
 
193
  # --- 5. launch the app ---
194
  demo.launch()
 
172
  output_text = gr.Textbox(label="recognized text", lines=5)
173
  output_json = gr.Code(label="json output", language="json", lines=5)
174
 
175
+ def process_example(img):
176
+ # examples are pre-loaded as numpy by gradio, so we can pass them directly
177
+ return run_ocr_pipeline(img, 0.5, 0.1)
178
 
179
+ example_image_path = os.path.join(os.path.dirname(__file__), "example.jpg") # <-- updated filename
180
  if os.path.exists(example_image_path):
181
  gr.Examples(
182
  examples=[example_image_path],
183
  inputs=[input_image],
184
  outputs=[output_image, output_text, output_json],
185
+ fn=process_example,
 
186
  cache_examples=True
187
  )
188
 
 
192
  outputs=[output_image, output_text, output_json]
193
  )
194
 
195
+ # <-- a new markdown component is added here for the footer
196
+ gr.Markdown(
197
+ """
198
+ ---
199
+ ### official github repository
200
+ the full source code, documentation, and local command-line script for `meikiocr` are available on github.
201
+ **► [github.com/rtr46/meikiocr](https://github.com/rtr46/meikiocr)**
202
+ """
203
+ )
204
+
205
  # --- 5. launch the app ---
206
  demo.launch()