From da9764445f3eeef920fa6caccc2b240a95f85ed9 Mon Sep 17 00:00:00 2001
From: MathieuKoz <127348750+MathieuKoz@users.noreply.github.com>
Date: Thu, 20 Jun 2024 00:37:02 +0200
Subject: [PATCH] =?UTF-8?q?tentative=20ajouts=20de=20feux=20group=C3=A9s?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

pas pu testé, le vue ne marchait plus, je sais pas pourquoi
---
 supervised_learning/create_classifiers.py | 31 ++++++++++++++++++++---
 supervised_learning/detection.py          |  6 +++--
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/supervised_learning/create_classifiers.py b/supervised_learning/create_classifiers.py
index c4937ad..84de49c 100644
--- a/supervised_learning/create_classifiers.py
+++ b/supervised_learning/create_classifiers.py
@@ -79,7 +79,20 @@ datasets = {
         "fvert": {
             "X" : [],
             "Y": []
-        }, 
+        },
+         
+    },
+    "feux_train": {
+         "feux": {
+              "X":[],
+              "Y":[]
+         },
+    },
+    "feux_val": {
+         "feux": {
+              "X":[],
+              "Y":[]
+         },
     }   
 }
 
@@ -91,6 +104,9 @@ for classe in CLASSES:
     if classe not in ['ff', 'empty']:
         datasets["train"][classe]["X"], datasets["train"][classe]["Y"] = create_binary_classification_dataset(datas_train, classe)
         datasets["val"][classe]["X"], datasets["val"][classe]["Y"] = create_binary_classification_dataset(datas_val, classe)
+        
+        datasets["feux_train"]["feux"]["X"], datasets["feux_train"]["feux"]["Y"] = create_binary_classification_dataset_feux(datas_train)
+        datasets["feux_val"]["feux"]["X"], datasets["feux_val"]["feux"]["Y"] = create_binary_classification_dataset_feux(datas_val)
 
 # Dict format to store all classifiers
 classifiers = {
@@ -101,7 +117,8 @@ classifiers = {
     "ceder": None, 
     "frouge": None, 
     "forange": None, 
-    "fvert": None
+    "fvert": None,
+    "feux" : None,
 }
 
 # ------------- CREATE CLASSIFIERS -----------------
@@ -109,18 +126,24 @@ print("Creating classifiers...")
 for classe in CLASSES:
     if classe not in ['ff', 'empty']:
         classifiers[classe] = svm.SVC(kernel='poly', probability=True)
-
+classifiers['feux'] = svm.SVC(kernel='poly', probability=True)
 
 # ------------- TRAIN & TEST CLASSIFIERS -----------------
 print("Train and testing all classifiers...")
 for classe in CLASSES:
-    if classe not in ['ff', 'empty']:
+    if classe not in ['ff', 'empty','feux']:
         X_train, y_train = datasets['train'][classe]["X"], datasets['train'][classe]["Y"]
         X_val, y_val = datasets['val'][classe]["X"], datasets['val'][classe]["Y"]
         classifiers[classe].fit(X_train, y_train)
         y_pred = classifiers[classe].predict(X_val)
         print(f"Précision pour panneaux {classe}: {np.mean(y_pred == y_val)}")
 
+X_train, y_train =  datasets["feux_train"]["feux"]["X"], datasets["feux_train"]["feux"]["Y"]
+X_val, y_val = datasets["feux_val"]["feux"]["X"], datasets["feux_val"]["feux"]["Y"]
+classifiers['feux'].fit(X_train, y_train)
+y_feu = classifiers['feux'].predict(X_val)
+print(f"Précision pour panneaux feux: {np.mean(y_feu == y_val)}")
+
 
 # ------------- SAVE CLASSIFIERS -----------------
 print("Saving classifiers")
diff --git a/supervised_learning/detection.py b/supervised_learning/detection.py
index 91e0a45..4434512 100644
--- a/supervised_learning/detection.py
+++ b/supervised_learning/detection.py
@@ -13,6 +13,7 @@ parser.add_argument('output_folder', metavar='DIR', help='Folder of output label
 # Analyser les arguments de la ligne de commande
 args = parser.parse_args()
 
+
 # Load input folder
 input_folder = args.input_folder
 # Check if input folder exists
@@ -39,7 +40,8 @@ classifiers = {
     "ceder": None, 
     "frouge": None, 
     "forange": None, 
-    "fvert": None
+    "fvert": None,
+    "feux":None
 }
 
 # Parse dict and load all classifiers
@@ -77,7 +79,7 @@ for filepath, image in X.items():
 
     # Filter rois with Non Maximum Suppression process
     rois = non_max_suppression(rois, iou_threshold=0.1)     
-    #display_rois(image, rois)
+    #display_rois(image, rois)  -- UNCOMMENT TO DISPLAY
 
     # Write preticted labels into prediction files
     prediction_file_path = os.path.join(output_folder, f"{name}.csv")
-- 
GitLab