File size: 1,734 Bytes
7e9669a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4a820b2
7e9669a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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()