Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 5 |
+
|
| 6 |
+
# Function to summarize text
|
| 7 |
+
def summarize_text(text):
|
| 8 |
+
summary = summarizer(text, max_length=150, min_length=50, do_sample=False)
|
| 9 |
+
return summary[0]['summary_text']
|
| 10 |
+
|
| 11 |
+
# Create Gradio UI
|
| 12 |
+
iface = gr.Interface(
|
| 13 |
+
fn=summarize_text,
|
| 14 |
+
inputs=gr.Textbox(lines=5, placeholder="Enter text to summarize..."),
|
| 15 |
+
outputs="text",
|
| 16 |
+
title="Text Summarization Chatbot",
|
| 17 |
+
description="Enter a long text, and the chatbot will generate a concise summary using BART."
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
iface.launch()
|