adeel707 commited on
Commit
b0647fe
Β·
verified Β·
1 Parent(s): 4dd017f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -17
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
- page_bg_img = """
20
- <style>
21
- .main {
22
- background: linear-gradient(135deg, #667eea, #764ba2);
23
- height: 100vh;
24
- padding: 2rem;
25
- }
26
- </style>
27
- <div class="main">
28
- </div>
29
- """
30
- st.markdown(page_bg_img, unsafe_allow_html=True)
31
-
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
- # Set background
34
  set_background()
35
 
36
- # Streamlit app
37
  st.title("🌍 Multilingual Translation App")
38
- st.markdown("### Translate English text into multiple languages using an AI model.")
 
 
 
 
 
 
 
 
 
 
 
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]