github-actions[bot] commited on
Commit
cbca9e2
Β·
1 Parent(s): 27b73f9

πŸš€ Automated OCR deployment from GitHub Actions

Browse files
Files changed (2) hide show
  1. =0.1.4 +1 -1
  2. app.py +15 -3
=0.1.4 CHANGED
@@ -20,6 +20,6 @@ Requirement already satisfied: exceptiongroup>=1.0.2 in /opt/hostedtoolcache/Pyt
20
  Requirement already satisfied: sniffio>=1.1 in /opt/hostedtoolcache/Python/3.10.19/x64/lib/python3.10/site-packages (from anyio->httpx<1,>=0.23.0->huggingface-hub>=0.30) (1.3.1)
21
  Requirement already satisfied: click>=8.0.0 in /opt/hostedtoolcache/Python/3.10.19/x64/lib/python3.10/site-packages (from typer-slim->huggingface-hub>=0.30) (8.3.1)
22
  Downloading hf_transfer-0.1.9-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6 MB)
23
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.6/3.6 MB 35.2 MB/s 0:00:00
24
  Installing collected packages: hf-transfer
25
  Successfully installed hf-transfer-0.1.9
 
20
  Requirement already satisfied: sniffio>=1.1 in /opt/hostedtoolcache/Python/3.10.19/x64/lib/python3.10/site-packages (from anyio->httpx<1,>=0.23.0->huggingface-hub>=0.30) (1.3.1)
21
  Requirement already satisfied: click>=8.0.0 in /opt/hostedtoolcache/Python/3.10.19/x64/lib/python3.10/site-packages (from typer-slim->huggingface-hub>=0.30) (8.3.1)
22
  Downloading hf_transfer-0.1.9-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6 MB)
23
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.6/3.6 MB 175.7 MB/s 0:00:00
24
  Installing collected packages: hf-transfer
25
  Successfully installed hf-transfer-0.1.9
app.py CHANGED
@@ -142,7 +142,7 @@ with gr.Blocks(title="OCR Text Detection", theme=gr.themes.Soft(), css=css) as d
142
  # Demo images gallery
143
  if sample_images:
144
  gr.Markdown("### Demo Images (Click to load)")
145
- demo_gallery = gr.Gallery(value=sample_images, columns=3, rows=1, height=150, show_label=False, container=True, preview=False, object_fit="scale-down")
146
 
147
  # Column 2: Processed image and confidence slider
148
  with gr.Column(scale=1):
@@ -191,8 +191,20 @@ with gr.Blocks(title="OCR Text Detection", theme=gr.themes.Soft(), css=css) as d
191
  annot, text = process_ocr(img, conf_thresh)
192
  return annot, gr.update(visible=True, value=text or "")
193
 
194
- image_input.change(fn=on_change, inputs=[image_input, confidence_slider], outputs=[annotated_output, text_output])
195
- confidence_slider.change(fn=on_change, inputs=[image_input, confidence_slider], outputs=[annotated_output, text_output])
 
 
 
 
 
 
 
 
 
 
 
 
196
 
197
 
198
  if __name__ == "__main__":
 
142
  # Demo images gallery
143
  if sample_images:
144
  gr.Markdown("### Demo Images (Click to load)")
145
+ demo_gallery = gr.Gallery(value=sample_images, columns=3, rows=1, height=210, show_label=False, container=True, preview=False, object_fit="scale-down")
146
 
147
  # Column 2: Processed image and confidence slider
148
  with gr.Column(scale=1):
 
191
  annot, text = process_ocr(img, conf_thresh)
192
  return annot, gr.update(visible=True, value=text or "")
193
 
194
+ # Process image when it changes - store event to allow cancellation
195
+ process_event = image_input.change(
196
+ fn=on_change,
197
+ inputs=[image_input, confidence_slider],
198
+ outputs=[annotated_output, text_output]
199
+ )
200
+
201
+ # Confidence slider cancels previous processing to avoid queue buildup
202
+ confidence_slider.change(
203
+ fn=on_change,
204
+ inputs=[image_input, confidence_slider],
205
+ outputs=[annotated_output, text_output],
206
+ cancels=[process_event] # Cancel previous image processing
207
+ )
208
 
209
 
210
  if __name__ == "__main__":