Spaces:
Sleeping
Sleeping
sanzanalora
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -45,71 +45,72 @@ 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 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
]
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
]
|
|
|
72 |
]
|
73 |
|
74 |
# Enhanced visual layout and interface design
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
)
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
45 |
}
|
46 |
return task_funcs.get(task, lambda x: "Invalid Task")(text)
|
47 |
|
48 |
+
# Task-specific examples
|
49 |
+
examples_translate_en_bn = [
|
50 |
+
["The sky is blue, and the weather is nice."],
|
51 |
+
["Artificial intelligence is shaping the future."],
|
52 |
+
["Bangladesh is known for its rich culture and heritage."]
|
53 |
+
]
|
54 |
+
|
55 |
+
examples_translate_bn_en = [
|
56 |
+
["বাংলাদেশ দক্ষিণ এশিয়ার একটি সার্বভৌম রাষ্ট্র।"],
|
57 |
+
["ঢাকা বাংলাদেশের রাজধানী।"],
|
58 |
+
["রবীন্দ্রনাথ ঠাকুরের গান বাংলা সংস্কৃতির একটি অবিচ্ছেদ্য অংশ।"]
|
59 |
+
]
|
60 |
+
|
61 |
+
examples_summarize = [
|
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_paraphrase = [
|
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 |
# Enhanced visual layout and interface design
|
76 |
+
with gr.Blocks() as demo:
|
77 |
+
gr.Markdown("# BanglaT5 Model Hub - Translation, Summarization & Paraphrasing")
|
78 |
+
gr.Markdown("Explore the power of BanglaT5 with this easy-to-use interface for multiple tasks like translation, summarization, and paraphrasing.")
|
79 |
+
|
80 |
+
with gr.Tabs():
|
81 |
+
with gr.Tab("Translate English to Bengali"):
|
82 |
+
gr.Examples(
|
83 |
+
examples_translate_en_bn,
|
84 |
+
inputs=gr.Textbox(label="Enter English Text", lines=5),
|
85 |
+
outputs=gr.Textbox(label="Bengali Translation")
|
86 |
+
)
|
87 |
+
|
88 |
+
with gr.Tab("Translate Bengali to English"):
|
89 |
+
gr.Examples(
|
90 |
+
examples_translate_bn_en,
|
91 |
+
inputs=gr.Textbox(label="Enter Bengali Text", lines=5),
|
92 |
+
outputs=gr.Textbox(label="English Translation")
|
93 |
+
)
|
94 |
+
|
95 |
+
with gr.Tab("Summarize"):
|
96 |
+
gr.Examples(
|
97 |
+
examples_summarize,
|
98 |
+
inputs=gr.Textbox(label="Enter Text to Summarize", lines=5),
|
99 |
+
outputs=gr.Textbox(label="Summary")
|
100 |
+
)
|
101 |
+
|
102 |
+
with gr.Tab("Paraphrase"):
|
103 |
+
gr.Examples(
|
104 |
+
examples_paraphrase,
|
105 |
+
inputs=gr.Textbox(label="Enter Text to Paraphrase", lines=5),
|
106 |
+
outputs=gr.Textbox(label="Paraphrased Text")
|
107 |
+
)
|
108 |
+
|
109 |
+
input_text = gr.Textbox(label="Enter your text here", lines=5)
|
110 |
+
task = gr.Dropdown(["Translate English to Bengali", "Translate Bengali to English", "Summarize", "Paraphrase"], label="Select Task")
|
111 |
+
output_text = gr.Textbox(label="Output", lines=5)
|
112 |
+
|
113 |
+
submit_btn = gr.Button("Run Task")
|
114 |
+
submit_btn.click(process_text, inputs=[input_text, task], outputs=output_text)
|
115 |
+
|
116 |
+
demo.launch()
|