Spaces:
Runtime error
Runtime error
Brass-monkey
commited on
Commit
•
3243b63
1
Parent(s):
3fcefd6
Update app.py
Browse files
app.py
CHANGED
@@ -2,26 +2,25 @@ import gradio as gr
|
|
2 |
from PyPDF2 import PdfReader
|
3 |
from transformers import pipeline
|
4 |
|
5 |
-
def
|
6 |
-
summarizer = pipeline("summarization")
|
7 |
summaries = []
|
8 |
-
|
9 |
for file in files:
|
10 |
with open(file.name, "rb") as pdf_file:
|
11 |
pdf_reader = PdfReader(pdf_file)
|
12 |
text = ""
|
13 |
for page in pdf_reader.pages:
|
14 |
text += page.extract_text() + "\n"
|
15 |
-
extracted_texts.append(text)
|
16 |
summary = summarizer(text, max_length=50, min_length=10, do_sample=False)[0]['summary_text']
|
17 |
summaries.append(summary)
|
18 |
-
return summaries
|
19 |
|
20 |
iface = gr.Interface(
|
21 |
-
fn=
|
22 |
inputs=gr.UploadButton("Click to Upload a PDF", file_types=["pdf"], file_count="multiple"),
|
23 |
-
outputs=
|
24 |
-
title="PDF Summarizer
|
25 |
)
|
26 |
|
27 |
iface.launch()
|
|
|
2 |
from PyPDF2 import PdfReader
|
3 |
from transformers import pipeline
|
4 |
|
5 |
+
def summarize_pdf_content(files):
|
6 |
+
summarizer = pipeline("summarization", model="stevhliu/my_awesome_billsum_model")
|
7 |
summaries = []
|
8 |
+
|
9 |
for file in files:
|
10 |
with open(file.name, "rb") as pdf_file:
|
11 |
pdf_reader = PdfReader(pdf_file)
|
12 |
text = ""
|
13 |
for page in pdf_reader.pages:
|
14 |
text += page.extract_text() + "\n"
|
|
|
15 |
summary = summarizer(text, max_length=50, min_length=10, do_sample=False)[0]['summary_text']
|
16 |
summaries.append(summary)
|
17 |
+
return summaries
|
18 |
|
19 |
iface = gr.Interface(
|
20 |
+
fn=summarize_pdf_content,
|
21 |
inputs=gr.UploadButton("Click to Upload a PDF", file_types=["pdf"], file_count="multiple"),
|
22 |
+
outputs=gr.Textbox(label="Summarized Text"),
|
23 |
+
title="PDF Summarizer"
|
24 |
)
|
25 |
|
26 |
iface.launch()
|