Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -45,55 +45,91 @@ def process_text(text, task):
|
|
45 |
}
|
46 |
return task_funcs.get(task, lambda x: "Invalid Task")(text)
|
47 |
|
48 |
-
# Task-specific examples
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
]
|
54 |
|
55 |
-
|
56 |
-
["বাংলাদেশ দক্ষিণ এশিয়ার একটি সার্বভৌম রাষ্ট্র।"],
|
57 |
-
["ঢাকা বাংলাদেশের রাজধানী।"],
|
58 |
-
["রবীন্দ্রনাথ ঠাকুরের গান বাংলা সংস্কৃতির একটি অবিচ্ছেদ্য অংশ।"]
|
59 |
-
]
|
60 |
-
|
61 |
-
examples_summarization = [
|
62 |
-
["The Department of Computer Science and Engineering, established in 1982, was the first of its kind in Bangladesh. "
|
63 |
-
"Attracting top students from all over the country, it offers both undergraduate and postgraduate degrees."],
|
64 |
-
["Climate change is one of the biggest challenges we face today. With rising temperatures and unpredictable weather, "
|
65 |
-
"the world needs to come together to find sustainable solutions."],
|
66 |
-
["Technology has advanced rapidly over the past decade, with innovations in fields like AI, robotics, and quantum computing."]
|
67 |
-
]
|
68 |
-
|
69 |
-
examples_paraphrasing = [
|
70 |
-
["The cat is sitting on the mat."],
|
71 |
-
["He was very happy to receive the award."],
|
72 |
-
["The weather today is sunny and warm."]
|
73 |
-
]
|
74 |
-
|
75 |
-
# Define the Gradio interface with enhanced visuals
|
76 |
iface = gr.Interface(
|
77 |
fn=process_text,
|
78 |
inputs=[
|
79 |
-
"text",
|
80 |
gr.Dropdown(
|
81 |
["Translate English to Bengali", "Translate Bengali to English", "Summarize", "Paraphrase"],
|
82 |
-
label="
|
83 |
-
elem_id="dropdown-task"
|
|
|
84 |
)
|
85 |
],
|
86 |
-
outputs="
|
87 |
-
title="BanglaT5 Model Hub",
|
88 |
-
description="
|
89 |
-
theme="
|
90 |
examples=[
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
],
|
96 |
allow_flagging="auto",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
)
|
98 |
|
99 |
# Launch the Gradio app
|
|
|
45 |
}
|
46 |
return task_funcs.get(task, lambda x: "Invalid Task")(text)
|
47 |
|
48 |
+
# Task-specific examples with clear labels
|
49 |
+
examples = [
|
50 |
+
("Translate English to Bengali", [
|
51 |
+
["The sky is blue, and the weather is nice."],
|
52 |
+
["Artificial intelligence is shaping the future."],
|
53 |
+
["Bangladesh is known for its rich culture and heritage."]
|
54 |
+
]),
|
55 |
+
("Translate Bengali to English", [
|
56 |
+
["বাংলাদেশ দক্ষিণ এশিয়ার একটি সার্বভৌম রাষ্ট্র।"],
|
57 |
+
["ঢাকা বাংলাদেশের রাজধানী।"],
|
58 |
+
["রবীন্দ্রনাথ ঠাকুরের গান বাংলা সংস্কৃতির একটি অবিচ্ছেদ্য অংশ।"]
|
59 |
+
]),
|
60 |
+
("Summarize", [
|
61 |
+
["The Department of Computer Science and Engineering, established in 1982, was the first of its kind in Bangladesh. "
|
62 |
+
"Attracting top students from all over the country, it offers both undergraduate and postgraduate degrees."],
|
63 |
+
["Climate change is one of the biggest challenges we face today. With rising temperatures and unpredictable weather, "
|
64 |
+
"the world needs to come together to find sustainable solutions."],
|
65 |
+
["Technology has advanced rapidly over the past decade, with innovations in fields like AI, robotics, and quantum computing."]
|
66 |
+
]),
|
67 |
+
("Paraphrase", [
|
68 |
+
["The cat is sitting on the mat."],
|
69 |
+
["He was very happy to receive the award."],
|
70 |
+
["The weather today is sunny and warm."]
|
71 |
+
])
|
72 |
]
|
73 |
|
74 |
+
# Enhanced visual layout and interface design
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
iface = gr.Interface(
|
76 |
fn=process_text,
|
77 |
inputs=[
|
78 |
+
gr.Textbox(lines=5, label="Enter your text"),
|
79 |
gr.Dropdown(
|
80 |
["Translate English to Bengali", "Translate Bengali to English", "Summarize", "Paraphrase"],
|
81 |
+
label="Select Task",
|
82 |
+
elem_id="dropdown-task",
|
83 |
+
interactive=True
|
84 |
)
|
85 |
],
|
86 |
+
outputs=gr.Textbox(label="Output"),
|
87 |
+
title="BanglaT5 Model Hub - Translation, Summarization & Paraphrasing",
|
88 |
+
description="Explore the power of BanglaT5 with this easy-to-use interface for multiple tasks like translation, summarization, and paraphrasing.",
|
89 |
+
theme="huggingface/space-shuttle",
|
90 |
examples=[
|
91 |
+
("Translate English to Bengali", [
|
92 |
+
["The sky is blue, and the weather is nice."],
|
93 |
+
["Artificial intelligence is shaping the future."],
|
94 |
+
["Bangladesh is known for its rich culture and heritage."]
|
95 |
+
]),
|
96 |
+
("Translate Bengali to English", [
|
97 |
+
["বাংলাদেশ দক্ষিণ এশিয়ার একটি সার্বভৌম রাষ্ট্র।"],
|
98 |
+
["ঢাকা বাংলাদেশের রাজধানী।"],
|
99 |
+
["রবীন্দ্রনাথ ঠাক��রের গান বাংলা সংস্কৃতির একটি অবিচ্ছেদ্য অংশ।"]
|
100 |
+
]),
|
101 |
+
("Summarize", [
|
102 |
+
["The Department of Computer Science and Engineering, established in 1982, was the first of its kind in Bangladesh. "
|
103 |
+
"Attracting top students from all over the country, it offers both undergraduate and postgraduate degrees."],
|
104 |
+
["Climate change is one of the biggest challenges we face today. With rising temperatures and unpredictable weather, "
|
105 |
+
"the world needs to come together to find sustainable solutions."],
|
106 |
+
["Technology has advanced rapidly over the past decade, with innovations in fields like AI, robotics, and quantum computing."]
|
107 |
+
]),
|
108 |
+
("Paraphrase", [
|
109 |
+
["The cat is sitting on the mat."],
|
110 |
+
["He was very happy to receive the award."],
|
111 |
+
["The weather today is sunny and warm."]
|
112 |
+
])
|
113 |
],
|
114 |
allow_flagging="auto",
|
115 |
+
layout="horizontal", # Adding a horizontal layout for a cleaner design
|
116 |
+
css="""
|
117 |
+
#dropdown-task {
|
118 |
+
color: #2C3E50;
|
119 |
+
font-size: 18px;
|
120 |
+
}
|
121 |
+
.output-area {
|
122 |
+
color: #2C3E50;
|
123 |
+
}
|
124 |
+
.examples {
|
125 |
+
display: grid;
|
126 |
+
grid-template-columns: 1fr 1fr;
|
127 |
+
gap: 20px;
|
128 |
+
}
|
129 |
+
.output-text {
|
130 |
+
background-color: #E8F6F3;
|
131 |
+
}
|
132 |
+
"""
|
133 |
)
|
134 |
|
135 |
# Launch the Gradio app
|