Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -26,28 +26,42 @@ def translate_text(model, tokenizer, text):
|
|
| 26 |
translated_text = tokenizer.decode(translated[0], skip_special_tokens=True)
|
| 27 |
return translated_text
|
| 28 |
|
| 29 |
-
# Streamlit app layout with
|
| 30 |
st.markdown("""
|
| 31 |
<style>
|
| 32 |
body {
|
| 33 |
-
background:
|
| 34 |
-
color:
|
| 35 |
}
|
| 36 |
.stApp {
|
| 37 |
-
background:
|
| 38 |
}
|
| 39 |
.css-1d391kg {
|
| 40 |
-
background-color:
|
| 41 |
-
color:
|
| 42 |
border-radius: 10px;
|
| 43 |
padding: 20px;
|
| 44 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
</style>
|
| 46 |
""", unsafe_allow_html=True)
|
| 47 |
|
| 48 |
-
# App title and subtitle with
|
| 49 |
-
st.markdown("<h1 style='text-align: center; color:
|
| 50 |
-
st.markdown("<p style='text-align: center; color: #
|
| 51 |
|
| 52 |
# Sidebar for language selection and instructions
|
| 53 |
st.sidebar.title("Language Options")
|
|
@@ -59,11 +73,11 @@ st.sidebar.write("2. Select the target language from the options.")
|
|
| 59 |
st.sidebar.write("3. Click **Translate** to get the result.")
|
| 60 |
|
| 61 |
# Input text
|
| 62 |
-
st.markdown("<h3 style='color:
|
| 63 |
text = st.text_area("", height=150)
|
| 64 |
|
| 65 |
# Character count
|
| 66 |
-
st.write(f"<p style='color:
|
| 67 |
|
| 68 |
# Button to translate
|
| 69 |
if st.button("Translate"):
|
|
@@ -78,7 +92,7 @@ if st.button("Translate"):
|
|
| 78 |
translated_text = translate_text(model, tokenizer, text)
|
| 79 |
|
| 80 |
# Display the translation
|
| 81 |
-
st.markdown(f"<h3 style='color:
|
| 82 |
st.success(translated_text)
|
| 83 |
else:
|
| 84 |
st.error("Please enter text to translate.")
|
|
|
|
| 26 |
translated_text = tokenizer.decode(translated[0], skip_special_tokens=True)
|
| 27 |
return translated_text
|
| 28 |
|
| 29 |
+
# Streamlit app layout with dark color scheme
|
| 30 |
st.markdown("""
|
| 31 |
<style>
|
| 32 |
body {
|
| 33 |
+
background-color: #121212;
|
| 34 |
+
color: #e0e0e0;
|
| 35 |
}
|
| 36 |
.stApp {
|
| 37 |
+
background-color: #121212;
|
| 38 |
}
|
| 39 |
.css-1d391kg {
|
| 40 |
+
background-color: #1f1f1f;
|
| 41 |
+
color: #e0e0e0;
|
| 42 |
border-radius: 10px;
|
| 43 |
padding: 20px;
|
| 44 |
}
|
| 45 |
+
.stButton > button {
|
| 46 |
+
background-color: #1f1f1f;
|
| 47 |
+
color: #e0e0e0;
|
| 48 |
+
border: 1px solid #333;
|
| 49 |
+
}
|
| 50 |
+
.stButton > button:hover {
|
| 51 |
+
background-color: #333;
|
| 52 |
+
border: 1px solid #444;
|
| 53 |
+
}
|
| 54 |
+
.stTextArea textarea {
|
| 55 |
+
background-color: #1f1f1f;
|
| 56 |
+
color: #e0e0e0;
|
| 57 |
+
border: 1px solid #333;
|
| 58 |
+
}
|
| 59 |
</style>
|
| 60 |
""", unsafe_allow_html=True)
|
| 61 |
|
| 62 |
+
# App title and subtitle with dark theme
|
| 63 |
+
st.markdown("<h1 style='text-align: center; color: #e0e0e0;'>π Polyglot Translator π</h1>", unsafe_allow_html=True)
|
| 64 |
+
st.markdown("<p style='text-align: center; color: #b0b0b0; font-size: 20px;'>Empowering You to Speak Any Language!</p>", unsafe_allow_html=True)
|
| 65 |
|
| 66 |
# Sidebar for language selection and instructions
|
| 67 |
st.sidebar.title("Language Options")
|
|
|
|
| 73 |
st.sidebar.write("3. Click **Translate** to get the result.")
|
| 74 |
|
| 75 |
# Input text
|
| 76 |
+
st.markdown("<h3 style='color: #e0e0e0;'>Enter text in English to translate:</h3>", unsafe_allow_html=True)
|
| 77 |
text = st.text_area("", height=150)
|
| 78 |
|
| 79 |
# Character count
|
| 80 |
+
st.write(f"<p style='color: #e0e0e0;'>Character count: {len(text)}</p>", unsafe_allow_html=True)
|
| 81 |
|
| 82 |
# Button to translate
|
| 83 |
if st.button("Translate"):
|
|
|
|
| 92 |
translated_text = translate_text(model, tokenizer, text)
|
| 93 |
|
| 94 |
# Display the translation
|
| 95 |
+
st.markdown(f"<h3 style='color: #e0e0e0;'>Translated Text ({language}):</h3>", unsafe_allow_html=True)
|
| 96 |
st.success(translated_text)
|
| 97 |
else:
|
| 98 |
st.error("Please enter text to translate.")
|