Spaces:
Runtime error
Runtime error
import streamlit as st | |
from transformers import pipeline | |
pipeline = pipeline(task="translation", model="guymorlan/English2Shami") | |
st.title("English to Levantine Arabic") | |
num_translations = st.sidebar.selectbox("Number of Translations:", [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], index=2) | |
input_text = st.text_input("Enter English text:") | |
if input_text: | |
result = pipeline(input_text, max_length=1024, num_return_sequences=num_translations, num_beams=max(num_translations, 5)) | |
# st.markdown("<div style='font-size:24px; text-align:right; direction:rtl;'>", unsafe_allow_html=True) | |
outs = list(set([x["translation_text"] for x in result])) | |
for i in range(len(outs)): | |
st.markdown(f"<div style='font-size:24px; text-align:right; direction:rtl;'>{outs[i]}</div>", unsafe_allow_html=True) | |
st.markdown("<br>", unsafe_allow_html=True) | |
#st.markdown("</div>", unsafe_allow_html=True) |