Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,17 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Load the summarization model
|
5 |
-
summarizer = pipeline("summarization", model="
|
6 |
|
7 |
def summarize_text(text):
|
8 |
-
|
|
|
|
|
|
|
9 |
return summary[0]['summary_text']
|
10 |
|
11 |
-
# Create
|
12 |
iface = gr.Interface(
|
13 |
fn=summarize_text,
|
14 |
inputs=gr.Textbox(lines=5, placeholder="Enter text to summarize"),
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Load the new summarization model
|
5 |
+
summarizer = pipeline("summarization", model="falconsai/text_summarization")
|
6 |
|
7 |
def summarize_text(text):
|
8 |
+
max_len = min(0.3 * len(text.split()), 200) # 30% of input length or 200 max
|
9 |
+
min_len = min(0.1 * len(text.split()), 50) # 10% of input length or 50 min
|
10 |
+
|
11 |
+
summary = summarizer(text, max_length=int(max_len), min_length=int(min_len), do_sample=False)
|
12 |
return summary[0]['summary_text']
|
13 |
|
14 |
+
# Create Gradio Interface
|
15 |
iface = gr.Interface(
|
16 |
fn=summarize_text,
|
17 |
inputs=gr.Textbox(lines=5, placeholder="Enter text to summarize"),
|