Shirish15 commited on
Commit
99ceffb
·
verified ·
1 Parent(s): b02c7ce

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Initialize the summarization pipeline
5
+ summarizer = pipeline("summarization", model="facebook/bart-large-cnn") # You can choose other models
6
+
7
+ def summarize_text(text):
8
+ """Summarizes the given text using the pre-trained model."""
9
+ try:
10
+ summary = summarizer(text, max_length=150, min_length=30, do_sample=False)[0]['summary_text'] # Adjust max and min length as needed
11
+ return summary
12
+ except Exception as e:
13
+ return f"Error during summarization: {str(e)}"
14
+
15
+ # Create the Gradio interface
16
+ iface = gr.Interface(
17
+ fn=summarize_text,
18
+ inputs=gr.Textbox(lines=5, label="Nepali Text to Summarize"),
19
+ outputs=gr.Textbox(lines=5, label="Summary"),
20
+ title="Nepali Text Summarizer",
21
+ description="Enter Nepali text and get a concise summary using a pre-trained NLP model.",
22
+ allow_flagging=False
23
+ )
24
+
25
+ if __name__ == "__main__":
26
+ iface.launch()