Skip to content
Snippets Groups Projects
Commit da976444 authored by MathieuKoz's avatar MathieuKoz
Browse files

tentative ajouts de feux groupés

pas pu testé, le vue ne marchait plus, je sais pas pourquoi
parent 4f7fad8c
No related branches found
No related tags found
No related merge requests found
......@@ -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")
......
......@@ -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")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment