Update app.py
Browse files
app.py
CHANGED
@@ -529,7 +529,7 @@ def quick_predict_ui(image_pil):
|
|
529 |
<div>
|
530 |
<span style="font-size:16px;font-weight:bold;">Diagnostic Global</span><br>
|
531 |
<div class="highlight malin">
|
532 |
-
{global_diag} : {ensemble_probs[top_class_idx]*100:.2f}%
|
533 |
</div>
|
534 |
</div>
|
535 |
</div>
|
@@ -538,12 +538,11 @@ def quick_predict_ui(image_pil):
|
|
538 |
img_src = "non-mel.webp" if global_diag == "Bénin" else "mel.webp"
|
539 |
global_diag_html = f'''
|
540 |
<div class="diagnostic-global clearfix">
|
541 |
-
<img src="https://huggingface.co/spaces/ericjedha/skin_care/resolve/main/{img_src}" width="
|
542 |
<div>
|
543 |
<span style="font-size:16px;font-weight:bold;">Diagnostic Global</span><br>
|
544 |
<div class="highlight benin">
|
545 |
-
{global_diag} : {ensemble_probs[top_class_idx]*100:.2f}%
|
546 |
-
➜ {top_class_name.upper()}
|
547 |
</div>
|
548 |
</div>
|
549 |
</div>
|
@@ -564,24 +563,23 @@ def quick_predict_ui(image_pil):
|
|
564 |
'''
|
565 |
warning_visible = True
|
566 |
|
567 |
-
# Génération du graphique
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
fig.update_layout(xaxis_title="", yaxis_title="Probabilité (%)", height=400)
|
579 |
|
580 |
return (
|
581 |
global_diag_html,
|
582 |
output_text_html,
|
583 |
-
gr.update(value=warning_html, visible=warning_visible),
|
584 |
-
|
585 |
"✅ Analyse terminée."
|
586 |
)
|
587 |
|
@@ -597,7 +595,7 @@ def quick_predict_ui(image_pil):
|
|
597 |
None,
|
598 |
f"❌ Erreur: {str(e)}"
|
599 |
)
|
600 |
-
|
601 |
def generate_gradcam_ui(progress=gr.Progress()):
|
602 |
global current_image, current_predictions
|
603 |
if current_image is None or current_predictions is None:
|
|
|
529 |
<div>
|
530 |
<span style="font-size:16px;font-weight:bold;">Diagnostic Global</span><br>
|
531 |
<div class="highlight malin">
|
532 |
+
{global_diag} : {ensemble_probs[top_class_idx]*100:.2f}% ▪ {top_class_name.upper()}
|
533 |
</div>
|
534 |
</div>
|
535 |
</div>
|
|
|
538 |
img_src = "non-mel.webp" if global_diag == "Bénin" else "mel.webp"
|
539 |
global_diag_html = f'''
|
540 |
<div class="diagnostic-global clearfix">
|
541 |
+
<img src="https://huggingface.co/spaces/ericjedha/skin_care/resolve/main/{img_src}" width="80" style="float:left;margin-right:10px;">
|
542 |
<div>
|
543 |
<span style="font-size:16px;font-weight:bold;">Diagnostic Global</span><br>
|
544 |
<div class="highlight benin">
|
545 |
+
{global_diag} : {ensemble_probs[top_class_idx]*100:.2f}% ▪ {top_class_name.upper()}
|
|
|
546 |
</div>
|
547 |
</div>
|
548 |
</div>
|
|
|
563 |
'''
|
564 |
warning_visible = True
|
565 |
|
566 |
+
# Génération du graphique avec gr.BarPlot
|
567 |
+
probabilities = {CLASS_NAMES[i]: ensemble_probs[i] * 100 for i in range(len(CLASS_NAMES))}
|
568 |
+
bar_plot = gr.BarPlot(
|
569 |
+
x=CLASS_NAMES,
|
570 |
+
y=[probabilities[cls] for cls in CLASS_NAMES],
|
571 |
+
title="Probabilités par classe",
|
572 |
+
y_title="Probabilité (%)",
|
573 |
+
y_lim=[0, 100], # Limite y pour inclure toutes les valeurs jusqu'à 100%
|
574 |
+
height=450, # Hauteur suffisante pour éviter le rognage
|
575 |
+
y_title_format="{value:.1f}%", # Afficher les pourcentages avec une décimale
|
576 |
+
)
|
|
|
577 |
|
578 |
return (
|
579 |
global_diag_html,
|
580 |
output_text_html,
|
581 |
+
gr.update(value=warning_html, visible=warning_visible),
|
582 |
+
bar_plot,
|
583 |
"✅ Analyse terminée."
|
584 |
)
|
585 |
|
|
|
595 |
None,
|
596 |
f"❌ Erreur: {str(e)}"
|
597 |
)
|
598 |
+
|
599 |
def generate_gradcam_ui(progress=gr.Progress()):
|
600 |
global current_image, current_predictions
|
601 |
if current_image is None or current_predictions is None:
|