-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
177 lines (154 loc) · 6.12 KB
/
Copy pathapp.py
File metadata and controls
177 lines (154 loc) · 6.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import streamlit as st
from pathlib import Path
# Configuration de la page
st.set_page_config(
page_title="Teachable Machine IA",
page_icon="🧠",
layout="wide",
initial_sidebar_state="expanded"
)
# Initialisation des variables de session
if 'problem_type' not in st.session_state:
st.session_state.problem_type = None
if 'use_deep_learning' not in st.session_state:
st.session_state.use_deep_learning = False
if 'data' not in st.session_state:
st.session_state.data = None
if 'X_train' not in st.session_state:
st.session_state.X_train = None
if 'X_test' not in st.session_state:
st.session_state.X_test = None
if 'y_train' not in st.session_state:
st.session_state.y_train = None
if 'y_test' not in st.session_state:
st.session_state.y_test = None
if 'model' not in st.session_state:
st.session_state.model = None
if 'model_name' not in st.session_state:
st.session_state.model_name = None
if 'preprocessing_steps' not in st.session_state:
st.session_state.preprocessing_steps = []
if 'target_column' not in st.session_state:
st.session_state.target_column = None
if 'data_type' not in st.session_state:
st.session_state.data_type = 'tabular' # 'tabular' or 'image'
if 'training_history' not in st.session_state:
st.session_state.training_history = None
if 'scaler' not in st.session_state:
st.session_state.scaler = None
if 'encoder' not in st.session_state:
st.session_state.encoder = None
# CSS personnalisé pour un design moderne
st.markdown("""
<style>
.main-header {
font-size: 3rem;
font-weight: bold;
text-align: center;
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
margin-bottom: 2rem;
}
.sub-header {
text-align: center;
color: #666;
font-size: 1.2rem;
margin-bottom: 3rem;
}
.stButton>button {
width: 100%;
border-radius: 10px;
height: 3em;
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
color: white;
font-weight: bold;
}
.info-box {
padding: 1.5rem;
border-radius: 10px;
background-color: #f0f2f6;
margin: 1rem 0;
}
</style>
""", unsafe_allow_html=True)
# Page d'accueil
st.markdown('<h1 class="main-header">🧠 Teachable Machine IA</h1>', unsafe_allow_html=True)
st.markdown('<p class="sub-header">Construisez, entraînez et évaluez vos modèles d\'IA sans coder</p>', unsafe_allow_html=True)
# Navigation dans la sidebar
st.sidebar.title("📚 Navigation")
st.sidebar.markdown("---")
# Statut du workflow
st.sidebar.subheader("🔄 Progression")
steps = {
"1️⃣ Accueil": True,
"2️⃣ Chargement": st.session_state.data is not None,
"3️⃣ Prétraitement": st.session_state.X_train is not None,
"4️⃣ Modèle": st.session_state.model_name is not None,
"5️⃣ Entraînement": st.session_state.model is not None,
"6️⃣ Évaluation": st.session_state.model is not None,
"7️⃣ Résumé": st.session_state.model is not None
}
for step, completed in steps.items():
icon = "✅" if completed else "⭕"
st.sidebar.markdown(f"{icon} {step}")
st.sidebar.markdown("---")
st.sidebar.info("💡 **Astuce**: Suivez les étapes dans l'ordre pour créer votre modèle IA.")
# Introduction
col1, col2, col3 = st.columns(3)
with col1:
st.markdown("### 🎯 Objectif")
st.write("Créez des modèles d'IA personnalisés pour résoudre vos problèmes de classification ou de régression.")
with col2:
st.markdown("### 🚀 Simplicité")
st.write("Interface intuitive sans code. Chargez vos données, configurez et entraînez en quelques clics.")
with col3:
st.markdown("### 🧪 Flexibilité")
st.write("ML classique ou Deep Learning. Datasets tabulaires ou images. Vous choisissez!")
st.markdown("---")
# Choix du type de problème
st.markdown("## 🎮 Commencez votre projet")
col1, col2 = st.columns(2)
with col1:
st.markdown("### 🧩 Classification")
st.write("Prédisez des catégories (ex: chat ou chien, spam ou non-spam)")
if st.button("🧩 Choisir Classification", key="classification"):
st.session_state.problem_type = "classification"
st.success("✅ Classification sélectionnée!")
st.info("👉 Rendez-vous dans la page **2_Chargement_donnees** via la sidebar")
with col2:
st.markdown("### 📈 Régression")
st.write("Prédisez des valeurs continues (ex: prix, température)")
if st.button("📈 Choisir Régression", key="regression"):
st.session_state.problem_type = "regression"
st.session_state.use_deep_learning = False # Pas de DL pour régression
st.success("✅ Régression sélectionnée!")
st.info("👉 Rendez-vous dans la page **2_Chargement_donnees** via la sidebar")
# Affichage du choix actuel
if st.session_state.problem_type:
st.markdown("---")
st.markdown("### 📋 Configuration actuelle")
config_col1, config_col2 = st.columns(2)
with config_col1:
st.info(f"**Type de problème**: {st.session_state.problem_type.upper()}")
# Option Deep Learning pour classification
if st.session_state.problem_type == "classification":
with config_col2:
use_dl = st.checkbox(
"🤖 Activer le Deep Learning",
value=st.session_state.use_deep_learning,
help="Utilisez des réseaux de neurones (CNN) pour les images ou données tabulaires"
)
st.session_state.use_deep_learning = use_dl
if st.session_state.use_deep_learning:
st.success("🤖 Mode Deep Learning activé - Parfait pour les images!")
st.markdown("---")
st.success("✅ Vous pouvez maintenant passer à l'étape suivante dans le menu de gauche.")
# Footer
st.markdown("---")
st.markdown("""
<div style='text-align: center; color: #666; padding: 2rem;'>
<p>🧠 <b>Teachable Machine IA</b> - Créé avec ❤️ et Streamlit</p>
<p style='font-size: 0.9rem;'>Propulsé par scikit-learn, TensorFlow et Keras</p>
</div>
""", unsafe_allow_html=True)