added demo
Browse files
app.py
CHANGED
@@ -1,16 +1,20 @@
|
|
1 |
-
from transformers import pipeline
|
2 |
import gradio as gr
|
|
|
3 |
|
4 |
-
model
|
5 |
-
|
6 |
-
def predict(prompt):
|
7 |
-
summary = model(prompt)[0]['summary_text']
|
8 |
-
return summary
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
#
|
|
|
|
|
|
|
|
|
|
|
16 |
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
# Load the summarization model from Hugging Face
|
5 |
+
summarizer = pipeline("summarization")
|
|
|
|
|
|
|
6 |
|
7 |
+
# Define the summarization function
|
8 |
+
def summarize_text(input_text):
|
9 |
+
summarized = summarizer(input_text, max_length=100, min_length=30, do_sample=False)[0]
|
10 |
+
return summarized["summary_text"]
|
11 |
|
12 |
+
# Create the Gradio interface
|
13 |
+
iface = gr.Interface(
|
14 |
+
fn=summarize_text,
|
15 |
+
inputs=gr.inputs.Textbox(lines=10, placeholder="Enter text to summarize..."),
|
16 |
+
outputs=gr.outputs.Textbox(placeholder="Summary will appear here...")
|
17 |
+
)
|
18 |
|
19 |
+
# Run the interface
|
20 |
+
iface.launch()
|