Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,9 +17,14 @@ def summarize_pdf(pdf_file):
|
|
| 17 |
|
| 18 |
# Summarize the text
|
| 19 |
inputs = tokenizer.encode("summarize: " + text, return_tensors="pt", max_length=1024, truncation=True)
|
| 20 |
-
summary_ids = model.generate(inputs, max_length=
|
| 21 |
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
# Interface for Gradio
|
| 25 |
iface = gr.Interface(
|
|
@@ -27,7 +32,8 @@ iface = gr.Interface(
|
|
| 27 |
inputs="file",
|
| 28 |
outputs="text",
|
| 29 |
title="PDF Summarizer",
|
| 30 |
-
description="Upload a PDF file
|
|
|
|
| 31 |
live=True,
|
| 32 |
capture_session=True,
|
| 33 |
)
|
|
|
|
| 17 |
|
| 18 |
# Summarize the text
|
| 19 |
inputs = tokenizer.encode("summarize: " + text, return_tensors="pt", max_length=1024, truncation=True)
|
| 20 |
+
summary_ids = model.generate(inputs, max_length=300, min_length=80, length_penalty=2.0, num_beams=4, early_stopping=True)
|
| 21 |
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
| 22 |
+
|
| 23 |
+
# Convert the summary to bullet points
|
| 24 |
+
bullet_points = summary.split('. ')
|
| 25 |
+
bullet_summary = "\n".join([f"• {point}" for point in bullet_points if point])
|
| 26 |
+
|
| 27 |
+
return bullet_summary
|
| 28 |
|
| 29 |
# Interface for Gradio
|
| 30 |
iface = gr.Interface(
|
|
|
|
| 32 |
inputs="file",
|
| 33 |
outputs="text",
|
| 34 |
title="PDF Summarizer",
|
| 35 |
+
description="Upload a PDF file and get a bullet-point summary of its content.",
|
| 36 |
+
theme="miku",
|
| 37 |
live=True,
|
| 38 |
capture_session=True,
|
| 39 |
)
|