Update app.py
Browse files
app.py
CHANGED
|
@@ -6,7 +6,9 @@ from transformers import pipeline
|
|
| 6 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 7 |
|
| 8 |
def extract_text_from_pdf(file):
|
| 9 |
-
doc = fitz.open(stream=file.read(), filetype="pdf")
|
|
|
|
|
|
|
| 10 |
text = ""
|
| 11 |
for page in doc:
|
| 12 |
text += page.get_text()
|
|
@@ -26,7 +28,8 @@ def summarize_pdf(file):
|
|
| 26 |
# Gradio UI
|
| 27 |
demo = gr.Interface(
|
| 28 |
fn=summarize_pdf,
|
| 29 |
-
inputs=gr.File(label="Upload a PDF"),
|
|
|
|
| 30 |
outputs=gr.Textbox(label="Summary"),
|
| 31 |
title="📄 PDF Summarizer",
|
| 32 |
description="Upload a PDF file and get an AI-generated summary using Hugging Face Transformers."
|
|
|
|
| 6 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 7 |
|
| 8 |
def extract_text_from_pdf(file):
|
| 9 |
+
# doc = fitz.open(stream=file.read(), filetype="pdf")
|
| 10 |
+
|
| 11 |
+
doc = fitz.open(file)
|
| 12 |
text = ""
|
| 13 |
for page in doc:
|
| 14 |
text += page.get_text()
|
|
|
|
| 28 |
# Gradio UI
|
| 29 |
demo = gr.Interface(
|
| 30 |
fn=summarize_pdf,
|
| 31 |
+
#inputs=gr.File(label="Upload a PDF"),
|
| 32 |
+
inputs=gr.File(type="filepath", label="Upload a PDF"),
|
| 33 |
outputs=gr.Textbox(label="Summary"),
|
| 34 |
title="📄 PDF Summarizer",
|
| 35 |
description="Upload a PDF file and get an AI-generated summary using Hugging Face Transformers."
|