Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -108,14 +108,14 @@ def process_pdf(path):
|
|
| 108 |
answers = answer_questions(results_dict["1. Kurzbeschreibung"])
|
| 109 |
return result_section1_dict['TOPIC']
|
| 110 |
|
| 111 |
-
def get_first_page_text(
|
| 112 |
-
doc = pdfplumber.open(
|
| 113 |
if len(doc.pages):
|
| 114 |
return doc.pages[0].extract_text()
|
| 115 |
|
| 116 |
# Define the Gradio interface
|
| 117 |
-
iface = gr.Interface(fn=get_first_page_text,
|
| 118 |
# iface = gr.Interface(fn=process_pdf,
|
|
|
|
| 119 |
inputs=gr.File(type="binary", label="Upload PDF"),
|
| 120 |
outputs=gr.Textbox(label="Extracted Text"),
|
| 121 |
title="PDF Text Extractor",
|
|
|
|
| 108 |
answers = answer_questions(results_dict["1. Kurzbeschreibung"])
|
| 109 |
return result_section1_dict['TOPIC']
|
| 110 |
|
| 111 |
+
def get_first_page_text(file_data):
|
| 112 |
+
doc = pdfplumber.open(BytesIO(file_data))
|
| 113 |
if len(doc.pages):
|
| 114 |
return doc.pages[0].extract_text()
|
| 115 |
|
| 116 |
# Define the Gradio interface
|
|
|
|
| 117 |
# iface = gr.Interface(fn=process_pdf,
|
| 118 |
+
iface = gr.Interface(fn=get_first_page_text,
|
| 119 |
inputs=gr.File(type="binary", label="Upload PDF"),
|
| 120 |
outputs=gr.Textbox(label="Extracted Text"),
|
| 121 |
title="PDF Text Extractor",
|