mike23415's picture
Update app.py
0116c46 verified
raw
history blame
447 Bytes
from transformers import pipeline
summarizer = pipeline("summarization", model="t5-base")
text = "This is a long text that needs summarization."
# Dynamically adjust max_length based on input length
input_length = len(text.split()) # Approximate token count
max_length = min(50, int(input_length * 0.8)) # 80% of input length
summary = summarizer(text, max_length=max_length, min_length=5, do_sample=False)
print(summary[0]["summary_text"])