demo1 / app.py
phunlh2001's picture
fixed: change position of button
0c147dc verified
raw
history blame contribute delete
637 Bytes
import streamlit as st
from transformers import pipeline, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("Helsinki-NLP/opus-mt-vi-en")
translator = pipeline("translation_vi_to_en", model="Helsinki-NLP/opus-mt-vi-en")
st.title("Demo translate VI - EN")
input_text = st.text_area("Input the Vietnamese text:", "")
if st.button("Submit"):
if input_text:
encoded_text = tokenizer(input_text, return_tensors="pt", padding=True, truncation=True)
translated_text = translator(input_text)
st.write("Translation Vietnamese to English:")
st.write(translated_text[0]["translation_text"])