Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -66,21 +66,25 @@ def cached_translate(text, src_lang, tgt_lang, max_length=128, temperature=0.7):
|
|
| 66 |
# Gradio App with Tabs
|
| 67 |
# ---------------------------
|
| 68 |
|
| 69 |
-
|
| 70 |
-
gr.
|
|
|
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
|
| 86 |
-
demo
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
# Gradio App with Tabs
|
| 67 |
# ---------------------------
|
| 68 |
|
| 69 |
+
def create_demo():
|
| 70 |
+
with gr.Blocks(theme=gr.themes.Soft(), fill_height=True) as demo:
|
| 71 |
+
gr.Markdown("## 🤖 Smart AI Tools – Translate, Summarize, and More")
|
| 72 |
|
| 73 |
+
with gr.Tab("🌐 Translator"):
|
| 74 |
+
src_lang = gr.Dropdown(list(LANGUAGE_CODES.keys()), label="From", value="English")
|
| 75 |
+
tgt_lang = gr.Dropdown(list(LANGUAGE_CODES.keys()), label="To", value="Korean")
|
| 76 |
+
input_text = gr.Textbox(label="Input Text", lines=4)
|
| 77 |
+
output_text = gr.Textbox(label="Translated Output", lines=4, interactive=False)
|
| 78 |
+
translate_btn = gr.Button("Translate")
|
| 79 |
+
clear_btn = gr.Button("Clear")
|
| 80 |
+
translate_btn.click(cached_translate, [input_text, src_lang, tgt_lang], output_text)
|
| 81 |
+
clear_btn.click(lambda: ("", ""), None, [input_text, output_text])
|
| 82 |
|
| 83 |
+
with gr.Tab("📝 Summarizer"):
|
| 84 |
+
gr.Markdown("### This tool summarizes long content using `facebook/bart-large-cnn`")
|
| 85 |
+
gr.load("models/facebook/bart-large-cnn", provider="huggingface", label="Summarizer")
|
| 86 |
|
| 87 |
+
return demo
|
| 88 |
+
|
| 89 |
+
demo = create_demo()
|
| 90 |
+
demo.launch(share=False)
|