space-demo / app.py
Kindlr's picture
Update app.py
4fac8f8
raw
history blame contribute delete
710 Bytes
from transformers import pipeline
import gradio as gr
# Initialize the summarizer pipeline
summarizer = pipeline("summarization", model="t5-base", tokenizer="t5-small", truncation=True, framework="tf")
def summarize(text):
# Replace HTML entities
text = text.replace('"', '"')
text = text.replace(''', "'")
text = text.replace('&', "&")
# Summarize the text
result = summarizer(text, min_length=100, truncation=True)
return result[0]["summary_text"]
# Define the Gradio interface
iface = gr.Interface(
fn=summarize,
inputs=gr.Textbox(lines=10, placeholder="Enter text to summarize..."),
outputs="text"
)
# Launch the Gradio interface
iface.launch()