Spaces:
Sleeping
Sleeping
Commit
·
720d849
1
Parent(s):
4c58e3b
Added app
Browse files- app.py +78 -0
- requirements.txt +82 -0
app.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from pipeline import extract_info, extract_child_fee_info
|
| 3 |
+
from pdf2image import convert_from_path
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
with gr.Blocks() as demo:
|
| 8 |
+
with gr.Tabs():
|
| 9 |
+
with gr.Tab("Single Upload"):
|
| 10 |
+
with gr.Row():
|
| 11 |
+
with gr.Column(scale=2):
|
| 12 |
+
img_input = gr.Image(type="pil",label="Image Upload",elem_id="upload-img",show_label=False,height=512,width=512)
|
| 13 |
+
|
| 14 |
+
with gr.Column(scale=2):
|
| 15 |
+
output_box = gr.Markdown(
|
| 16 |
+
value="""```json
|
| 17 |
+
{
|
| 18 |
+
"merchant": "",
|
| 19 |
+
"date": "",
|
| 20 |
+
"total_amount": null,
|
| 21 |
+
}
|
| 22 |
+
```""",
|
| 23 |
+
|
| 24 |
+
label="Extracted Info", elem_id="output-box", show_label=False
|
| 25 |
+
)
|
| 26 |
+
img_input.upload(fn=extract_info, inputs=img_input, outputs=output_box)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
with gr.Tab("Reimbursement Form"):
|
| 32 |
+
with gr.Row():
|
| 33 |
+
with gr.Column(scale=2):
|
| 34 |
+
img_input = gr.Image(
|
| 35 |
+
type="pil",
|
| 36 |
+
label="Image Upload",
|
| 37 |
+
elem_id="upload-img",
|
| 38 |
+
show_label=False,
|
| 39 |
+
height=512,
|
| 40 |
+
width=512
|
| 41 |
+
)
|
| 42 |
+
|
| 43 |
+
with gr.Column(scale=2):
|
| 44 |
+
# Dropdown for form names
|
| 45 |
+
form_dropdown = gr.Dropdown(
|
| 46 |
+
choices=["Child Fee Reimbursement", "Medical Reimbursement", "Other Form"],
|
| 47 |
+
label="Select Form",
|
| 48 |
+
value="Child Fee Reimbursement",
|
| 49 |
+
multiselect=False,
|
| 50 |
+
interactive=True,
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
# 2x2 grid for info fields
|
| 54 |
+
with gr.Row():
|
| 55 |
+
emp_name = gr.Textbox(label="Employee Name")
|
| 56 |
+
emp_code = gr.Textbox(label="Employee Code")
|
| 57 |
+
with gr.Row():
|
| 58 |
+
department = gr.Textbox(label="Department")
|
| 59 |
+
upload_btn = gr.Button("Upload and Process")
|
| 60 |
+
preview_output = gr.Markdown(label="Filled Form")
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
upload_btn.click(
|
| 64 |
+
fn=extract_child_fee_info,
|
| 65 |
+
inputs=[img_input, emp_name, emp_code, department],
|
| 66 |
+
outputs=preview_output
|
| 67 |
+
)
|
| 68 |
+
|
| 69 |
+
# CSS:
|
| 70 |
+
gr.HTML("""
|
| 71 |
+
<style>
|
| 72 |
+
#output-box .prose, #output-box .prose pre, #output-box .prose code {
|
| 73 |
+
font-size: 30px !important;
|
| 74 |
+
}
|
| 75 |
+
</style>
|
| 76 |
+
""")
|
| 77 |
+
|
| 78 |
+
demo.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
aiofiles==24.1.0
|
| 2 |
+
annotated-types==0.7.0
|
| 3 |
+
anyio==4.9.0
|
| 4 |
+
certifi==2025.4.26
|
| 5 |
+
charset-normalizer==3.4.2
|
| 6 |
+
click==8.1.8
|
| 7 |
+
colorama==0.4.6
|
| 8 |
+
distro==1.9.0
|
| 9 |
+
docx==0.2.4
|
| 10 |
+
dotenv==0.9.9
|
| 11 |
+
fastapi==0.115.12
|
| 12 |
+
ffmpy==0.5.0
|
| 13 |
+
filelock==3.18.0
|
| 14 |
+
fsspec==2025.5.0
|
| 15 |
+
gradio==5.31.0
|
| 16 |
+
gradio_client==1.10.1
|
| 17 |
+
greenlet==3.2.2
|
| 18 |
+
groovy==0.1.2
|
| 19 |
+
h11==0.16.0
|
| 20 |
+
httpcore==1.0.9
|
| 21 |
+
httpx==0.28.1
|
| 22 |
+
huggingface-hub==0.31.4
|
| 23 |
+
idna==3.10
|
| 24 |
+
Jinja2==3.1.6
|
| 25 |
+
jiter==0.10.0
|
| 26 |
+
jsonpatch==1.33
|
| 27 |
+
jsonpointer==3.0.0
|
| 28 |
+
langchain-core==0.3.61
|
| 29 |
+
langgraph==0.4.5
|
| 30 |
+
langgraph-checkpoint==2.0.26
|
| 31 |
+
langgraph-prebuilt==0.2.0
|
| 32 |
+
langgraph-sdk==0.1.70
|
| 33 |
+
langsmith==0.3.42
|
| 34 |
+
lxml==5.4.0
|
| 35 |
+
markdown-it-py==3.0.0
|
| 36 |
+
MarkupSafe==3.0.2
|
| 37 |
+
mdurl==0.1.2
|
| 38 |
+
numpy==2.2.6
|
| 39 |
+
openai==1.82.0
|
| 40 |
+
opencv-python==4.11.0.86
|
| 41 |
+
orjson==3.10.18
|
| 42 |
+
ormsgpack==1.9.1
|
| 43 |
+
packaging==24.2
|
| 44 |
+
pandas==2.2.3
|
| 45 |
+
pdf2image==1.17.0
|
| 46 |
+
pdfrw==0.4
|
| 47 |
+
pillow==11.2.1
|
| 48 |
+
pydantic==2.11.5
|
| 49 |
+
pydantic_core==2.33.2
|
| 50 |
+
pydub==0.25.1
|
| 51 |
+
Pygments==2.19.1
|
| 52 |
+
pytesseract==0.3.13
|
| 53 |
+
python-dateutil==2.9.0.post0
|
| 54 |
+
python-docx==1.1.2
|
| 55 |
+
python-dotenv==1.1.0
|
| 56 |
+
python-multipart==0.0.20
|
| 57 |
+
pytz==2025.2
|
| 58 |
+
PyYAML==6.0.2
|
| 59 |
+
requests==2.32.3
|
| 60 |
+
requests-toolbelt==1.0.0
|
| 61 |
+
rich==14.0.0
|
| 62 |
+
ruff==0.11.11
|
| 63 |
+
safehttpx==0.1.6
|
| 64 |
+
semantic-version==2.10.0
|
| 65 |
+
shellingham==1.5.4
|
| 66 |
+
six==1.17.0
|
| 67 |
+
sniffio==1.3.1
|
| 68 |
+
SQLAlchemy==2.0.41
|
| 69 |
+
sqlmodel==0.0.24
|
| 70 |
+
starlette==0.46.2
|
| 71 |
+
tenacity==9.1.2
|
| 72 |
+
tomlkit==0.13.2
|
| 73 |
+
tqdm==4.67.1
|
| 74 |
+
typer==0.15.4
|
| 75 |
+
typing-inspection==0.4.1
|
| 76 |
+
typing_extensions==4.13.2
|
| 77 |
+
tzdata==2025.2
|
| 78 |
+
urllib3==2.4.0
|
| 79 |
+
uvicorn==0.34.2
|
| 80 |
+
websockets==15.0.1
|
| 81 |
+
xxhash==3.5.0
|
| 82 |
+
zstandard==0.23.0
|