import gradio as gr import transformers from transformers import BartTokenizer, BartForConditionalGeneration model_name = 'facebook/bart-large-cnn' tokenizer = BartTokenizer.from_pretrained(model_name) model = BartForConditionalGeneration.from_pretrained(model_name) def summarize(input_text): inp = tokenizer.encode("summarize: " + input_text.replace('\n',''), return_tensors="pt", max_length=1024, truncation=True) summary_ids = model.generate(inp, num_beams=4, max_length=150, early_stopping=True) summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True) return summary app = gr.Interface( fn=summarize, inputs=gr.Textbox(lines=7, label="Input Text"), outputs="text", css="footer {visibility: hidden}", article = """

Hello, thanks for coming, visit AI tools: Genelify, visit Social Media tools: Tubtic

""" ) app.launch(inline=False, show_api=False)