Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,15 @@
|
|
1 |
-
gradio==3.0
|
2 |
-
transformers==4.12
|
3 |
-
torch==1.9
|
4 |
-
|
5 |
-
!pip install transformers
|
6 |
-
!pip install gradio
|
7 |
-
|
8 |
import gradio as gr
|
9 |
from transformers import pipeline
|
10 |
|
|
|
11 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
12 |
|
|
|
13 |
def summarize_text(text):
|
14 |
summary = summarizer(text, max_length=200, min_length=100, do_sample=False)
|
15 |
return summary[0]['summary_text']
|
16 |
|
|
|
17 |
demo = gr.Interface(
|
18 |
fn=summarize_text,
|
19 |
inputs=gr.Textbox(placeholder="Enter your text here", label="Input Text"),
|
@@ -22,4 +18,5 @@ demo = gr.Interface(
|
|
22 |
description="This chatbot takes a long text as input and returns a summary."
|
23 |
)
|
24 |
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Initialize the summarizer pipeline
|
5 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
6 |
|
7 |
+
# Define the summarization function
|
8 |
def summarize_text(text):
|
9 |
summary = summarizer(text, max_length=200, min_length=100, do_sample=False)
|
10 |
return summary[0]['summary_text']
|
11 |
|
12 |
+
# Create the Gradio interface
|
13 |
demo = gr.Interface(
|
14 |
fn=summarize_text,
|
15 |
inputs=gr.Textbox(placeholder="Enter your text here", label="Input Text"),
|
|
|
18 |
description="This chatbot takes a long text as input and returns a summary."
|
19 |
)
|
20 |
|
21 |
+
# Launch the interface
|
22 |
+
demo.launch()
|