Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Initialize
|
5 |
-
summarizer = pipeline("summarization", model="facebook/
|
6 |
|
7 |
def summarize_text(text):
|
8 |
-
"""Summarizes the given text using
|
9 |
try:
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
return summary
|
12 |
except Exception as e:
|
13 |
return f"Error during summarization: {str(e)}"
|
@@ -18,8 +28,8 @@ iface = gr.Interface(
|
|
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
|
22 |
-
flagging_mode="never"
|
23 |
)
|
24 |
|
25 |
if __name__ == "__main__":
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Initialize multilingual summarization pipeline
|
5 |
+
summarizer = pipeline("summarization", model="facebook/mbart-large-50")
|
6 |
|
7 |
def summarize_text(text):
|
8 |
+
"""Summarizes the given Nepali text using a multilingual model."""
|
9 |
try:
|
10 |
+
if not text.strip():
|
11 |
+
return "Please enter some Nepali text to summarize"
|
12 |
+
|
13 |
+
summary = summarizer(
|
14 |
+
text,
|
15 |
+
max_length=150,
|
16 |
+
min_length=30,
|
17 |
+
do_sample=False,
|
18 |
+
truncation=True,
|
19 |
+
src_lang="ne_NP" # Nepali language code
|
20 |
+
)[0]['summary_text']
|
21 |
return summary
|
22 |
except Exception as e:
|
23 |
return f"Error during summarization: {str(e)}"
|
|
|
28 |
inputs=gr.Textbox(lines=5, label="Nepali Text to Summarize"),
|
29 |
outputs=gr.Textbox(lines=5, label="Summary"),
|
30 |
title="Nepali Text Summarizer",
|
31 |
+
description="Enter Nepali text and get a concise summary using multilingual NLP models.",
|
32 |
+
flagging_mode="never"
|
33 |
)
|
34 |
|
35 |
if __name__ == "__main__":
|