Spaces:
Build error
Build error
Commit ·
4ebe9a5
1
Parent(s): fec4160
Update app.py
Browse files
app.py
CHANGED
|
@@ -251,14 +251,14 @@ def pdf_ocr(file, model_t, question):
|
|
| 251 |
|
| 252 |
return immobile_values, total_output, text_output
|
| 253 |
|
| 254 |
-
|
|
|
|
| 255 |
# Call the pdf_ocr function
|
| 256 |
values, total, text = pdf_ocr(pdf_file.name, model_t, question)
|
| 257 |
return values, total, text
|
| 258 |
|
| 259 |
|
| 260 |
-
|
| 261 |
-
|
| 262 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 263 |
|
| 264 |
gr.Markdown(
|
|
@@ -294,7 +294,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 294 |
extract_button.click(fn = ocr_interface,
|
| 295 |
inputs=[pdf_input, model_input, question_input], outputs=[values_output, total_output, text_output])
|
| 296 |
|
| 297 |
-
gr.Examples(['Example1(
|
| 298 |
cache_examples = True, fn = ocr_interface, outputs = [values_output, total_output, text_output])
|
| 299 |
|
| 300 |
demo.launch()
|
|
|
|
| 251 |
|
| 252 |
return immobile_values, total_output, text_output
|
| 253 |
|
| 254 |
+
|
| 255 |
+
def ocr_interface(pdf_file, model_t='it5/it5-base-question-answering', question="Quanti metri quadri misura l'immobile?"):
|
| 256 |
# Call the pdf_ocr function
|
| 257 |
values, total, text = pdf_ocr(pdf_file.name, model_t, question)
|
| 258 |
return values, total, text
|
| 259 |
|
| 260 |
|
| 261 |
+
# Start the UI
|
|
|
|
| 262 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 263 |
|
| 264 |
gr.Markdown(
|
|
|
|
| 294 |
extract_button.click(fn = ocr_interface,
|
| 295 |
inputs=[pdf_input, model_input, question_input], outputs=[values_output, total_output, text_output])
|
| 296 |
|
| 297 |
+
gr.Examples(['Example1(scannedDoc).pdf', 'Example2.pdf', 'Example3Large.pdf'], inputs = pdf_input,
|
| 298 |
cache_examples = True, fn = ocr_interface, outputs = [values_output, total_output, text_output])
|
| 299 |
|
| 300 |
demo.launch()
|