Spaces:
Sleeping
Sleeping
initial
Browse files- app.py +27 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# Initialize the model
|
5 |
+
model = pipeline("summarization", model="luisotorres/bart-finetuned-samsum")
|
6 |
+
|
7 |
+
def summarize_text(text):
|
8 |
+
try:
|
9 |
+
summary = model(text, max_length=130, min_length=30)
|
10 |
+
return summary[0]["summary_text"]
|
11 |
+
except Exception as e:
|
12 |
+
return str(e)
|
13 |
+
|
14 |
+
# Create Gradio interface
|
15 |
+
iface = gr.Interface(
|
16 |
+
fn=summarize_text,
|
17 |
+
inputs=gr.Textbox(label="Input Text", lines=5),
|
18 |
+
outputs=gr.Textbox(label="Summary"),
|
19 |
+
title="Text Summarization",
|
20 |
+
description="Enter your text to generate a summary.",
|
21 |
+
examples=[
|
22 |
+
["Sarah: Do you think it's a good idea to invest in Bitcoin?\nEmily: I'm skeptical. The market is very volatile, and you could lose money.\nSarah: True. But there's also a high upside, right?"]
|
23 |
+
]
|
24 |
+
)
|
25 |
+
|
26 |
+
# Launch the interface
|
27 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
transformers
|
3 |
+
torch
|