import streamlit as st import pandas as pd import numpy as np import re from datetime import datetime import subprocess from fairseq.models.transformer import TransformerModel time_interval=0 st.title('Knowledge Distillation for Multi-Domain Neural Machine Translation') title = st.text_input('English Text', 'We are not inclined to entertain this petition under Article 32 of the Constitution of India.') if st.button('Law En-Hi Teacher'): time_1 = datetime.now() zh2en = TransformerModel.from_pretrained('law/out/tokenized.en-hi/', checkpoint_file='../../checkpoint_best.pt',bpe='subword_nmt', bpe_codes='/home/sakharam/RnD/translation/en-hi/bpe-codes/codes.en',tokenizer='moses') time_2 = datetime.now() time_interval = time_2 - time_1 st.write('Hindi Translation: ',zh2en.translate([title.lower()])[0]) st.write('Inference Time: ',time_interval) if st.button('Sports En-Hi Teacher'): time_1 = datetime.now() zh2en = TransformerModel.from_pretrained('sports/out/tokenized.en-hi/', checkpoint_file='../../checkpoint_best.pt',bpe='subword_nmt', bpe_codes='/home/sakharam/RnD/translation/en-hi/bpe-codes/codes.en',tokenizer='moses') time_2 = datetime.now() time_interval = time_2 - time_1 st.write('Hindi Translation: ',zh2en.translate([title.lower()])[0]) st.write('Inference Time: ',time_interval) if st.button('Tourism En-Hi Teacher'): time_1 = datetime.now() zh2en = TransformerModel.from_pretrained('tourism/out/tokenized.en-hi/', checkpoint_file='../../checkpoint_best.pt',bpe='subword_nmt', bpe_codes='/home/sakharam/RnD/translation/en-hi/bpe-codes/codes.en',tokenizer='moses') time_2 = datetime.now() time_interval = time_2 - time_1 st.write('Hindi Translation: ',zh2en.translate([title.lower()])[0]) st.write('Inference Time: ',time_interval) if st.button('Multi-Domain En-Hi Student'): time_1 = datetime.now() zh2en = TransformerModel.from_pretrained('multi/out/tokenized.en-hi/', checkpoint_file='../../checkpoint_best.pt',bpe='subword_nmt', bpe_codes='/home/sakharam/RnD/translation/en-hi/bpe-codes/codes.en',tokenizer='moses') time_2 = datetime.now() time_interval = time_2 - time_1 st.write('Hindi Translation: ',zh2en.translate([title.lower()])[0]) st.write('Inference Time: ',time_interval)