Spaces:
Runtime error
Runtime error
Add example images and questions for better UX
Browse files- Add receipt example image to all three tabs for easy testing
- Include sample questions for the Chat tab to guide users
- Users can now click examples to quickly try different features
Examples:
- Image: Official KOSMOS-2.5 receipt sample
- Questions: Total amount, items purchased, receipt date, subtotal
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
app.py
CHANGED
|
@@ -201,6 +201,10 @@ with gr.Blocks(title="KOSMOS-2.5 Document AI Demo", theme=gr.themes.Soft()) as d
|
|
| 201 |
with gr.Row():
|
| 202 |
with gr.Column():
|
| 203 |
md_image = gr.Image(type="pil", label="Upload Document Image")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
md_button = gr.Button("Generate Markdown", variant="primary")
|
| 205 |
with gr.Column():
|
| 206 |
md_output = gr.Textbox(
|
|
@@ -215,6 +219,10 @@ with gr.Blocks(title="KOSMOS-2.5 Document AI Demo", theme=gr.themes.Soft()) as d
|
|
| 215 |
with gr.Row():
|
| 216 |
with gr.Column():
|
| 217 |
ocr_image = gr.Image(type="pil", label="Upload Document Image")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 218 |
ocr_button = gr.Button("Extract Text with Coordinates", variant="primary")
|
| 219 |
with gr.Column():
|
| 220 |
with gr.Row():
|
|
@@ -230,11 +238,19 @@ with gr.Blocks(title="KOSMOS-2.5 Document AI Demo", theme=gr.themes.Soft()) as d
|
|
| 230 |
with gr.Row():
|
| 231 |
with gr.Column():
|
| 232 |
chat_image = gr.Image(type="pil", label="Upload Document Image")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 233 |
chat_question = gr.Textbox(
|
| 234 |
label="Ask a question about the document",
|
| 235 |
placeholder="e.g., What is the total amount on this receipt?",
|
| 236 |
lines=2
|
| 237 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 238 |
chat_button = gr.Button("Get Answer", variant="primary")
|
| 239 |
with gr.Column():
|
| 240 |
chat_output = gr.Textbox(
|
|
|
|
| 201 |
with gr.Row():
|
| 202 |
with gr.Column():
|
| 203 |
md_image = gr.Image(type="pil", label="Upload Document Image")
|
| 204 |
+
gr.Examples(
|
| 205 |
+
examples=["https://huggingface.co/microsoft/kosmos-2.5/resolve/main/receipt_00008.png"],
|
| 206 |
+
inputs=md_image
|
| 207 |
+
)
|
| 208 |
md_button = gr.Button("Generate Markdown", variant="primary")
|
| 209 |
with gr.Column():
|
| 210 |
md_output = gr.Textbox(
|
|
|
|
| 219 |
with gr.Row():
|
| 220 |
with gr.Column():
|
| 221 |
ocr_image = gr.Image(type="pil", label="Upload Document Image")
|
| 222 |
+
gr.Examples(
|
| 223 |
+
examples=["https://huggingface.co/microsoft/kosmos-2.5/resolve/main/receipt_00008.png"],
|
| 224 |
+
inputs=ocr_image
|
| 225 |
+
)
|
| 226 |
ocr_button = gr.Button("Extract Text with Coordinates", variant="primary")
|
| 227 |
with gr.Column():
|
| 228 |
with gr.Row():
|
|
|
|
| 238 |
with gr.Row():
|
| 239 |
with gr.Column():
|
| 240 |
chat_image = gr.Image(type="pil", label="Upload Document Image")
|
| 241 |
+
gr.Examples(
|
| 242 |
+
examples=["https://huggingface.co/microsoft/kosmos-2.5/resolve/main/receipt_00008.png"],
|
| 243 |
+
inputs=chat_image
|
| 244 |
+
)
|
| 245 |
chat_question = gr.Textbox(
|
| 246 |
label="Ask a question about the document",
|
| 247 |
placeholder="e.g., What is the total amount on this receipt?",
|
| 248 |
lines=2
|
| 249 |
)
|
| 250 |
+
gr.Examples(
|
| 251 |
+
examples=["What is the total amount on this receipt?", "What items were purchased?", "When was this receipt issued?", "What is the subtotal?"],
|
| 252 |
+
inputs=chat_question
|
| 253 |
+
)
|
| 254 |
chat_button = gr.Button("Get Answer", variant="primary")
|
| 255 |
with gr.Column():
|
| 256 |
chat_output = gr.Textbox(
|