File size: 833 Bytes
9863176
 
 
 
 
 
d64b152
b2774fc
 
dbea2e3
 
 
9863176
24f5f3a
9863176
 
edb94c3
 
 
 
 
 
 
 
 
 
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
import streamlit as st
import transformers
from transformers import pipeline
import indicnlp
from indicnlp.transliterate.unicode_transliterate import UnicodeIndicTransliterator

model_checkpoint = './MKB_NIOS_hindi_sanskrit_5'
translator = pipeline('translation', model=model_checkpoint, decoder_start_token='<2sa>')

st.title('NLTM')

st.header('Hindi-Sanskrit Translation Model')
query = st.text_input("Enter the Input Sentence", "")
submit = st.button('Translate') 
input_sentence = query + ' </s>' + ' <2hi>'

if submit:
  st.subheader('Sanskrit Sentence')
  
  with st.spinner(text='This may take a moment...'):
    output_sentence = translator(input_sentence,max_length=128)
    
  output_sentence = output_sentence[0]["translation_text"]
  output_sentence = output_sentence.replace('<2sa>','')
    
  st.write(output_sentence)