From 21015384f0f90e5a0a1dfed1d43aa9359bfdfc30 Mon Sep 17 00:00:00 2001
From: Schneider Leo <leo.schneider@etu.ec-lyon.fr>
Date: Mon, 5 May 2025 13:10:53 +0200
Subject: [PATCH] add : print confidence matrix construction

---
 image_ref/main.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/image_ref/main.py b/image_ref/main.py
index 20a099ff..2b53852e 100644
--- a/image_ref/main.py
+++ b/image_ref/main.py
@@ -228,6 +228,7 @@ def make_prediction_duo(model, data, f_name, f_name2):
         label = label.long()
         specie = torch.argmin(label)
 
+
         if torch.cuda.is_available():
             imaer = imaer.cuda()
             imana = imana.cuda()
@@ -235,6 +236,8 @@ def make_prediction_duo(model, data, f_name, f_name2):
             label = label.cuda()
         output = model(imaer, imana, img_ref)
         confidence = soft_max(output)
+        print(label)
+        print(confidence)
         confidence_pred_list[specie].append(confidence[:, 0].data.cpu().numpy())
         # Mono class output (only most postive paire)
         output = torch.argmax(output[:, 0])
@@ -248,8 +251,10 @@ def make_prediction_duo(model, data, f_name, f_name2):
     cf_matrix = confusion_matrix(y_true, y_pred)
     confidence_matrix = np.zeros((n_class, n_class))
     for i in range(n_class):
+        print('species ',classes[i],' nb sample test : ',len(confidence_pred_list[i]))
         confidence_matrix[i] = np.mean(confidence_pred_list[i], axis=0)
 
+
     df_cm = pd.DataFrame(cf_matrix / np.sum(cf_matrix, axis=1)[:, None], index=[i for i in classes],
                          columns=[i for i in classes])
     print('Saving Confusion Matrix')
@@ -267,6 +272,8 @@ def make_prediction_duo(model, data, f_name, f_name2):
     plt.savefig(f_name2)
 
 
+
+
 def save_model(model, path):
     print('Model saved')
     torch.save(model.state_dict(), path)
-- 
GitLab