Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,12 @@
|
|
1 |
from transformers import pipeline
|
2 |
|
3 |
-
# Load the summarization model (ensure from_tf is removed)
|
4 |
summarizer = pipeline("summarization", model="t5-base")
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
from transformers import pipeline
|
2 |
|
|
|
3 |
summarizer = pipeline("summarization", model="t5-base")
|
4 |
|
5 |
+
text = "This is a long text that needs summarization."
|
6 |
+
|
7 |
+
# Dynamically adjust max_length based on input length
|
8 |
+
input_length = len(text.split()) # Approximate token count
|
9 |
+
max_length = min(50, int(input_length * 0.8)) # 80% of input length
|
10 |
+
|
11 |
+
summary = summarizer(text, max_length=max_length, min_length=5, do_sample=False)
|
12 |
+
print(summary[0]["summary_text"])
|