Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -180,22 +180,25 @@ def create_interface():
|
|
180 |
gr.Markdown("Extract text from PDFs and images or get structured JSON output")
|
181 |
|
182 |
tabs = [
|
183 |
-
("OCR with PDF URL", gr.Textbox, processor.ocr_pdf_url, "PDF URL"),
|
184 |
("OCR with Uploaded PDF", gr.File, processor.ocr_uploaded_pdf, "Upload PDF", SUPPORTED_PDF_TYPES),
|
185 |
-
("OCR with Image URL", gr.Textbox, processor.ocr_image_url, "Image URL"),
|
186 |
("OCR with Uploaded Image", gr.File, processor.ocr_uploaded_image, "Upload Image", SUPPORTED_IMAGE_TYPES),
|
187 |
("Structured OCR", gr.File, processor.structured_ocr, "Upload Image", SUPPORTED_IMAGE_TYPES),
|
188 |
]
|
189 |
|
190 |
-
for name, input_type, fn, label,
|
191 |
with gr.Tab(name):
|
192 |
-
|
|
|
|
|
|
|
193 |
output = gr.Markdown(label="Result")
|
194 |
gr.Button(f"Process {name.split(' with ')[1]}").click(fn, inputs=inputs, outputs=output)
|
195 |
|
196 |
with gr.Tab("Document Understanding"):
|
197 |
-
doc_url = gr.Textbox(label="Document URL")
|
198 |
-
question = gr.Textbox(label="Question")
|
199 |
output = gr.Markdown(label="Answer")
|
200 |
gr.Button("Ask Question").click(processor.document_understanding, inputs=[doc_url, question], outputs=output)
|
201 |
|
|
|
180 |
gr.Markdown("Extract text from PDFs and images or get structured JSON output")
|
181 |
|
182 |
tabs = [
|
183 |
+
("OCR with PDF URL", gr.Textbox, processor.ocr_pdf_url, "PDF URL", None),
|
184 |
("OCR with Uploaded PDF", gr.File, processor.ocr_uploaded_pdf, "Upload PDF", SUPPORTED_PDF_TYPES),
|
185 |
+
("OCR with Image URL", gr.Textbox, processor.ocr_image_url, "Image URL", None),
|
186 |
("OCR with Uploaded Image", gr.File, processor.ocr_uploaded_image, "Upload Image", SUPPORTED_IMAGE_TYPES),
|
187 |
("Structured OCR", gr.File, processor.structured_ocr, "Upload Image", SUPPORTED_IMAGE_TYPES),
|
188 |
]
|
189 |
|
190 |
+
for name, input_type, fn, label, file_types in tabs:
|
191 |
with gr.Tab(name):
|
192 |
+
if input_type == gr.Textbox:
|
193 |
+
inputs = input_type(label=label, placeholder=f"e.g., https://example.com/{label.lower().replace(' ', '')}")
|
194 |
+
else: # gr.File
|
195 |
+
inputs = input_type(label=label, file_types=file_types)
|
196 |
output = gr.Markdown(label="Result")
|
197 |
gr.Button(f"Process {name.split(' with ')[1]}").click(fn, inputs=inputs, outputs=output)
|
198 |
|
199 |
with gr.Tab("Document Understanding"):
|
200 |
+
doc_url = gr.Textbox(label="Document URL", placeholder="e.g., https://arxiv.org/pdf/1805.04770")
|
201 |
+
question = gr.Textbox(label="Question", placeholder="e.g., What is the last sentence?")
|
202 |
output = gr.Markdown(label="Answer")
|
203 |
gr.Button("Ask Question").click(processor.document_understanding, inputs=[doc_url, question], outputs=output)
|
204 |
|