import torch import gradio as gr from transformers import pipeline # Initialize the summarization pipeline text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6", torch_dtype=torch.float32) # Function to perform text summarization def summary(input_text): # Use the summarization pipeline to generate a summary output = text_summary(input_text)[0]['summary_text'] return output # Close all existing Gradio interfaces to prevent conflicts gr.close_all() # Create a Gradio interface for text summarization demo = gr.Interface( fn=summary, inputs=gr.Textbox(label="Enter text to summarize", lines=6), outputs=gr.Textbox(label="Summarized text", lines=4), title="Summarizer AI", description="This application from LANARI Tech Ltd. is used to summarize text." ) # Launch the Gradio interface demo.launch()