mike23415 commited on
Commit
0116c46
·
verified ·
1 Parent(s): dbc2790

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
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
- # Example usage
7
- print(summarizer("This is a long text that needs summarization.", max_length=50, min_length=10, do_sample=False))
 
 
 
 
 
 
 
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"])