Arnaldo Mont'Alvao
Update app.py
849d2cc
raw
history blame
772 Bytes
import streamlit as st
from transformers import pipeline, AutoTokenizer, AutoModelForSeq2SeqLM
#Load model
model = AutoModelForSeq2SeqLM.from_pretrained('unicamp-dl/translation-en-pt-t5')
#Tokenizer
tokenizer = AutoTokenizer.from_pretrained('unicamp-dl/translation-en-pt-t5')
#Set up Translator
translator = pipeline('text2text-generation', model=model, tokenizer=tokenizer)
#Create Streamlit app
st.title('English to Portuguese Translation')
st.write('Enter a sentence here and we will translate it to Portuguese!')
#Add text box
txt_input = st.text_input('Enter text here:')
#When text is entered, run model
if st.button('Submit'):
#Run Translation
translation = translator(txt_input)
#Display translation
st.write(f'Translation: {translation}')