Update app.py
Browse files
app.py
CHANGED
|
@@ -1,27 +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 text based on the min and max length
|
| 8 |
def summarize_text(text, min_length, max_length):
|
| 9 |
-
# Summarize the input text with the specified min and max length
|
| 10 |
summary = summarizer(text, min_length=min_length, max_length=max_length)
|
| 11 |
return summary[0]['summary_text']
|
| 12 |
|
| 13 |
-
# Create Gradio Interface
|
| 14 |
iface = gr.Interface(
|
| 15 |
-
fn=summarize_text,
|
| 16 |
inputs=[
|
| 17 |
gr.Textbox(label="Enter Text", placeholder="Type or paste a long text here...", lines=10),
|
| 18 |
gr.Slider(minimum=10, maximum=50, step=1, label="Minimum Length", value=10),
|
| 19 |
gr.Slider(minimum=50, maximum=150, step=1, label="Maximum Length", value=100),
|
| 20 |
],
|
| 21 |
outputs=gr.Textbox(label="Summarized Text"),
|
| 22 |
-
live=False,
|
| 23 |
description="Text Summarization using BART model. Set minimum and maximum token lengths for the summary."
|
| 24 |
)
|
| 25 |
|
| 26 |
-
# Launch the interface
|
| 27 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
|
|
|
| 4 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 5 |
|
|
|
|
| 6 |
def summarize_text(text, min_length, max_length):
|
|
|
|
| 7 |
summary = summarizer(text, min_length=min_length, max_length=max_length)
|
| 8 |
return summary[0]['summary_text']
|
| 9 |
|
|
|
|
| 10 |
iface = gr.Interface(
|
| 11 |
+
fn=summarize_text,
|
| 12 |
inputs=[
|
| 13 |
gr.Textbox(label="Enter Text", placeholder="Type or paste a long text here...", lines=10),
|
| 14 |
gr.Slider(minimum=10, maximum=50, step=1, label="Minimum Length", value=10),
|
| 15 |
gr.Slider(minimum=50, maximum=150, step=1, label="Maximum Length", value=100),
|
| 16 |
],
|
| 17 |
outputs=gr.Textbox(label="Summarized Text"),
|
| 18 |
+
live=False,
|
| 19 |
description="Text Summarization using BART model. Set minimum and maximum token lengths for the summary."
|
| 20 |
)
|
| 21 |
|
|
|
|
| 22 |
iface.launch()
|