from transformers import AutoTokenizer, AutoModelForSeq2SeqLM tokenizer = AutoTokenizer.from_pretrained("suriya7/bart-finetuned-text-summarization") model = AutoModelForSeq2SeqLM.from_pretrained("suriya7/bart-finetuned-text-summarization") def generate_summary(text): inputs = tokenizer([text], max_length=1024, return_tensors='pt', truncation=True) summary_ids = model.generate(inputs['input_ids'], max_new_tokens=100, do_sample=False) summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True) return summary text_to_summarize = """Now, there is no doubt that one of the most important aspects of any Pixel phone is its camera. And there might be good news for all camera lovers. Rumours have suggested that the Pixel 9 could come with a telephoto lens, improving its photography capabilities even further. Google will likely continue to focus on using AI to enhance its camera performance, in order to make sure that Pixel phones remain top contenders in the world of mobile photography.""" summary = generate_summary(text_to_summarize) print(summary)