Spaces:
Running
Running
github-actions[bot]
commited on
Commit
Β·
cbca9e2
1
Parent(s):
27b73f9
π Automated OCR deployment from GitHub Actions
Browse files
=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
|
| 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=
|
| 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 |
-
|
| 195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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__":
|