Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Load the BART model for summarization
|
5 |
+
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
6 |
+
|
7 |
+
# Function to summarize the input text
|
8 |
+
def summarize_text(text):
|
9 |
+
summary = summarizer(text, min_length=10, max_length=100)
|
10 |
+
return summary[0]['summary_text']
|
11 |
+
|
12 |
+
# Create the Gradio interface
|
13 |
+
iface = gr.Interface(
|
14 |
+
fn=summarize_text,
|
15 |
+
inputs=gr.Textbox(label="Enter long text here", lines=10, placeholder="Enter a long text to summarize..."),
|
16 |
+
outputs=gr.Textbox(label="Summarized text"),
|
17 |
+
live=False,
|
18 |
+
description="Text summarization application using the BART model"
|
19 |
+
)
|
20 |
+
|
21 |
+
# Launch the application
|
22 |
+
iface.launch()
|