Spaces:
Build error
Build error
Commit
·
cae91d6
1
Parent(s):
a1404bc
Update app.py
Browse files
app.py
CHANGED
|
@@ -234,10 +234,11 @@ def pdf_ocr(file, model_t, question):
|
|
| 234 |
|
| 235 |
extracted_values = extractor_clean(text=text, k_words=ks, transformer=model_t, question=question, total_kwords=totalK, return_text=True)
|
| 236 |
values_output = extracted_values[0][0]
|
|
|
|
| 237 |
total_output = f'{extracted_values[0][1]} Mq'
|
| 238 |
text_output = extracted_values[2]
|
| 239 |
|
| 240 |
-
immobile_values = [f'{i + 1}. Immobile : {value} Mq\n' for i, value in enumerate(
|
| 241 |
immobile_values = '\n'.join(immobile_values)
|
| 242 |
|
| 243 |
return immobile_values, total_output, text_output
|
|
@@ -287,6 +288,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 287 |
extract_button.click(fn = ocr_interface,
|
| 288 |
inputs=[pdf_input, model_input, question_input], outputs=[values_output, total_output, text_output])
|
| 289 |
|
| 290 |
-
|
|
|
|
| 291 |
|
| 292 |
demo.launch()
|
|
|
|
| 234 |
|
| 235 |
extracted_values = extractor_clean(text=text, k_words=ks, transformer=model_t, question=question, total_kwords=totalK, return_text=True)
|
| 236 |
values_output = extracted_values[0][0]
|
| 237 |
+
sor_values = sorted(values_output)
|
| 238 |
total_output = f'{extracted_values[0][1]} Mq'
|
| 239 |
text_output = extracted_values[2]
|
| 240 |
|
| 241 |
+
immobile_values = [f'{i + 1}. Immobile : {value} Mq\n' for i, value in enumerate(sor_val)]
|
| 242 |
immobile_values = '\n'.join(immobile_values)
|
| 243 |
|
| 244 |
return immobile_values, total_output, text_output
|
|
|
|
| 288 |
extract_button.click(fn = ocr_interface,
|
| 289 |
inputs=[pdf_input, model_input, question_input], outputs=[values_output, total_output, text_output])
|
| 290 |
|
| 291 |
+
gr.Examples(['Example1(scannedDoc).pdf', 'Example2.pdf', 'Example3Large.pdf'], inputs = pdf_input,
|
| 292 |
+
cache_examples = True, fn = ocr_interface, outputs = [values_output, total_output, text_output])
|
| 293 |
|
| 294 |
demo.launch()
|