diff --git a/supervised_learning/config.py b/supervised_learning/config.py index 92dc335849e16c60c285bcd28a0a7fb4c6438cd5..a200dc2bde2bce5f898e5faf7f4b2494ec674625 100644 --- a/supervised_learning/config.py +++ b/supervised_learning/config.py @@ -4,7 +4,7 @@ TRAINING_IMAGE_FOLDER_PATH = "./data/train/images/" TRAINING_LABEL_FOLDER_PATH = "./data/train/labels/" VAL_IMAGE_FOLDER_PATH = "./data/val/images/" VAL_LABEL_FOLDER_PATH = "./data/val/labels/" -PREDICTION_LABEL_FOLDER_PATH = "./data/train/predicted_labels/" +PREDICTION_LABEL_FOLDER_PATH = "./data/val/predicted_labels/" CLASSIFIERS_FOLDER_PATH = "./supervised_learning/classifiers/saves/" WINDOW_SIZES = [(64, 64), (128, 128), (256, 256),(512,512)] # Window sizes during slidding window process STEP_SIZE = 16 \ No newline at end of file diff --git a/supervised_learning/create_classifiers.py b/supervised_learning/create_classifiers.py index 84de49c36f6ebc582bde868c40d36fdc8eeb0760..af1eed485b8a0208b1a352e5f9f4505a9342462e 100644 --- a/supervised_learning/create_classifiers.py +++ b/supervised_learning/create_classifiers.py @@ -105,8 +105,6 @@ for classe in CLASSES: 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 = { @@ -118,7 +116,6 @@ classifiers = { "frouge": None, "forange": None, "fvert": None, - "feux" : None, } # ------------- CREATE CLASSIFIERS ----------------- @@ -126,7 +123,7 @@ 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...") @@ -138,13 +135,6 @@ for classe in CLASSES: 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") for classes, model in classifiers.items(): diff --git a/supervised_learning/detection.py b/supervised_learning/detection.py index 443451260d7acb37380fff96d23a5d7fd4c64bd0..b068a1a27e53d61bbea9fe79dde60772e9538802 100644 --- a/supervised_learning/detection.py +++ b/supervised_learning/detection.py @@ -40,8 +40,7 @@ classifiers = { "ceder": None, "frouge": None, "forange": None, - "fvert": None, - "feux":None + "fvert": None } # Parse dict and load all classifiers @@ -79,7 +78,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) -- UNCOMMENT TO DISPLAY + #display_rois(image, rois) #-- UNCOMMENT TO DISPLAY # Write preticted labels into prediction files prediction_file_path = os.path.join(output_folder, f"{name}.csv")