File size: 608 Bytes
183264b
dca9d10
 
 
183264b
75b4131
183264b
75b4131
183264b
75b4131
183264b
75b4131
dca9d10
 
75b4131
183264b
75b4131
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 translation with pretrained model")

input_text = st.text_area("Nhập văn bản tiếng Việt:", "")

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"])