Eng-Ass-Former / app.py
rbgo's picture
Update app.py
4a820b2
import streamlit as st
import model
import inference
with st.spinner('Your TransFormer is on the way...'):
if 'transformer' not in st.session_state:
transformer,tokenizer_ass,tokenizer_en,MAX_LENGTH = model.prepare_model()
st.session_state['transformer'] = transformer
st.session_state['tokenizer_ass'] = tokenizer_ass
st.session_state['tokenizer_en'] = tokenizer_en
st.session_state['MAX_LENGTH'] = MAX_LENGTH
def show_information():
st.header('Translate Assamese with Transformer!🤖')
def select_text():
option = st.selectbox(
'Suggested Assamese Sentences',
('মানুহে সদায় ইজনে সিজনক সহায় কৰিব লাগিব',
'আমি সদায় আমাৰ মাক সন্মান কৰিব লাগিব',
'আপুনি আপোনাৰ সপোন প্ৰাপ্ত নকৰালৈকে সদায় কঠোৰ আৰু কঠোৰ পৰিশ্ৰম কৰিব লাগিব'))
st.write('You have selected suggested text')
title = st.text_input('Assamese Text Input', option)
# st.write('Your Assamese Text', title)
return title
def main():
st.title('📚Assamese to English Translator🤖')
show_information()
text = select_text()
if st.button('Translate'):
result = inference.translate_main(st.session_state['transformer'],text,st.session_state['tokenizer_ass'],
st.session_state['tokenizer_en'],st.session_state['MAX_LENGTH'])
st.caption('Your Assamese translated text')
st.text(result)
if __name__ == "__main__":
main()