Spaces:
Runtime error
Runtime error
Update app.py
#2
by
okewunmi
- opened
app.py
CHANGED
|
@@ -3,12 +3,16 @@ import pdfminer
|
|
| 3 |
from pdfminer.high_level import extract_text
|
| 4 |
|
| 5 |
def read_pdf(file):
|
|
|
|
|
|
|
| 6 |
text = extract_text(file.name)
|
| 7 |
return text
|
| 8 |
|
| 9 |
iface = gr.Interface(
|
| 10 |
-
read_pdf,
|
| 11 |
-
gr.
|
| 12 |
-
gr.
|
| 13 |
)
|
| 14 |
-
|
|
|
|
|
|
|
|
|
| 3 |
from pdfminer.high_level import extract_text
|
| 4 |
|
| 5 |
def read_pdf(file):
|
| 6 |
+
if file is None:
|
| 7 |
+
return "No file uploaded"
|
| 8 |
text = extract_text(file.name)
|
| 9 |
return text
|
| 10 |
|
| 11 |
iface = gr.Interface(
|
| 12 |
+
fn=read_pdf,
|
| 13 |
+
inputs=gr.File(label="Upload PDF file"),
|
| 14 |
+
outputs=gr.Textbox(label="Extracted Text")
|
| 15 |
)
|
| 16 |
+
|
| 17 |
+
if __name__ == "__main__":
|
| 18 |
+
iface.launch()
|