Spaces:
Runtime error
Runtime error
update
Browse files
app.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
-
from transformers import pipeline
|
|
|
|
|
3 |
|
4 |
translator = pipeline("translation_vi_to_en", model="Helsinki-NLP/opus-mt-vi-en")
|
5 |
|
@@ -8,6 +10,8 @@ st.title("Demo translation with pretrained model")
|
|
8 |
input_text = st.text_area("Nhập văn bản tiếng Việt:", "")
|
9 |
|
10 |
if input_text:
|
|
|
|
|
11 |
translated_text = translator(input_text)
|
12 |
|
13 |
st.write("Translation Vietnamese to English:")
|
|
|
1 |
import streamlit as st
|
2 |
+
from transformers import pipeline, AutoTokenizer
|
3 |
+
|
4 |
+
tokenizer = AutoTokenizer.from_pretrained("Helsinki-NLP/opus-mt-vi-en")
|
5 |
|
6 |
translator = pipeline("translation_vi_to_en", model="Helsinki-NLP/opus-mt-vi-en")
|
7 |
|
|
|
10 |
input_text = st.text_area("Nhập văn bản tiếng Việt:", "")
|
11 |
|
12 |
if input_text:
|
13 |
+
encoded_text = tokenizer(input_text, return_tensors="pt", padding=True, truncation=True)
|
14 |
+
|
15 |
translated_text = translator(input_text)
|
16 |
|
17 |
st.write("Translation Vietnamese to English:")
|