Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import fitz
|
|
| 2 |
from transformers import pipeline
|
| 3 |
import gradio as gr
|
| 4 |
|
|
|
|
| 5 |
def extract_text_from_pdf(pdf_content):
|
| 6 |
doc = fitz.open("temp.pdf", pdf_content)
|
| 7 |
text = ""
|
|
@@ -10,6 +11,7 @@ def extract_text_from_pdf(pdf_content):
|
|
| 10 |
text += page.get_text()
|
| 11 |
return text
|
| 12 |
|
|
|
|
| 13 |
def generate_summary(file_content):
|
| 14 |
# Load pre-trained Flan-T5 model
|
| 15 |
text_generator = pipeline("text2text-generation", model="google/flan-t5-base")
|
|
@@ -28,18 +30,18 @@ def generate_summary(file_content):
|
|
| 28 |
return {
|
| 29 |
"Extracted Information": input_text,
|
| 30 |
"Book Summary": summary[0]["generated_text"],
|
| 31 |
-
"Review": "The book conveys a powerful message about..."
|
| 32 |
}
|
| 33 |
|
|
|
|
| 34 |
iface = gr.Interface(
|
| 35 |
fn=generate_summary,
|
| 36 |
-
inputs=gr.File(
|
| 37 |
outputs=[
|
| 38 |
gr.Textbox(),
|
| 39 |
gr.Textbox(),
|
| 40 |
gr.Textbox(),
|
| 41 |
],
|
| 42 |
-
live=True
|
| 43 |
)
|
| 44 |
-
|
| 45 |
iface.launch()
|
|
|
|
| 2 |
from transformers import pipeline
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
+
|
| 6 |
def extract_text_from_pdf(pdf_content):
|
| 7 |
doc = fitz.open("temp.pdf", pdf_content)
|
| 8 |
text = ""
|
|
|
|
| 11 |
text += page.get_text()
|
| 12 |
return text
|
| 13 |
|
| 14 |
+
|
| 15 |
def generate_summary(file_content):
|
| 16 |
# Load pre-trained Flan-T5 model
|
| 17 |
text_generator = pipeline("text2text-generation", model="google/flan-t5-base")
|
|
|
|
| 30 |
return {
|
| 31 |
"Extracted Information": input_text,
|
| 32 |
"Book Summary": summary[0]["generated_text"],
|
| 33 |
+
"Review": "The book conveys a powerful message about...",
|
| 34 |
}
|
| 35 |
|
| 36 |
+
|
| 37 |
iface = gr.Interface(
|
| 38 |
fn=generate_summary,
|
| 39 |
+
inputs=gr.File(), # Remove the max_upload_size parameter
|
| 40 |
outputs=[
|
| 41 |
gr.Textbox(),
|
| 42 |
gr.Textbox(),
|
| 43 |
gr.Textbox(),
|
| 44 |
],
|
| 45 |
+
live=True,
|
| 46 |
)
|
|
|
|
| 47 |
iface.launch()
|