Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from PIL import Image
|
| 3 |
-
import
|
| 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
|
| 14 |
-
def
|
| 15 |
-
"""
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
|
| 32 |
# --- CSS Personnalisé ---
|
| 33 |
st.markdown(
|
| 34 |
-
"""
|
| 35 |
<style>
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 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:
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
color:
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
}
|
| 111 |
-
.
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
color:
|
| 120 |
-
}
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
color:
|
| 126 |
-
|
|
|
|
| 127 |
</style>
|
| 128 |
""",
|
| 129 |
unsafe_allow_html=True
|
| 130 |
)
|
| 131 |
|
| 132 |
-
# --- Titre
|
| 133 |
-
st.
|
| 134 |
-
|
|
|
|
|
|
|
| 135 |
|
| 136 |
-
# ---
|
| 137 |
col1, col2 = st.columns(2)
|
| 138 |
|
| 139 |
with col1:
|
| 140 |
-
|
| 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 |
-
#
|
| 146 |
if uploaded_files:
|
| 147 |
-
st.
|
| 148 |
-
st.write("Aperçu des images :")
|
| 149 |
for uploaded_file in uploaded_files:
|
| 150 |
-
|
| 151 |
-
|
|
|
|
| 152 |
|
| 153 |
with col2:
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 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.
|
| 168 |
-
if st.button("🚀 Lancer l'analyse"):
|
| 169 |
if uploaded_files:
|
| 170 |
-
st.write("Type d'analyse sélectionné :",
|
| 171 |
-
with st.spinner(
|
| 172 |
-
#
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 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("
|
|
|
|
|
|
| 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)
|