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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +135 -31
app.py CHANGED
@@ -1,4 +1,6 @@
1
  import streamlit as st
 
 
2
 
3
  # Configuration de la page
4
  st.set_page_config(
@@ -8,74 +10,176 @@ st.set_page_config(
8
  initial_sidebar_state="expanded"
9
  )
10
 
11
- # CSS personnalisé pour un design plus esthétique
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  st.markdown(
13
  """
14
  <style>
15
  body {
16
- background-color: #f4f4f4;
17
- font-family: 'Arial', sans-serif;
 
 
 
 
 
 
 
 
 
 
 
 
18
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  .stButton>button {
20
- background-color: #4CAF50;
21
  color: white;
22
- padding: 0.75rem 1.5rem;
23
- border-radius: 0.5rem;
24
- font-weight: bold;
 
 
 
 
 
 
 
25
  }
 
26
  .stFileUploader {
27
- padding: 1rem;
28
- border: 2px dashed #4CAF50;
29
- border-radius: 0.5rem;
30
  }
 
31
  .stRadio>div>label {
32
- font-weight: bold;
 
 
 
33
  }
34
- .st-bb {
35
- border-bottom: 2px solid #4CAF50;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  }
37
  </style>
38
  """,
39
  unsafe_allow_html=True
40
  )
41
 
42
- # Titre et introduction
43
- st.title(" Mariam Anglais ")
44
- st.markdown("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.")
45
 
46
- # Colonnes pour une meilleure disposition
47
  col1, col2 = st.columns(2)
48
 
49
  with col1:
 
50
  # Téléchargement d'images
51
  uploaded_files = st.file_uploader("Choisissez des images", type=["jpg", "jpeg", "png"], accept_multiple_files=True)
 
52
 
53
  # Aperçu des images téléchargées
54
  if uploaded_files:
 
55
  st.write("Aperçu des images :")
56
  for uploaded_file in uploaded_files:
57
  st.image(uploaded_file, width=200)
 
58
 
59
  with col2:
 
60
  # Choix du type d'analyse
61
- analysis_type = st.radio("Choisissez le type d'analyse :",
62
- ("🔍 Type 1", "🧠 Type 2"))
 
 
 
 
 
 
 
63
 
64
  # Bouton de soumission
65
- if st.button("🚀 Soumettre"):
 
66
  if uploaded_files:
67
- st.write("Type d'analyse sélectionné :", analysis_type)
68
- with st.spinner("Analyse en cours..."):
69
- # Insérez ici le code pour effectuer l'analyse d'image
70
- # en fonction du type d'analyse choisi.
71
- # Simule un traitement pour l'exemple
72
- import time
73
- time.sleep(3)
74
-
 
75
  st.success("✅ Analyse terminée !")
76
  else:
77
  st.warning("⚠️ Veuillez télécharger au moins une image.")
 
78
 
79
- # Pied de page
80
- st.markdown("---")
81
- st.write("© 2023 Mariam Anglais - Tous droits réservés.")
 
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
  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)