Commit
·
8888722
1
Parent(s):
2666269
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,7 +19,7 @@ modeles_disponibles = {
|
|
| 19 |
def predire(image, mouvements_selectionnes):
|
| 20 |
# Vérifier qu'au moins un mouvement est sélectionné
|
| 21 |
if not mouvements_selectionnes:
|
| 22 |
-
return "⚠️ Veuillez sélectionner au moins un mouvement pictural à analyser
|
| 23 |
|
| 24 |
# Prétraitement
|
| 25 |
image_resized = tf.image.resize(image, (224, 224)) / 255.0
|
|
@@ -37,7 +37,7 @@ def predire(image, mouvements_selectionnes):
|
|
| 37 |
|
| 38 |
# Si aucun mouvement n'atteint 50%
|
| 39 |
if not mouvements_reconnus:
|
| 40 |
-
return "❌ Aucun des mouvements picturaux sélectionnés n'a été reconnu
|
| 41 |
|
| 42 |
# Tri par probabilité décroissante
|
| 43 |
mouvements_tries = sorted(mouvements_reconnus.items(), key=lambda x: x[1], reverse=True)
|
|
@@ -81,7 +81,7 @@ def predire(image, mouvements_selectionnes):
|
|
| 81 |
|
| 82 |
fig.data[0].textfont = dict(color='black', size=14, family="Arial")
|
| 83 |
|
| 84 |
-
return fig
|
| 85 |
|
| 86 |
# === Interface Gradio ===
|
| 87 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
@@ -106,11 +106,12 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 106 |
|
| 107 |
with gr.Column(scale=1):
|
| 108 |
output_plot = gr.Plot(label="Résultats de la classification")
|
|
|
|
| 109 |
|
| 110 |
analyser_btn.click(
|
| 111 |
fn=predire,
|
| 112 |
inputs=[image_input, mouvements_checkbox],
|
| 113 |
-
outputs=output_plot
|
| 114 |
)
|
| 115 |
|
| 116 |
gr.Markdown(
|
|
|
|
| 19 |
def predire(image, mouvements_selectionnes):
|
| 20 |
# Vérifier qu'au moins un mouvement est sélectionné
|
| 21 |
if not mouvements_selectionnes:
|
| 22 |
+
return None, gr.update(value="⚠️ **Veuillez sélectionner au moins un mouvement pictural à analyser.**", visible=True)
|
| 23 |
|
| 24 |
# Prétraitement
|
| 25 |
image_resized = tf.image.resize(image, (224, 224)) / 255.0
|
|
|
|
| 37 |
|
| 38 |
# Si aucun mouvement n'atteint 50%
|
| 39 |
if not mouvements_reconnus:
|
| 40 |
+
return None, gr.update(value="❌ **Aucun des mouvements picturaux sélectionnés n'a été reconnu.**", visible=True)
|
| 41 |
|
| 42 |
# Tri par probabilité décroissante
|
| 43 |
mouvements_tries = sorted(mouvements_reconnus.items(), key=lambda x: x[1], reverse=True)
|
|
|
|
| 81 |
|
| 82 |
fig.data[0].textfont = dict(color='black', size=14, family="Arial")
|
| 83 |
|
| 84 |
+
return fig, gr.update(visible=False)
|
| 85 |
|
| 86 |
# === Interface Gradio ===
|
| 87 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
|
|
| 106 |
|
| 107 |
with gr.Column(scale=1):
|
| 108 |
output_plot = gr.Plot(label="Résultats de la classification")
|
| 109 |
+
output_message = gr.Markdown(visible=False)
|
| 110 |
|
| 111 |
analyser_btn.click(
|
| 112 |
fn=predire,
|
| 113 |
inputs=[image_input, mouvements_checkbox],
|
| 114 |
+
outputs=[output_plot, output_message]
|
| 115 |
)
|
| 116 |
|
| 117 |
gr.Markdown(
|