Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,8 @@ from transformers import pipeline
|
|
| 4 |
# transformers パイプラインのインポート
|
| 5 |
fugu_translator_enja = pipeline('translation', model='staka/fugumt-en-ja')
|
| 6 |
fugu_translator_jaen = pipeline('translation', model='staka/fugumt-ja-en')
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# デフォルトのモデル
|
| 9 |
current_model = 'enja'
|
|
@@ -18,18 +20,22 @@ def translate(model, text):
|
|
| 18 |
|
| 19 |
if current_model == 'enja':
|
| 20 |
return fugu_translator_enja(text)[0]['translation_text']
|
| 21 |
-
|
| 22 |
return fugu_translator_jaen(text)[0]['translation_text']
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
# Streamlit アプリケーション
|
| 25 |
-
st.title("
|
| 26 |
|
| 27 |
# デフォルトの入力値
|
| 28 |
default_model = 'enja'
|
| 29 |
default_text = ''
|
| 30 |
|
| 31 |
# ユーザー入力の取得
|
| 32 |
-
model = st.selectbox("モデル", ['enja', 'jaen'], index=0, key='model')
|
| 33 |
text = st.text_area("入力テキスト", default_text)
|
| 34 |
|
| 35 |
# 翻訳ボタンが押されたときの処理
|
|
|
|
| 4 |
# transformers パイプラインのインポート
|
| 5 |
fugu_translator_enja = pipeline('translation', model='staka/fugumt-en-ja')
|
| 6 |
fugu_translator_jaen = pipeline('translation', model='staka/fugumt-ja-en')
|
| 7 |
+
zhja_translator = pipeline("translation", model="Helsinki-NLP/opus-mt-tc-big-zh-ja")
|
| 8 |
+
jazh_translator = pipeline(model="larryvrh/mt5-translation-ja_zh")
|
| 9 |
|
| 10 |
# デフォルトのモデル
|
| 11 |
current_model = 'enja'
|
|
|
|
| 20 |
|
| 21 |
if current_model == 'enja':
|
| 22 |
return fugu_translator_enja(text)[0]['translation_text']
|
| 23 |
+
elif current_model == 'jaen':
|
| 24 |
return fugu_translator_jaen(text)[0]['translation_text']
|
| 25 |
+
elif current_model == 'zhja':
|
| 26 |
+
return zhja_translator(text)[0]['translation_text']
|
| 27 |
+
elif current_model == 'jazh':
|
| 28 |
+
return jazh_translator(text)
|
| 29 |
|
| 30 |
# Streamlit アプリケーション
|
| 31 |
+
st.title("Multi-Language Translator")
|
| 32 |
|
| 33 |
# デフォルトの入力値
|
| 34 |
default_model = 'enja'
|
| 35 |
default_text = ''
|
| 36 |
|
| 37 |
# ユーザー入力の取得
|
| 38 |
+
model = st.selectbox("モデル", ['enja', 'jaen', 'zhja', 'jazh'], index=0, key='model')
|
| 39 |
text = st.text_area("入力テキスト", default_text)
|
| 40 |
|
| 41 |
# 翻訳ボタンが押されたときの処理
|