Spaces:
Sleeping
Sleeping
Commit
·
f2543f2
1
Parent(s):
cde0f19
improved ui
Browse files
app.py
CHANGED
@@ -1,15 +1,25 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Load English-to-Japanese translation
|
5 |
translator = pipeline("translation", model="staka/fugumt-en-ja")
|
6 |
|
7 |
-
# Define translation function
|
8 |
def translate(text):
|
9 |
if not text.strip():
|
10 |
return "Please enter some English text."
|
11 |
-
|
12 |
-
return result
|
13 |
|
14 |
-
#
|
15 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Load English-to-Japanese translation model
|
5 |
translator = pipeline("translation", model="staka/fugumt-en-ja")
|
6 |
|
|
|
7 |
def translate(text):
|
8 |
if not text.strip():
|
9 |
return "Please enter some English text."
|
10 |
+
return translator(text)[0]["translation_text"]
|
|
|
11 |
|
12 |
+
# Build a better UI
|
13 |
+
with gr.Blocks(title="English to Japanese Translator") as demo:
|
14 |
+
gr.Markdown("## 🌐 English to Japanese Translator")
|
15 |
+
gr.Markdown("Enter English text below and get the Japanese translation.")
|
16 |
+
|
17 |
+
with gr.Row():
|
18 |
+
input_text = gr.Textbox(label="English Input", placeholder="Type something in English...", lines=3)
|
19 |
+
output_text = gr.Textbox(label="Japanese Translation", lines=3)
|
20 |
+
|
21 |
+
translate_btn = gr.Button("Translate")
|
22 |
+
|
23 |
+
translate_btn.click(fn=translate, inputs=input_text, outputs=output_text)
|
24 |
+
|
25 |
+
demo.launch(share=True)
|