Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
-
import base64
|
4 |
|
5 |
# Mapping target languages to specific Hugging Face models
|
6 |
MODEL_MAPPING = {
|
@@ -16,26 +15,49 @@ MODEL_MAPPING = {
|
|
16 |
|
17 |
# Function to set background gradient
|
18 |
def set_background():
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
-
#
|
34 |
set_background()
|
35 |
|
36 |
-
#
|
37 |
st.title("π Multilingual Translation App")
|
38 |
-
st.markdown("### Translate English text into multiple languages using
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
# Sidebar for language selection
|
41 |
selected_language = st.sidebar.selectbox("π Select Target Language", list(MODEL_MAPPING.keys()))
|
@@ -43,6 +65,7 @@ selected_language = st.sidebar.selectbox("π Select Target Language", list(MOD
|
|
43 |
# User input
|
44 |
user_input = st.text_area("βοΈ Enter text in English:")
|
45 |
|
|
|
46 |
if st.button("Translate β¨"):
|
47 |
if user_input.strip():
|
48 |
model_name = MODEL_MAPPING[selected_language]
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
|
|
3 |
|
4 |
# Mapping target languages to specific Hugging Face models
|
5 |
MODEL_MAPPING = {
|
|
|
15 |
|
16 |
# Function to set background gradient
|
17 |
def set_background():
|
18 |
+
st.markdown(
|
19 |
+
"""
|
20 |
+
<style>
|
21 |
+
/* Set full-page gradient background */
|
22 |
+
.stApp {
|
23 |
+
background: linear-gradient(135deg, #ff0080, #ff8c00);
|
24 |
+
color: white;
|
25 |
+
}
|
26 |
+
/* Style headers */
|
27 |
+
h1, h2, h3, h4 {
|
28 |
+
color: white;
|
29 |
+
}
|
30 |
+
/* Style sidebar */
|
31 |
+
.css-1d391kg {
|
32 |
+
background-color: rgba(255, 255, 255, 0.2) !important;
|
33 |
+
}
|
34 |
+
/* Style text area */
|
35 |
+
.stTextArea textarea {
|
36 |
+
background-color: rgba(255, 255, 255, 0.2) !important;
|
37 |
+
color: white !important;
|
38 |
+
}
|
39 |
+
</style>
|
40 |
+
""",
|
41 |
+
unsafe_allow_html=True
|
42 |
+
)
|
43 |
|
44 |
+
# Apply background
|
45 |
set_background()
|
46 |
|
47 |
+
# App title and description
|
48 |
st.title("π Multilingual Translation App")
|
49 |
+
st.markdown("### Translate English text into multiple languages using AI.")
|
50 |
+
st.write(
|
51 |
+
"""
|
52 |
+
This app allows you to translate English text into multiple languages using AI-powered translation models.
|
53 |
+
Select your target language and enter your text to get an accurate translation.
|
54 |
+
|
55 |
+
**How to Use:**
|
56 |
+
1. Select a target language from the sidebar.
|
57 |
+
2. Enter the text you want to translate.
|
58 |
+
3. Click the "Translate" button to generate the translation.
|
59 |
+
"""
|
60 |
+
)
|
61 |
|
62 |
# Sidebar for language selection
|
63 |
selected_language = st.sidebar.selectbox("π Select Target Language", list(MODEL_MAPPING.keys()))
|
|
|
65 |
# User input
|
66 |
user_input = st.text_area("βοΈ Enter text in English:")
|
67 |
|
68 |
+
# Translation logic
|
69 |
if st.button("Translate β¨"):
|
70 |
if user_input.strip():
|
71 |
model_name = MODEL_MAPPING[selected_language]
|