Spaces:
Sleeping
Sleeping
| import torch | |
| import gradio as gr | |
| from transformers import pipeline | |
| # Use a pipeline as a high-level helper | |
| device = 0 if torch.cuda.is_available() else -1 | |
| text_summary = pipeline("summarization", model="Falconsai/text_summarization", device=device, torch_dtype=torch.bfloat16) | |
| def summary(input): | |
| # Adjust max_length and min_length for better summarization | |
| output = text_summary(input, max_length=200, min_length=50, truncation=True) | |
| return output[0]['summary_text'] | |
| gr.close_all() | |
| # Create the Gradio interface | |
| demo = gr.Interface( | |
| fn=summary, | |
| inputs=[gr.Textbox(label="INPUT THE PASSAGE TO SUMMARIZE", lines=10)], | |
| outputs=[gr.Textbox(label="SUMMARIZED TEXT", lines=4)], | |
| title="PAVISHINI @ GenAI Project 1: Text Summarizer", | |
| description="This application is used to summarize the text" | |
| ) | |
| demo.launch() | |