Spaces:
Sleeping
Sleeping
import gradio as gr | |
from transformers import pipeline | |
# Initialize the summarization pipeline | |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn") # You can choose other models | |
def summarize_text(text): | |
"""Summarizes the given text using the pre-trained model.""" | |
try: | |
summary = summarizer(text, max_length=150, min_length=30, do_sample=False)[0]['summary_text'] # Adjust max and min length as needed | |
return summary | |
except Exception as e: | |
return f"Error during summarization: {str(e)}" | |
# Create the Gradio interface | |
iface = gr.Interface( | |
fn=summarize_text, | |
inputs=gr.Textbox(lines=5, label="Nepali Text to Summarize"), | |
outputs=gr.Textbox(lines=5, label="Summary"), | |
title="Nepali Text Summarizer", | |
description="Enter Nepali text and get a concise summary using a pre-trained NLP model.", | |
allow_flagging=False | |
) | |
if __name__ == "__main__": | |
iface.launch() |