Docfile commited on
Commit
25f0e13
·
verified ·
1 Parent(s): 725d2cb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +107 -148
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import streamlit as st
2
  from PIL import Image
3
- import time
4
 
5
  # Configuration de la page
6
  st.set_page_config(
@@ -10,176 +10,135 @@ st.set_page_config(
10
  initial_sidebar_state="expanded"
11
  )
12
 
13
- # --- Fonctions de simulation d'analyse ---
14
- def simulate_analysis_type_1(image):
15
- """Simule une analyse de type 1."""
16
- time.sleep(2) # Simule un traitement
17
- # Ici, vous ajouteriez le code pour traiter l'image avec le type 1
18
- st.write("Résultats de l'analyse de type 1 (simulation) :")
19
- # Exemple : détection d'objets (simulation)
20
- st.image(image, caption="Image avec détection d'objets (simulation)")
21
- st.write("Objets détectés : voiture (80%), personne (70%), route (90%)")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
- def simulate_analysis_type_2(image):
24
- """Simule une analyse de type 2."""
25
- time.sleep(3) # Simule un traitement plus long
26
- # Ici, vous ajouteriez le code pour traiter l'image avec le type 2
27
- st.write("Résultats de l'analyse de type 2 (simulation) :")
28
- # Exemple : analyse de texte (simulation)
29
- st.image(image, caption="Image avec analyse de texte (simulation)")
30
- st.write("Texte détecté : 'Welcome to London' (95%)")
31
 
32
  # --- CSS Personnalisé ---
33
  st.markdown(
34
- """
35
  <style>
36
- body {
37
- background-color: #f8f8f8; /* Fond légèrement plus clair */
38
- font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* Police plus moderne */
39
- }
40
- /* Titre principal */
41
- .title {
42
- color: #2c3e50; /* Bleu foncé */
43
- text-align: center;
44
- font-size: 3.5em;
45
- font-weight: 800;
46
- padding: 0.5em;
47
- margin-bottom: 0.5em;
48
- background-color: #ecf0f1; /* Fond gris clair */
49
- border-radius: 10px; /* Coins arrondis */
50
- box-shadow: 3px 3px 5px #888888; /* Ombre légère */
51
- }
52
- /* Introduction */
53
- .intro {
54
- text-align: center;
55
- font-size: 1.3em;
56
- margin-bottom: 2em;
57
- color: #34495e; /* Gris bleu */
58
- }
59
- /* Conteneurs */
60
- .container {
61
- background-color: white;
62
- border-radius: 10px;
63
- padding: 1.5em;
64
- margin-bottom: 1em;
65
- box-shadow: 2px 2px 4px #888888;
66
- }
67
- /* Bouton */
68
- .stButton>button {
69
- background-color: #007bff; /* Bleu vif */
70
- color: white;
71
- padding: 0.8em 1.8em;
72
- border-radius: 25px; /* Coins très arrondis */
73
- font-weight: 600;
74
- font-size: 1.1em;
75
- transition: all 0.3s ease; /* Transition douce */
76
- }
77
- .stButton>button:hover {
78
- background-color: #0056b3; /* Bleu plus foncé au survol */
79
- transform: translateY(-2px); /* Léger déplacement vers le haut */
80
- box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.2); /* Ombre plus prononcée au survol */
81
- }
82
- /* Uploader de fichiers */
83
- .stFileUploader {
84
- padding: 1.5em;
85
- border: 2px dashed #007bff;
86
- border-radius: 10px;
87
- }
88
- /* Radio buttons */
89
- .stRadio>div>label {
90
  font-weight: 600;
91
- color: #2c3e50;
92
- font-size: 1.1em;
93
- padding: 0.5em 0;
94
- }
95
- .stRadio>div>label>div>p {
96
- font-size: 1em; /* Texte descriptif plus petit */
97
- font-weight: 400;
98
- color: #34495e;
99
- }
100
- /* Spinner */
101
- .stSpinner {
102
- text-align: center;
103
- color: #007bff;
104
- }
105
- /* Messages */
106
- .stSuccess, .stWarning, .stError {
107
- border-radius: 10px;
108
- padding: 1em;
109
- font-weight: 600;
110
- }
111
- .stSuccess {
112
- background-color: #d4edda;
113
- border-color: #c3e6cb;
114
- color: #155724;
115
- }
116
- .stWarning {
117
- background-color: #fff3cd;
118
- border-color: #ffeeba;
119
- color: #856404;
120
- }
121
- /* Pied de page */
122
- footer {
123
- text-align: center;
124
- margin-top: 2em;
125
- color: #666;
126
- }
 
127
  </style>
128
  """,
129
  unsafe_allow_html=True
130
  )
131
 
132
- # --- Titre et introduction ---
133
- st.markdown("<div class='title'>✨ Mariam Anglais ✨</div>", unsafe_allow_html=True)
134
- st.markdown("<div class='intro'>Votre plateforme d'analyse d'images intelligente et ultra-réaliste !</div>", unsafe_allow_html=True)
 
 
135
 
136
- # --- Conteneurs pour une meilleure disposition ---
137
  col1, col2 = st.columns(2)
138
 
139
  with col1:
140
- st.markdown("<div class='container'>", unsafe_allow_html=True)
141
- # Téléchargement d'images
142
  uploaded_files = st.file_uploader("Choisissez des images", type=["jpg", "jpeg", "png"], accept_multiple_files=True)
143
- st.markdown("</div>", unsafe_allow_html=True)
144
 
145
- # Aperçu des images téléchargées
146
  if uploaded_files:
147
- st.markdown("<div class='container'>", unsafe_allow_html=True)
148
- st.write("Aperçu des images :")
149
  for uploaded_file in uploaded_files:
150
- st.image(uploaded_file, width=200)
151
- st.markdown("</div>", unsafe_allow_html=True)
 
152
 
153
  with col2:
154
- st.markdown("<div class='container'>", unsafe_allow_html=True)
155
- # Choix du type d'analyse
156
- analysis_type = st.radio(
157
- "Choisissez le type d'analyse :",
158
- (
159
- "🔍 Type 1: Détection d'objets",
160
- "🧠 Type 2: Analyse de texte"
161
- ),
162
- format_func=lambda x: x.split(":")[1] # Affiche uniquement la description
163
- )
164
- st.markdown("</div>", unsafe_allow_html=True)
165
 
166
- # Bouton de soumission
167
- st.markdown("<div class='container'>", unsafe_allow_html=True)
168
- if st.button("🚀 Lancer l'analyse"):
169
  if uploaded_files:
170
- st.write("Type d'analyse sélectionné :", analysis_type.split(":")[1])
171
- with st.spinner(f"Analyse de type {analysis_type.split(':')[0]} en cours..."):
172
- # Traitement des images
173
- for uploaded_file in uploaded_files:
174
- image = Image.open(uploaded_file)
175
- if "Type 1" in analysis_type:
176
- simulate_analysis_type_1(image)
177
- elif "Type 2" in analysis_type:
178
- simulate_analysis_type_2(image)
179
- st.success("✅ Analyse terminée !")
180
  else:
181
- st.warning("⚠️ Veuillez télécharger au moins une image.")
182
- st.markdown("</div>", unsafe_allow_html=True)
183
 
184
  # --- Pied de page ---
185
- st.markdown("<footer>© 2023 Mariam Anglais - Tous droits réservés.</footer>", unsafe_allow_html=True)
 
 
1
  import streamlit as st
2
  from PIL import Image
3
+ import numpy as np
4
 
5
  # Configuration de la page
6
  st.set_page_config(
 
10
  initial_sidebar_state="expanded"
11
  )
12
 
13
+ # --- Fonctions pour effets visuels ---
14
+ def gradient_background(start_color, end_color):
15
+ """Génère un fond dégradé."""
16
+ st.markdown(
17
+ f"""
18
+ <style>
19
+ body {{
20
+ background: linear-gradient(to right, {start_color}, {end_color});
21
+ background-size: 120% 120%;
22
+ animation: gradient 5s ease infinite;
23
+ }}
24
+ @keyframes gradient {{
25
+ 0% {{ background-position: 0% 50%; }}
26
+ 50% {{ background-position: 100% 50%; }}
27
+ 100% {{ background-position: 0% 50%; }}
28
+ }}
29
+ </style>
30
+ """,
31
+ unsafe_allow_html=True
32
+ )
33
+
34
+ def neon_effect(text, color):
35
+ """Ajoute un effet néon à un texte."""
36
+ return f"<span style='color: {color}; text-shadow: 0 0 5px {color};'>{text}</span>"
37
 
38
+ # --- Couleurs ---
39
+ start_color = "#0078D7" # Bleu Microsoft
40
+ end_color = "#00B294" # Vert émeraude
41
+ text_color = "#FFFFFF" # Blanc
42
+ neon_blue = "#66CCFF" # Bleu néon
43
+
44
+ # --- Appliquer le fond dégradé ---
45
+ gradient_background(start_color, end_color)
46
 
47
  # --- CSS Personnalisé ---
48
  st.markdown(
49
+ f"""
50
  <style>
51
+ .stApp {{
52
+ font-family: 'Segoe UI', sans-serif;
53
+ }}
54
+ .stFileUploader {{
55
+ padding: 1.5rem;
56
+ border: 3px dashed {neon_blue};
57
+ border-radius: 1rem;
58
+ }}
59
+ .stRadio>div>label {{
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  font-weight: 600;
61
+ color: {text_color};
62
+ padding: 0.75rem 1.5rem;
63
+ margin-bottom: 0.5rem;
64
+ border-radius: 0.5rem;
65
+ border: 2px solid {neon_blue};
66
+ background-color: rgba(0, 0, 0, 0.2);
67
+ }}
68
+ .stRadio>div>label:hover {{
69
+ background-color: {neon_blue};
70
+ color: black;
71
+ }}
72
+ .stButton>button {{
73
+ background-color: {neon_blue};
74
+ color: black;
75
+ padding: 0.75rem 1.5rem;
76
+ border-radius: 0.5rem;
77
+ font-weight: bold;
78
+ box-shadow: 0 0 10px {neon_blue};
79
+ transition: all 0.3s ease;
80
+ }}
81
+ .stButton>button:hover {{
82
+ transform: scale(1.05);
83
+ box-shadow: 0 0 15px {neon_blue};
84
+ }}
85
+ .st-bb {{
86
+ border-bottom: 3px solid {neon_blue};
87
+ }}
88
+ .st-eb, .st-ec, .st-ed, .st-ee, .st-ef, .st-eg, .st-eh, .st-ei, .st-ej {{
89
+ color: {text_color};
90
+ }}
91
+ .uploadedFiles {{
92
+ color: {neon_blue}
93
+ }}
94
+ .uploadedFile {{
95
+ color: {neon_blue};
96
+ font-weight: bold;
97
+ }}
98
  </style>
99
  """,
100
  unsafe_allow_html=True
101
  )
102
 
103
+ # --- Titre avec effet néon ---
104
+ st.title(neon_effect(" Mariam Anglais ", neon_blue))
105
+
106
+ # --- Introduction ---
107
+ st.markdown(f"<p style='color: {text_color}; font-size: 1.2rem;'>Bienvenue sur votre plateforme d'analyse d'images intelligente ! Téléchargez vos images, choisissez votre type d'analyse, et laissez la magie opérer.</p>", unsafe_allow_html=True)
108
 
109
+ # --- Colonnes ---
110
  col1, col2 = st.columns(2)
111
 
112
  with col1:
113
+ # --- Téléchargement d'images ---
 
114
  uploaded_files = st.file_uploader("Choisissez des images", type=["jpg", "jpeg", "png"], accept_multiple_files=True)
 
115
 
116
+ # --- Effet sur les images téléchargées ---
117
  if uploaded_files:
118
+ st.write(f"<p style='color: {neon_blue}; font-weight: bold; font-size: 1.1rem;'>Aperçu des images :</p>", unsafe_allow_html=True)
 
119
  for uploaded_file in uploaded_files:
120
+ img = Image.open(uploaded_file)
121
+ img = np.array(img)
122
+ st.image(img, width=200, use_column_width='auto', output_format='JPEG')
123
 
124
  with col2:
125
+ # --- Choix du type d'analyse avec effet néon ---
126
+ analysis_type = st.radio("Choisissez le type d'analyse :",
127
+ (neon_effect("🔍 Type 1", neon_blue), neon_effect("🧠 Type 2", neon_blue)))
 
 
 
 
 
 
 
 
128
 
129
+ # --- Bouton de soumission avec effet néon ---
130
+ if st.button("🚀 Soumettre"):
 
131
  if uploaded_files:
132
+ st.write(f"<p style='color: {text_color};'>Type d'analyse sélectionné : {analysis_type}</p>", unsafe_allow_html=True)
133
+ with st.spinner(neon_effect("Analyse en cours...", neon_blue)):
134
+ # Insérez ici le code pour effectuer l'analyse d'image
135
+ import time
136
+ time.sleep(3)
137
+
138
+ st.success(neon_effect("✅ Analyse terminée !", neon_blue))
 
 
 
139
  else:
140
+ st.warning(neon_effect("⚠️ Veuillez télécharger au moins une image.", neon_blue))
 
141
 
142
  # --- Pied de page ---
143
+ st.markdown("---")
144
+ st.write(f"<p style='color: {text_color};'>© 2023 Mariam Anglais - Tous droits réservés.</p>", unsafe_allow_html=True)