Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,26 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
from transformers import pipeline
|
3 |
|
4 |
-
# Initialize the summarization pipeline
|
5 |
-
summarizer = pipeline("summarization", model="google/mt5-
|
6 |
|
7 |
-
def summarize_text(text):
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
|
15 |
-
# Create the Gradio interface
|
16 |
-
iface = gr.Interface(
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
)
|
24 |
|
25 |
-
if __name__ == "__main__":
|
26 |
-
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
# Initialize the summarization pipeline
|
5 |
+
summarizer = pipeline("summarization", model="google/mt5-base") # Changed the model here
|
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 |
+
flagging_mode="never"
|
23 |
+
)
|
24 |
|
25 |
+
if __name__ == "__main__":
|
26 |
+
iface.launch()
|