Spaces:
Sleeping
Sleeping
Raghu
commited on
Commit
·
168a22c
1
Parent(s):
abcee6a
Simplify outputs to avoid gradio schema error (remove hidden state)
Browse files
app.py
CHANGED
|
@@ -505,7 +505,7 @@ def process_receipt(image):
|
|
| 505 |
if image is None:
|
| 506 |
return (
|
| 507 |
"<div style='padding: 20px; text-align: center;'>Upload an image to begin</div>",
|
| 508 |
-
None, "", ""
|
| 509 |
)
|
| 510 |
|
| 511 |
if not isinstance(image, Image.Image):
|
|
@@ -632,7 +632,7 @@ def process_receipt(image):
|
|
| 632 |
{fields_html}
|
| 633 |
"""
|
| 634 |
|
| 635 |
-
return summary_html, ocr_image, ocr_text,
|
| 636 |
|
| 637 |
|
| 638 |
# ============================================================================
|
|
@@ -685,12 +685,10 @@ with gr.Blocks(title="Receipt Processing Agent", theme=gr.themes.Soft(), css=CUS
|
|
| 685 |
with gr.Accordion("Raw Results (JSON)", open=False):
|
| 686 |
results_json = gr.Textbox(label="Full Results", lines=15)
|
| 687 |
|
| 688 |
-
hidden_state = gr.Textbox(visible=False)
|
| 689 |
-
|
| 690 |
process_btn.click(
|
| 691 |
fn=process_receipt,
|
| 692 |
inputs=[input_image],
|
| 693 |
-
outputs=[agent_summary, ocr_image_output, ocr_text_output,
|
| 694 |
)
|
| 695 |
|
| 696 |
gr.Markdown("""
|
|
|
|
| 505 |
if image is None:
|
| 506 |
return (
|
| 507 |
"<div style='padding: 20px; text-align: center;'>Upload an image to begin</div>",
|
| 508 |
+
None, "", ""
|
| 509 |
)
|
| 510 |
|
| 511 |
if not isinstance(image, Image.Image):
|
|
|
|
| 632 |
{fields_html}
|
| 633 |
"""
|
| 634 |
|
| 635 |
+
return summary_html, ocr_image, ocr_text, json.dumps(results, indent=2)
|
| 636 |
|
| 637 |
|
| 638 |
# ============================================================================
|
|
|
|
| 685 |
with gr.Accordion("Raw Results (JSON)", open=False):
|
| 686 |
results_json = gr.Textbox(label="Full Results", lines=15)
|
| 687 |
|
|
|
|
|
|
|
| 688 |
process_btn.click(
|
| 689 |
fn=process_receipt,
|
| 690 |
inputs=[input_image],
|
| 691 |
+
outputs=[agent_summary, ocr_image_output, ocr_text_output, results_json]
|
| 692 |
)
|
| 693 |
|
| 694 |
gr.Markdown("""
|