Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -173,7 +173,7 @@ demo = gr.Interface(
|
|
| 173 |
theme=gr.themes.Soft()
|
| 174 |
)"""
|
| 175 |
|
| 176 |
-
import plotly.graph_objects as go
|
| 177 |
|
| 178 |
def predire(image):
|
| 179 |
image_resized = tf.image.resize(image, (224, 224)) / 255.0
|
|
@@ -202,6 +202,48 @@ def predire(image):
|
|
| 202 |
height=500,
|
| 203 |
font=dict(size=16)
|
| 204 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 205 |
fig.show(config={'displayModeBar': False})
|
| 206 |
return fig
|
| 207 |
|
|
|
|
| 173 |
theme=gr.themes.Soft()
|
| 174 |
)"""
|
| 175 |
|
| 176 |
+
"""import plotly.graph_objects as go
|
| 177 |
|
| 178 |
def predire(image):
|
| 179 |
image_resized = tf.image.resize(image, (224, 224)) / 255.0
|
|
|
|
| 202 |
height=500,
|
| 203 |
font=dict(size=16)
|
| 204 |
)
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
# Pour placer le texte à l’intérieur des barres
|
| 208 |
+
fig.show(config={'displayModeBar': False})
|
| 209 |
+
return fig
|
| 210 |
+
"""
|
| 211 |
+
|
| 212 |
+
import plotly.graph_objects as go
|
| 213 |
+
|
| 214 |
+
def predire(image):
|
| 215 |
+
image_resized = tf.image.resize(image, (224, 224)) / 255.0
|
| 216 |
+
preds = model.predict(tf.expand_dims(image_resized, axis=0))[0]
|
| 217 |
+
sorted_indices = np.argsort(preds)[::-1]
|
| 218 |
+
sorted_classes = [classes[i] for i in sorted_indices]
|
| 219 |
+
sorted_probs = [preds[i] for i in sorted_indices]
|
| 220 |
+
colors = ['#2ecc71' if p >= 0.5 else '#bdc3c7' for p in sorted_probs]
|
| 221 |
+
|
| 222 |
+
fig = go.Figure(go.Bar(
|
| 223 |
+
x=sorted_classes,
|
| 224 |
+
y=sorted_probs,
|
| 225 |
+
marker=dict(color=colors, line=dict(color='black', width=1)),
|
| 226 |
+
text=[f"{p*100:.1f}%" for p in sorted_probs],
|
| 227 |
+
textposition='auto'
|
| 228 |
+
))
|
| 229 |
+
|
| 230 |
+
fig.update_layout(
|
| 231 |
+
xaxis=dict(fixedrange=True, tickangle=45, tickfont=dict(size=15), automargin=True),
|
| 232 |
+
yaxis=dict(fixedrange=True, range=[0, 1], title="Probabilité", tickfont=dict(size=14)),
|
| 233 |
+
title=dict(
|
| 234 |
+
text="Probabilités par mouvement pictural",
|
| 235 |
+
y=0.94,
|
| 236 |
+
pad=dict(b=30)
|
| 237 |
+
),
|
| 238 |
+
margin=dict(l=20, r=20, t=60, b=80), # marge top plus haute et bottom plus grande
|
| 239 |
+
height=500,
|
| 240 |
+
font=dict(size=16)
|
| 241 |
+
)
|
| 242 |
+
|
| 243 |
+
# Pour placer le texte à l’intérieur des barres
|
| 244 |
+
fig.data[0].textposition = 'inside'
|
| 245 |
+
fig.data[0].insidetextanchor = 'middle'
|
| 246 |
+
fig.data[0].textfont = dict(color='black', size=14, family="Arial")
|
| 247 |
fig.show(config={'displayModeBar': False})
|
| 248 |
return fig
|
| 249 |
|