Spaces:
Runtime error
Runtime error
Commit
Β·
a2d9609
1
Parent(s):
5b264f6
First commit
Browse files- app.py +26 -0
- data/receipt_00000.JPG +0 -0
- data/receipt_00001.jpg +0 -0
- requirements.txt +71 -0
app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import easyocr
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from PIL import Image
|
| 4 |
+
|
| 5 |
+
reader = easyocr.Reader(['en'])
|
| 6 |
+
|
| 7 |
+
def inference(img_path, width_ths):
|
| 8 |
+
output = reader.readtext(img_path, detail=0, slope_ths=0.7, ycenter_ths=0.9,
|
| 9 |
+
height_ths=0.8, width_ths=width_ths, add_margin=0.2)
|
| 10 |
+
|
| 11 |
+
output = "\n".join(output)
|
| 12 |
+
|
| 13 |
+
title = "Receipt RAG"
|
| 14 |
+
description = "A simple Gradio interface to query receipts using RAG"
|
| 15 |
+
examples = [["data/receipt_00000.JPG", 7.7],
|
| 16 |
+
["data/receipr_00001.jpg", 7.7]]
|
| 17 |
+
|
| 18 |
+
demo = gr.Interface(inference,
|
| 19 |
+
inputs = [gr.Image(width=320, height=320, label="Input Receipt"),
|
| 20 |
+
gr.Slider(0, 10, 7.7, 0.1, label="Width Threshold to merge bounding boxes")],
|
| 21 |
+
outputs= [gr.Textbox(label="OCR Output", type="text")],
|
| 22 |
+
title=title,
|
| 23 |
+
description=description,
|
| 24 |
+
examples=examples)
|
| 25 |
+
|
| 26 |
+
demo.launch()
|
data/receipt_00000.JPG
ADDED
|
|
data/receipt_00001.jpg
ADDED
|
requirements.txt
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
aiofiles==23.2.1
|
| 2 |
+
annotated-types==0.7.0
|
| 3 |
+
anyio==4.8.0
|
| 4 |
+
audioop-lts==0.2.1
|
| 5 |
+
certifi==2025.1.31
|
| 6 |
+
charset-normalizer==3.4.1
|
| 7 |
+
click==8.1.8
|
| 8 |
+
colorama==0.4.6
|
| 9 |
+
easyocr==1.7.2
|
| 10 |
+
fastapi==0.115.11
|
| 11 |
+
ffmpy==0.5.0
|
| 12 |
+
filelock==3.17.0
|
| 13 |
+
fsspec==2025.3.0
|
| 14 |
+
gradio==5.20.1
|
| 15 |
+
gradio_client==1.7.2
|
| 16 |
+
groovy==0.1.2
|
| 17 |
+
h11==0.14.0
|
| 18 |
+
httpcore==1.0.7
|
| 19 |
+
httpx==0.28.1
|
| 20 |
+
huggingface-hub==0.29.3
|
| 21 |
+
idna==3.10
|
| 22 |
+
imageio==2.37.0
|
| 23 |
+
Jinja2==3.1.6
|
| 24 |
+
lazy_loader==0.4
|
| 25 |
+
markdown-it-py==3.0.0
|
| 26 |
+
MarkupSafe==2.1.5
|
| 27 |
+
mdurl==0.1.2
|
| 28 |
+
mpmath==1.3.0
|
| 29 |
+
networkx==3.4.2
|
| 30 |
+
ninja==1.11.1.3
|
| 31 |
+
numpy==2.2.3
|
| 32 |
+
opencv-python-headless==4.11.0.86
|
| 33 |
+
orjson==3.10.15
|
| 34 |
+
packaging==24.2
|
| 35 |
+
pandas==2.2.3
|
| 36 |
+
pillow==11.1.0
|
| 37 |
+
pyclipper==1.3.0.post6
|
| 38 |
+
pydantic==2.10.6
|
| 39 |
+
pydantic_core==2.27.2
|
| 40 |
+
pydub==0.25.1
|
| 41 |
+
Pygments==2.19.1
|
| 42 |
+
python-bidi==0.6.6
|
| 43 |
+
python-dateutil==2.9.0.post0
|
| 44 |
+
python-multipart==0.0.20
|
| 45 |
+
pytz==2025.1
|
| 46 |
+
PyYAML==6.0.2
|
| 47 |
+
requests==2.32.3
|
| 48 |
+
rich==13.9.4
|
| 49 |
+
ruff==0.9.10
|
| 50 |
+
safehttpx==0.1.6
|
| 51 |
+
scikit-image==0.25.2
|
| 52 |
+
scipy==1.15.2
|
| 53 |
+
semantic-version==2.10.0
|
| 54 |
+
setuptools==76.0.0
|
| 55 |
+
shapely==2.0.7
|
| 56 |
+
shellingham==1.5.4
|
| 57 |
+
six==1.17.0
|
| 58 |
+
sniffio==1.3.1
|
| 59 |
+
starlette==0.46.1
|
| 60 |
+
sympy==1.13.1
|
| 61 |
+
tifffile==2025.2.18
|
| 62 |
+
tomlkit==0.13.2
|
| 63 |
+
torch==2.6.0
|
| 64 |
+
torchvision==0.21.0
|
| 65 |
+
tqdm==4.67.1
|
| 66 |
+
typer==0.15.2
|
| 67 |
+
typing_extensions==4.12.2
|
| 68 |
+
tzdata==2025.1
|
| 69 |
+
urllib3==2.3.0
|
| 70 |
+
uvicorn==0.34.0
|
| 71 |
+
websockets==15.0.1
|