Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ from transformers import pipeline
|
|
6 |
fugu_translator_enja = pipeline('translation', model='staka/fugumt-en-ja')
|
7 |
fugu_translator_jaen = pipeline('translation', model='staka/fugumt-ja-en')
|
8 |
zhja_translator = pipeline("translation", model="Helsinki-NLP/opus-mt-tc-big-zh-ja")
|
9 |
-
|
10 |
|
11 |
# Streamlit アプリケーション
|
12 |
st.title("Multi-Language Translator")
|
@@ -16,8 +16,8 @@ if 'session_models' not in st.session_state:
|
|
16 |
st.session_state.session_models = {
|
17 |
'enja': fugu_translator_enja,
|
18 |
'jaen': fugu_translator_jaen,
|
19 |
-
'zhja': zhja_translator
|
20 |
-
|
21 |
}
|
22 |
|
23 |
# デフォルトの入力値
|
@@ -25,7 +25,7 @@ default_model = 'enja'
|
|
25 |
default_text = ''
|
26 |
|
27 |
# ユーザー入力の取得
|
28 |
-
model = st.selectbox("モデル", ['enja', 'jaen', 'zhja'], index=0, key='model')
|
29 |
text = st.text_area("入力テキスト", default_text)
|
30 |
|
31 |
# 翻訳ボタンが押されたときの処理
|
@@ -33,6 +33,9 @@ if st.button("翻訳する"):
|
|
33 |
# Perform translation
|
34 |
result = st.session_state.session_models[model](text)[0]['translation_text']
|
35 |
|
|
|
|
|
|
|
36 |
# Save the data to a CSV file
|
37 |
data = {'ID': [1], 'Original Text': [text], 'Result': [result]}
|
38 |
df = pd.DataFrame(data)
|
@@ -40,6 +43,3 @@ if st.button("翻訳する"):
|
|
40 |
|
41 |
# Update the CSV creation flag
|
42 |
st.session_state.csv_created = True
|
43 |
-
|
44 |
-
# Display the result
|
45 |
-
st.write(f"翻訳結果: {result}")
|
|
|
6 |
fugu_translator_enja = pipeline('translation', model='staka/fugumt-en-ja')
|
7 |
fugu_translator_jaen = pipeline('translation', model='staka/fugumt-ja-en')
|
8 |
zhja_translator = pipeline("translation", model="Helsinki-NLP/opus-mt-tc-big-zh-ja")
|
9 |
+
jazh_translator = pipeline(model="larryvrh/mt5-translation-ja_zh")
|
10 |
|
11 |
# Streamlit アプリケーション
|
12 |
st.title("Multi-Language Translator")
|
|
|
16 |
st.session_state.session_models = {
|
17 |
'enja': fugu_translator_enja,
|
18 |
'jaen': fugu_translator_jaen,
|
19 |
+
'zhja': zhja_translator,
|
20 |
+
'jazh': jazh_translator
|
21 |
}
|
22 |
|
23 |
# デフォルトの入力値
|
|
|
25 |
default_text = ''
|
26 |
|
27 |
# ユーザー入力の取得
|
28 |
+
model = st.selectbox("モデル", ['enja', 'jaen', 'zhja', 'jazh'], index=0, key='model')
|
29 |
text = st.text_area("入力テキスト", default_text)
|
30 |
|
31 |
# 翻訳ボタンが押されたときの処理
|
|
|
33 |
# Perform translation
|
34 |
result = st.session_state.session_models[model](text)[0]['translation_text']
|
35 |
|
36 |
+
# Display the result
|
37 |
+
st.write(f"翻訳結果: {result}")
|
38 |
+
|
39 |
# Save the data to a CSV file
|
40 |
data = {'ID': [1], 'Original Text': [text], 'Result': [result]}
|
41 |
df = pd.DataFrame(data)
|
|
|
43 |
|
44 |
# Update the CSV creation flag
|
45 |
st.session_state.csv_created = True
|
|
|
|
|
|