Shanshan Wang commited on
Commit ·
5099c24
1
Parent(s): e2474e5
added a few example images and prompts
Browse files- app.py +17 -4
- assets/CBA-1H23-Results-Presentation_wheel.png +0 -0
- assets/driver_license.png +0 -0
- assets/invoice.png +0 -0
- assets/receipt.jpg +0 -0
app.py
CHANGED
|
@@ -280,7 +280,7 @@ def clear_all():
|
|
| 280 |
|
| 281 |
# Build the Gradio interface
|
| 282 |
with gr.Blocks() as demo:
|
| 283 |
-
gr.Markdown("# **
|
| 284 |
|
| 285 |
state= gr.State()
|
| 286 |
image_state = gr.State()
|
|
@@ -320,11 +320,11 @@ with gr.Blocks() as demo:
|
|
| 320 |
interactive=True,
|
| 321 |
label="Max New Tokens (default: 1024)"
|
| 322 |
)
|
|
|
|
| 323 |
with gr.Row():
|
| 324 |
submit_button = gr.Button("Submit")
|
| 325 |
regenerate_button = gr.Button("Regenerate")
|
| 326 |
-
clear_button = gr.Button("Clear")
|
| 327 |
-
|
| 328 |
|
| 329 |
# When the submit button is clicked, call the inference function
|
| 330 |
submit_button.click(
|
|
@@ -339,11 +339,24 @@ with gr.Blocks() as demo:
|
|
| 339 |
outputs=[chatbot, state, image_state]
|
| 340 |
)
|
| 341 |
|
| 342 |
-
|
| 343 |
clear_button.click(
|
| 344 |
fn=clear_all,
|
| 345 |
inputs=None,
|
| 346 |
outputs=[chatbot, state, image_state, image_input]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 347 |
)
|
|
|
|
|
|
|
| 348 |
|
| 349 |
demo.launch()
|
|
|
|
| 280 |
|
| 281 |
# Build the Gradio interface
|
| 282 |
with gr.Blocks() as demo:
|
| 283 |
+
gr.Markdown("# **H2OVL-Mississippi**")
|
| 284 |
|
| 285 |
state= gr.State()
|
| 286 |
image_state = gr.State()
|
|
|
|
| 320 |
interactive=True,
|
| 321 |
label="Max New Tokens (default: 1024)"
|
| 322 |
)
|
| 323 |
+
|
| 324 |
with gr.Row():
|
| 325 |
submit_button = gr.Button("Submit")
|
| 326 |
regenerate_button = gr.Button("Regenerate")
|
| 327 |
+
clear_button = gr.Button("Clear")
|
|
|
|
| 328 |
|
| 329 |
# When the submit button is clicked, call the inference function
|
| 330 |
submit_button.click(
|
|
|
|
| 339 |
outputs=[chatbot, state, image_state]
|
| 340 |
)
|
| 341 |
|
|
|
|
| 342 |
clear_button.click(
|
| 343 |
fn=clear_all,
|
| 344 |
inputs=None,
|
| 345 |
outputs=[chatbot, state, image_state, image_input]
|
| 346 |
+
)
|
| 347 |
+
gr.Examples(
|
| 348 |
+
examples=[
|
| 349 |
+
["assets/driver_license.png", "Extract the text from the image and fill the following json {'license_number':'',\n'full_name':'',\n'date_of_birth':'',\n'address':'',\n'issue_date':'',\n'expiration_date':'',\n}"],
|
| 350 |
+
# ["assets/receipt.jpg", "Read the text on the image"],
|
| 351 |
+
["assets/invoice.png", "Please extract the following fields, and return the result in JSON format: supplier_name, supplier_address, customer_name, customer_address, invoice_number, invoice_total_amount, invoice_tax_amount"],
|
| 352 |
+
["assets/CBA-1H23-Results-Presentation_wheel.png", "What is the efficiency of H2O.AI in document processing?"],
|
| 353 |
+
],
|
| 354 |
+
inputs = [image_input, user_input, temperature_input, top_p_input, max_new_tokens_input, chatbot, state, image_state],
|
| 355 |
+
outputs = [chatbot, state, image_state, user_input],
|
| 356 |
+
fn=inference,
|
| 357 |
+
label = "examples",
|
| 358 |
)
|
| 359 |
+
|
| 360 |
+
|
| 361 |
|
| 362 |
demo.launch()
|
assets/CBA-1H23-Results-Presentation_wheel.png
ADDED
|
assets/driver_license.png
ADDED
|
assets/invoice.png
ADDED
|
assets/receipt.jpg
ADDED
|