Spaces:
Runtime error
Runtime error
import streamlit as st | |
import joblib | |
from PIL import Image | |
with st.sidebar: | |
st.subheader('English to Hindi Translator') | |
st.write('This model is trained on OPUS dataset. This open parallel is the collection of translated texts from the web. It also includes translations of Wikipedia, WikiSource, WikiBooks, WikiNews and WikiQuote web pages.Built using MarianMT model') | |
image = Image.open('image.png') | |
st.image(image, caption='MarianMT model') | |
st.code('App Built by Ambuj Raj',language='python') | |
st.header("English to Hindi Translator") | |
text = st.text_input("Enter text to translate") | |
if st.button("Translate"): | |
with st.spinner("Translating..."): | |
model = joblib.load('model.sav') | |
tokenizer = joblib.load('tokenizer.sav') | |
input_ids = tokenizer.encode(text, return_tensors="pt", padding=True) | |
outputs = model.generate(input_ids) | |
decoded_text = tokenizer.decode(outputs[0], skip_special_tokens=True) | |
st.success("Done!") | |
st.write("Hindi Translation: ",decoded_text) |