Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,18 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
def
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
iface = gr.Interface(
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import fitz # PyMuPDF
|
| 3 |
|
| 4 |
+
def extract_text(pdf_file):
|
| 5 |
+
doc = fitz.open(pdf_file.name)
|
| 6 |
+
text = ""
|
| 7 |
+
for page_num in range(doc.page_count):
|
| 8 |
+
page = doc[page_num]
|
| 9 |
+
text += page.get_text()
|
| 10 |
+
return text
|
| 11 |
|
| 12 |
+
iface = gr.Interface(
|
| 13 |
+
fn=extract_text,
|
| 14 |
+
inputs=gr.File(type="file", label="Upload PDF"),
|
| 15 |
+
outputs="text"
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
iface.launch()
|