Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,10 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import MarianMTModel, MarianTokenizer, pipeline
|
| 3 |
|
| 4 |
-
#
|
| 5 |
model_names = {
|
| 6 |
"en-ur": "Helsinki-NLP/opus-mt-en-ur",
|
| 7 |
-
"ur-en": "Helsinki-NLP/opus-mt-ur-en"
|
| 8 |
-
"en-fr": "Helsinki-NLP/opus-mt-en-fr",
|
| 9 |
-
"fr-en": "Helsinki-NLP/opus-mt-fr-en",
|
| 10 |
-
"en-de": "Helsinki-NLP/opus-mt-en-de",
|
| 11 |
-
"de-en": "Helsinki-NLP/opus-mt-de-en"
|
| 12 |
}
|
| 13 |
|
| 14 |
models = {}
|
|
@@ -20,15 +16,15 @@ for key, model_name in model_names.items():
|
|
| 20 |
models[key] = pipeline("translation", model=model, tokenizer=tokenizer)
|
| 21 |
|
| 22 |
# Streamlit UI
|
| 23 |
-
st.title("
|
| 24 |
|
| 25 |
# User section on the left
|
| 26 |
st.sidebar.title("User Section")
|
| 27 |
-
input_lang = st.sidebar.selectbox("Select Input Language", ["English", "Urdu"
|
| 28 |
-
output_lang = st.sidebar.selectbox("Select Output Language", ["Urdu", "English"
|
| 29 |
|
| 30 |
# Text input
|
| 31 |
-
input_text = st.text_area("Enter Text to Translate",
|
| 32 |
|
| 33 |
# Translation logic
|
| 34 |
if st.button("Translate"):
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import MarianMTModel, MarianTokenizer, pipeline
|
| 3 |
|
| 4 |
+
# Load translation models for Urdu-English and English-Urdu
|
| 5 |
model_names = {
|
| 6 |
"en-ur": "Helsinki-NLP/opus-mt-en-ur",
|
| 7 |
+
"ur-en": "Helsinki-NLP/opus-mt-ur-en"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
}
|
| 9 |
|
| 10 |
models = {}
|
|
|
|
| 16 |
models[key] = pipeline("translation", model=model, tokenizer=tokenizer)
|
| 17 |
|
| 18 |
# Streamlit UI
|
| 19 |
+
st.title("Urdu-English Translator")
|
| 20 |
|
| 21 |
# User section on the left
|
| 22 |
st.sidebar.title("User Section")
|
| 23 |
+
input_lang = st.sidebar.selectbox("Select Input Language", ["English", "Urdu"])
|
| 24 |
+
output_lang = st.sidebar.selectbox("Select Output Language", ["Urdu", "English"])
|
| 25 |
|
| 26 |
# Text input
|
| 27 |
+
input_text = st.text_area("Enter Text to Translate",placehoder = "Type here...")
|
| 28 |
|
| 29 |
# Translation logic
|
| 30 |
if st.button("Translate"):
|