Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,20 +1,26 @@
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
|
|
|
|
| 4 |
summarizer = pipeline("summarization", model="t5-base", tokenizer="t5-small", truncation=True, framework="tf")
|
| 5 |
|
| 6 |
-
def
|
|
|
|
| 7 |
text = text.replace('"', '"')
|
| 8 |
text = text.replace(''', "'")
|
| 9 |
text = text.replace('&', "&")
|
|
|
|
| 10 |
result = summarizer(text, min_length=100, truncation=True)
|
| 11 |
return result[0]["summary_text"]
|
| 12 |
|
|
|
|
| 13 |
iface = gr.Interface(
|
| 14 |
-
fn=
|
| 15 |
inputs=gr.Textbox(lines=10, placeholder="Enter text to summarize..."),
|
| 16 |
outputs="text"
|
| 17 |
)
|
| 18 |
|
| 19 |
-
|
|
|
|
|
|
|
| 20 |
|
|
|
|
| 1 |
from transformers import pipeline
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
+
# Initialize the summarizer pipeline
|
| 5 |
summarizer = pipeline("summarization", model="t5-base", tokenizer="t5-small", truncation=True, framework="tf")
|
| 6 |
|
| 7 |
+
def summarize(text):
|
| 8 |
+
# Replace HTML entities
|
| 9 |
text = text.replace('"', '"')
|
| 10 |
text = text.replace(''', "'")
|
| 11 |
text = text.replace('&', "&")
|
| 12 |
+
# Summarize the text
|
| 13 |
result = summarizer(text, min_length=100, truncation=True)
|
| 14 |
return result[0]["summary_text"]
|
| 15 |
|
| 16 |
+
# Define the Gradio interface
|
| 17 |
iface = gr.Interface(
|
| 18 |
+
fn=summarize,
|
| 19 |
inputs=gr.Textbox(lines=10, placeholder="Enter text to summarize..."),
|
| 20 |
outputs="text"
|
| 21 |
)
|
| 22 |
|
| 23 |
+
# Launch the Gradio interface
|
| 24 |
+
iface.launch()
|
| 25 |
+
|
| 26 |
|