Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| summarizer = pipeline( | |
| "text-generation", | |
| model="sshleifer/distilbart-cnn-12-6" | |
| ) | |
| def summary_input(text): | |
| prompt = f"Summarize the following text:\n{text}\nSummary:" | |
| output = summarizer(prompt, max_new_tokens=120, do_sample=False) | |
| return output[0]["generated_text"] | |
| demo = gr.Interface( | |
| fn=summary_input, | |
| inputs=gr.Textbox(lines=10, label="Enter text to summarize"), | |
| outputs=gr.Textbox(lines=4, label="Summary"), | |
| title="Text Summarization App" | |
| ) | |
| demo.launch() | |