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()