CARIA.2.1
Update for the final presentation huge change with previous version
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Thumbs.db
|
||||||
|
.DS_Store
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
import cv2
|
|
||||||
import glob
|
|
||||||
import numpy as np
|
|
||||||
import json
|
|
||||||
import requests
|
|
||||||
|
|
||||||
# Charger le modèle TensorFlow
|
|
||||||
import tensorflow as tf
|
|
||||||
model = tf.keras.models.load_model('server-ia/data/modeles/traffic_signs_model/')
|
|
||||||
|
|
||||||
# Chemin vers les images de test
|
|
||||||
# path = 'server-ia/data/videos/autoroute.mp4'
|
|
||||||
path = 'server-ia/data/images/panneaux/France_road_sign_B14_(5).svg.png'
|
|
||||||
|
|
||||||
images = glob.glob(path)
|
|
||||||
|
|
||||||
# Initialiser les listes pour les données et les étiquettes
|
|
||||||
data = []
|
|
||||||
|
|
||||||
# Récupérer les images et leurs étiquettes
|
|
||||||
for im in images[:5]: # Charger seulement les 5 premières images pour l'exemple
|
|
||||||
try:
|
|
||||||
# Lire l'image et redimensionner
|
|
||||||
image = cv2.imread(im)
|
|
||||||
image = cv2.resize(image, (30, 30))
|
|
||||||
|
|
||||||
# Ajouter l'image à la liste des données
|
|
||||||
data.append(image)
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Erreur lors du chargement de l'image {im}: {e}")
|
|
||||||
|
|
||||||
# Convertir la liste des données en un tableau numpy
|
|
||||||
test_imgs = np.array(data)
|
|
||||||
|
|
||||||
# Effectuer les prédictions sur les images
|
|
||||||
predictions = model.predict(test_imgs)
|
|
||||||
|
|
||||||
# Afficher les prédictions
|
|
||||||
print(predictions)
|
|
||||||
|
|
||||||
#dictionary to label all traffic signs class.
|
|
||||||
classes = { 0:'Speed limit (20km/h)',
|
|
||||||
1:'Speed limit (30km/h)',
|
|
||||||
2:'Speed limit (50km/h)',
|
|
||||||
3:'Speed limit (60km/h)',
|
|
||||||
4:'Speed limit (70km/h)',
|
|
||||||
5:'Speed limit (80km/h)',
|
|
||||||
6:'End of speed limit (80km/h)',
|
|
||||||
7:'Speed limit (100km/h)',
|
|
||||||
8:'Speed limit (120km/h)',
|
|
||||||
9:'No passing',
|
|
||||||
10:'No passing veh over 3.5 tons',
|
|
||||||
11:'Right-of-way at intersection',
|
|
||||||
12:'Priority road',
|
|
||||||
13:'Yield',
|
|
||||||
14:'Stop',
|
|
||||||
15:'No vehicles',
|
|
||||||
16:'Veh > 3.5 tons prohibited',
|
|
||||||
17:'No entry',
|
|
||||||
18:'General caution',
|
|
||||||
19:'Dangerous curve left',
|
|
||||||
20:'Dangerous curve right',
|
|
||||||
21:'Double curve',
|
|
||||||
22:'Bumpy road',
|
|
||||||
23:'Slippery road',
|
|
||||||
24:'Road narrows on the right',
|
|
||||||
25:'Road work',
|
|
||||||
26:'Traffic signals',
|
|
||||||
27:'Pedestrians',
|
|
||||||
28:'Children crossing',
|
|
||||||
29:'Bicycles crossing',
|
|
||||||
30:'Beware of ice/snow',
|
|
||||||
31:'Wild animals crossing',
|
|
||||||
32:'End speed + passing limits',
|
|
||||||
33:'Turn right ahead',
|
|
||||||
34:'Turn left ahead',
|
|
||||||
35:'Ahead only',
|
|
||||||
36:'Go straight or right',
|
|
||||||
37:'Go straight or left',
|
|
||||||
38:'Keep right',
|
|
||||||
39:'Keep left',
|
|
||||||
40:'Roundabout mandatory',
|
|
||||||
41:'End of no passing',
|
|
||||||
42:'End no passing veh > 3.5 tons' }
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
import cv2
|
|
||||||
import numpy as np
|
|
||||||
import tensorflow as tf
|
|
||||||
|
|
||||||
# Chemin vers le dossier contenant le modèle SavedModel
|
|
||||||
model_dir = "server-ia/data/modeles/traffic_signs_model/1"
|
|
||||||
|
|
||||||
# Chargement du modèle SavedModel
|
|
||||||
model = tf.keras.models.load_model(model_dir)
|
|
||||||
|
|
||||||
# Fonction de prétraitement de l'image
|
|
||||||
def preprocess_image(image):
|
|
||||||
# Redimensionner l'image à la taille attendue par le modèle
|
|
||||||
processed_image = cv2.resize(image, (30, 30))
|
|
||||||
# Assurez-vous que l'image est dans le format attendu par le modèle
|
|
||||||
processed_image = processed_image.astype("float32") / 255.0 # Normalisation
|
|
||||||
processed_image = np.expand_dims(processed_image, axis=0) # Ajouter une dimension pour l'axe du lot
|
|
||||||
return processed_image
|
|
||||||
|
|
||||||
# Fonction de détection des panneaux
|
|
||||||
def detect_signs(video_path):
|
|
||||||
cap = cv2.VideoCapture(video_path)
|
|
||||||
while cap.isOpened():
|
|
||||||
ret, frame = cap.read()
|
|
||||||
if not ret:
|
|
||||||
break
|
|
||||||
|
|
||||||
# Prétraitement de l'image
|
|
||||||
processed_frame = preprocess_image(frame)
|
|
||||||
|
|
||||||
# Faire une prédiction avec le modèle
|
|
||||||
predictions = model.predict(processed_frame)
|
|
||||||
|
|
||||||
# Analyser les prédictions et afficher les résultats sur l'image
|
|
||||||
# Remplacez cette partie par votre code de détection et d'affichage des panneaux
|
|
||||||
|
|
||||||
# Affichage de la vidéo avec les détections
|
|
||||||
cv2.imshow('Video', frame)
|
|
||||||
if cv2.waitKey(1) & 0xFF == ord('q'):
|
|
||||||
break
|
|
||||||
|
|
||||||
cap.release()
|
|
||||||
cv2.destroyAllWindows()
|
|
||||||
|
|
||||||
# Appel de la fonction pour détecter les panneaux dans la vidéo
|
|
||||||
video_path = "server-ia/data/videos/autoroute.mp4"
|
|
||||||
detect_signs(video_path)
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
import cv2
|
|
||||||
import pickle
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
min_size=50
|
|
||||||
|
|
||||||
face_cascade= cv2.CascadeClassifier("server-ia/data/haarcascades/haarcascade_frontalface_alt2.xml")
|
|
||||||
recognizer=cv2.face.LBPHFaceRecognizer_create()
|
|
||||||
recognizer.read("server-ia/data/modeles/camera_identification_user/trainner.yml")
|
|
||||||
id_image=0
|
|
||||||
color_info=(255, 255, 255)
|
|
||||||
color_ko=(0, 0, 255)
|
|
||||||
color_ok=(0, 255, 0)
|
|
||||||
url = "http://192.168.52.194:8081"
|
|
||||||
|
|
||||||
with open("server-ia/data/modeles/camera_identification_user/labels.pickle", "rb") as f:
|
|
||||||
og_labels=pickle.load(f)
|
|
||||||
labels={v:k for k, v in og_labels.items()}
|
|
||||||
|
|
||||||
cap=cv2.VideoCapture(0)
|
|
||||||
while True:
|
|
||||||
ret, frame=cap.read()
|
|
||||||
tickmark=cv2.getTickCount()
|
|
||||||
gray=cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
|
||||||
faces=face_cascade.detectMultiScale(gray, scaleFactor=1.2,minNeighbors=4, minSize=(min_size, min_size))
|
|
||||||
for (x, y, w, h) in faces:
|
|
||||||
roi_gray=gray[y:y+h, x:x+w]
|
|
||||||
#id_, conf=recognizer.predict(cv2.resize(roi_gray, (min_size, min_size)))
|
|
||||||
id_, conf=recognizer.predict(roi_gray)
|
|
||||||
if conf<=95:
|
|
||||||
color=color_ok
|
|
||||||
name=labels[id_]
|
|
||||||
else:
|
|
||||||
color=color_ko
|
|
||||||
name="Inconnu"
|
|
||||||
label=name+" "+'{:5.2f}'.format(conf)
|
|
||||||
cv2.putText(frame, label, (x, y-10), cv2.FONT_HERSHEY_DUPLEX, 1, color_info, 1, cv2.LINE_AA)
|
|
||||||
cv2.rectangle(frame, (x, y), (x+w, y+h), color, 2)
|
|
||||||
fps=cv2.getTickFrequency()/(cv2.getTickCount()-tickmark)
|
|
||||||
cv2.putText(frame, "FPS: {:05.2f}".format(fps), (10, 30), cv2.FONT_HERSHEY_PLAIN, 2, color_info, 2)
|
|
||||||
cv2.imshow('L42Project', frame)
|
|
||||||
key=cv2.waitKey(1)&0xFF
|
|
||||||
if key==ord('q'):
|
|
||||||
break
|
|
||||||
if key==ord('a'):
|
|
||||||
for cpt in range(100):
|
|
||||||
ret, frame=cap.read()
|
|
||||||
|
|
||||||
cv2.destroyAllWindows()
|
|
||||||
print("Fin")
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
import tensorflow as tf
|
|
||||||
from tensorflow.keras import layers, models
|
|
||||||
import os
|
|
||||||
import cv2
|
|
||||||
|
|
||||||
size=42
|
|
||||||
dir_images_panneaux="server-ia/Camera_Identification_VitesseRoadSign/images_panneaux"
|
|
||||||
dir_images_autres_panneaux="server-ia/Camera_Identification_VitesseRoadSign/images_autres_panneaux"
|
|
||||||
dir_images_sans_panneaux="server-ia/Camera_Identification_VitesseRoadSign/images_sans_panneaux"
|
|
||||||
|
|
||||||
def panneau_model(nbr_classes):
|
|
||||||
model=tf.keras.Sequential()
|
|
||||||
|
|
||||||
model.add(layers.Input(shape=(size, size, 3), dtype='float32'))
|
|
||||||
|
|
||||||
model.add(layers.Conv2D(128, 3, strides=1))
|
|
||||||
model.add(layers.Dropout(0.2))
|
|
||||||
model.add(layers.BatchNormalization())
|
|
||||||
model.add(layers.Activation('relu'))
|
|
||||||
|
|
||||||
model.add(layers.Conv2D(128, 3, strides=1))
|
|
||||||
model.add(layers.Dropout(0.2))
|
|
||||||
model.add(layers.BatchNormalization())
|
|
||||||
model.add(layers.Activation('relu'))
|
|
||||||
|
|
||||||
model.add(layers.MaxPool2D(pool_size=2, strides=2))
|
|
||||||
|
|
||||||
model.add(layers.Conv2D(256, 3, strides=1))
|
|
||||||
model.add(layers.Dropout(0.3))
|
|
||||||
model.add(layers.BatchNormalization())
|
|
||||||
model.add(layers.Activation('relu'))
|
|
||||||
|
|
||||||
model.add(layers.Conv2D(256, 3, strides=1))
|
|
||||||
model.add(layers.Dropout(0.4))
|
|
||||||
model.add(layers.BatchNormalization())
|
|
||||||
model.add(layers.Activation('relu'))
|
|
||||||
|
|
||||||
model.add(layers.MaxPool2D(pool_size=2, strides=2))
|
|
||||||
|
|
||||||
model.add(layers.Flatten())
|
|
||||||
model.add(layers.Dense(512, activation='relu'))
|
|
||||||
model.add(layers.Dropout(0.5))
|
|
||||||
model.add(layers.BatchNormalization())
|
|
||||||
model.add(layers.Dense(nbr_classes, activation='sigmoid'))
|
|
||||||
|
|
||||||
return model
|
|
||||||
|
|
||||||
def lire_images_panneaux(dir_images_panneaux, size=None):
|
|
||||||
tab_panneau=[]
|
|
||||||
tab_image_panneau=[]
|
|
||||||
|
|
||||||
if not os.path.exists(dir_images_panneaux):
|
|
||||||
quit("Le repertoire d'image n'existe pas: {}".format(dir_images_panneaux))
|
|
||||||
|
|
||||||
files=os.listdir(dir_images_panneaux)
|
|
||||||
if files is None:
|
|
||||||
quit("Le repertoire d'image est vide: {}".format(dir_images_panneaux))
|
|
||||||
|
|
||||||
for file in sorted(files):
|
|
||||||
if file.endswith("png"):
|
|
||||||
tab_panneau.append(file.split(".")[0])
|
|
||||||
image=cv2.imread(dir_images_panneaux+"/"+file)
|
|
||||||
if size is not None:
|
|
||||||
image=cv2.resize(image, (size, size), cv2.INTER_LANCZOS4)
|
|
||||||
tab_image_panneau.append(image)
|
|
||||||
|
|
||||||
return tab_panneau, tab_image_panneau
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
import cv2
|
|
||||||
import os
|
|
||||||
import numpy as np
|
|
||||||
import random
|
|
||||||
# Tuto25[OpenCV] Lecture des panneaux de vitesse p.1 (houghcircles) 16min
|
|
||||||
|
|
||||||
size=42
|
|
||||||
video_dir = "server-ia/data/videos"
|
|
||||||
|
|
||||||
# Liste tous les fichiers dans le répertoire vidéo
|
|
||||||
l = os.listdir(video_dir)
|
|
||||||
|
|
||||||
for video in l:
|
|
||||||
if not video.endswith("mp4"):
|
|
||||||
continue
|
|
||||||
cap = cv2.VideoCapture(video_dir + "/" + video)
|
|
||||||
|
|
||||||
print("video:", video)
|
|
||||||
while True:
|
|
||||||
# Capture une frame de la vidéo
|
|
||||||
ret, frame = cap.read()
|
|
||||||
if ret is False:
|
|
||||||
break
|
|
||||||
|
|
||||||
# Redimensionne la frame pour un affichage correct
|
|
||||||
f_w, f_h, f_c = frame.shape
|
|
||||||
frame = cv2.resize(frame, (int(f_h / 1.5), int(f_w / 1.5)))
|
|
||||||
|
|
||||||
# Extrait une région d'intérêt (ROI) de la frame
|
|
||||||
image = frame[200:400, 700:1000]
|
|
||||||
|
|
||||||
# represents the top left corner of rectangle
|
|
||||||
start_point = (600, 50)
|
|
||||||
# Ending coordinate
|
|
||||||
# represents t
|
|
||||||
# he bottom right corner of rectangle
|
|
||||||
end_point = (800, 450)
|
|
||||||
# Color in BGR
|
|
||||||
color = (255, 255, 255)
|
|
||||||
# Line thickness
|
|
||||||
thickness = 1
|
|
||||||
|
|
||||||
# Dessine un rectangle autour de la ROI (dimensions spécifiées)
|
|
||||||
cv2.rectangle(frame, start_point, end_point, color, thickness)
|
|
||||||
|
|
||||||
# Convertit l'image en niveaux de gris pour la détection des cercles
|
|
||||||
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
|
||||||
|
|
||||||
# Détection des cercles dans l'image
|
|
||||||
circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1, 20, param1=30, param2=60, minRadius=5, maxRadius=45)
|
|
||||||
if circles is not None:
|
|
||||||
circles = np.int16(np.around(circles))
|
|
||||||
for i in circles[0, :]:
|
|
||||||
if i[2] != 0:
|
|
||||||
cv2.circle(frame, (i[0], i[1]), i[2], (0, 255, 0), 4)
|
|
||||||
# Extrait le panneau de signalisation à partir de la position et du rayon du cercle
|
|
||||||
panneau = cv2.resize(
|
|
||||||
image[max(0, i[1] - i[2]):i[1] + i[2], max(0, i[0] - i[2]):i[0] + i[2]],
|
|
||||||
(size, size)) / 255
|
|
||||||
cv2.imshow("panneau", panneau)
|
|
||||||
|
|
||||||
# Affiche le nom du fichier vidéo en cours
|
|
||||||
cv2.putText(frame, "fichier:" + video, (30, 30), cv2.FONT_HERSHEY_DUPLEX, 1, (0, 255, 0), 1, cv2.LINE_AA)
|
|
||||||
|
|
||||||
# Affiche la frame avec le rectangle et le panneau détecté
|
|
||||||
cv2.imshow("Video", frame)
|
|
||||||
|
|
||||||
# Attend l'appui d'une touche et traite les actions associées
|
|
||||||
key = cv2.waitKey(1) & 0xFF
|
|
||||||
if key == ord('q'):
|
|
||||||
quit()
|
|
||||||
if key == ord('a'):
|
|
||||||
for cpt in range(100):
|
|
||||||
ret, frame = cap.read()
|
|
||||||
if key == ord('f'):
|
|
||||||
break
|
|
||||||
|
|
||||||
# Ferme toutes les fenêtres OpenCV
|
|
||||||
cv2.destroyAllWindows()
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
import cv2
|
|
||||||
import numpy as np
|
|
||||||
# Tuto25[OpenCV] Lecture des panneaux de vitesse p.1 (houghcircles) 14min
|
|
||||||
param1=30
|
|
||||||
param2=55
|
|
||||||
dp=1.0
|
|
||||||
video_path = "server-ia/data/videos/ville.mp4"
|
|
||||||
|
|
||||||
cap=cv2.VideoCapture(video_path)
|
|
||||||
|
|
||||||
while True:
|
|
||||||
ret, frame=cap.read()
|
|
||||||
gray=cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
|
||||||
circles=cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, dp, 20, param1=param1, param2=param2, minRadius=10, maxRadius=50)
|
|
||||||
if circles is not None:
|
|
||||||
circles=np.around(circles).astype(np.int32)
|
|
||||||
for i in circles[0, :]:
|
|
||||||
if i[2]!=0:
|
|
||||||
cv2.circle(frame, (i[0], i[1]), i[2], (0, 255, 0), 4)
|
|
||||||
cv2.putText(frame, "[i|k]dp: {:4.2f} [o|l]param1: {:d} [p|m]param2: {:d}".format(dp, param1, param2), (10, 40), cv2.FONT_HERSHEY_COMPLEX_SMALL, 1, (255, 0, 0), 1)
|
|
||||||
cv2.imshow("Video", frame)
|
|
||||||
key=cv2.waitKey(1)&0xFF
|
|
||||||
if key==ord('q'):
|
|
||||||
quit()
|
|
||||||
if key==ord('i'):
|
|
||||||
dp=min(10, dp+0.1)
|
|
||||||
if key==ord('k'):
|
|
||||||
dp=max(0.1, dp-0.1)
|
|
||||||
if key==ord('o'):
|
|
||||||
param1=min(255, param1+1)
|
|
||||||
if key==ord('l'):
|
|
||||||
param1=max(1, param1-1)
|
|
||||||
if key==ord('p'):
|
|
||||||
param2=min(255, param2+1)
|
|
||||||
if key==ord('m'):
|
|
||||||
param2=max(1, param2-1)
|
|
||||||
cv2.destroyAllWindows()
|
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
import tensorflow as tf
|
|
||||||
from tensorflow.keras import layers, models
|
|
||||||
import cv2
|
|
||||||
import os
|
|
||||||
import numpy as np
|
|
||||||
import random
|
|
||||||
|
|
||||||
th1=30
|
|
||||||
th2=55
|
|
||||||
size=42
|
|
||||||
video_dir="server-ia/data/videos/"
|
|
||||||
dir_images_panneaux="server-ia/data/images/panneaux"
|
|
||||||
|
|
||||||
def panneau_model(nbr_classes):
|
|
||||||
model=tf.keras.Sequential()
|
|
||||||
|
|
||||||
model.add(layers.Input(shape=(size, size, 3), dtype='float32'))
|
|
||||||
|
|
||||||
model.add(layers.Conv2D(128, 3, strides=1))
|
|
||||||
model.add(layers.Dropout(0.2))
|
|
||||||
model.add(layers.BatchNormalization())
|
|
||||||
model.add(layers.Activation('relu'))
|
|
||||||
|
|
||||||
model.add(layers.Conv2D(128, 3, strides=1))
|
|
||||||
model.add(layers.Dropout(0.2))
|
|
||||||
model.add(layers.BatchNormalization())
|
|
||||||
model.add(layers.Activation('relu'))
|
|
||||||
|
|
||||||
model.add(layers.MaxPool2D(pool_size=2, strides=2))
|
|
||||||
|
|
||||||
model.add(layers.Conv2D(256, 3, strides=1))
|
|
||||||
model.add(layers.Dropout(0.3))
|
|
||||||
model.add(layers.BatchNormalization())
|
|
||||||
model.add(layers.Activation('relu'))
|
|
||||||
|
|
||||||
model.add(layers.Conv2D(256, 3, strides=1))
|
|
||||||
model.add(layers.Dropout(0.4))
|
|
||||||
model.add(layers.BatchNormalization())
|
|
||||||
model.add(layers.Activation('relu'))
|
|
||||||
|
|
||||||
model.add(layers.MaxPool2D(pool_size=2, strides=2))
|
|
||||||
|
|
||||||
model.add(layers.Flatten())
|
|
||||||
model.add(layers.Dense(512, activation='relu'))
|
|
||||||
model.add(layers.Dropout(0.5))
|
|
||||||
model.add(layers.BatchNormalization())
|
|
||||||
model.add(layers.Dense(nbr_classes, activation='sigmoid'))
|
|
||||||
|
|
||||||
return model
|
|
||||||
|
|
||||||
def lire_images_panneaux(dir_images_panneaux, size=None):
|
|
||||||
tab_panneau=[]
|
|
||||||
tab_image_panneau=[]
|
|
||||||
|
|
||||||
if not os.path.exists(dir_images_panneaux):
|
|
||||||
quit("Le repertoire d'image n'existe pas: {}".format(dir_images_panneaux))
|
|
||||||
|
|
||||||
files=os.listdir(dir_images_panneaux)
|
|
||||||
if files is None:
|
|
||||||
quit("Le repertoire d'image est vide: {}".format(dir_images_panneaux))
|
|
||||||
|
|
||||||
for file in sorted(files):
|
|
||||||
if file.endswith("png"):
|
|
||||||
tab_panneau.append(file.split(".")[0])
|
|
||||||
image=cv2.imread(dir_images_panneaux+"/"+file)
|
|
||||||
if size is not None:
|
|
||||||
image=cv2.resize(image, (size, size), cv2.INTER_LANCZOS4)
|
|
||||||
tab_image_panneau.append(image)
|
|
||||||
|
|
||||||
return tab_panneau, tab_image_panneau
|
|
||||||
|
|
||||||
tab_panneau, tab_image_panneau=lire_images_panneaux(dir_images_panneaux)
|
|
||||||
|
|
||||||
model_panneau=panneau_model(len(tab_panneau))
|
|
||||||
checkpoint=tf.train.Checkpoint(model_panneau=model_panneau)
|
|
||||||
checkpoint.restore(tf.train.latest_checkpoint("server-ia\data\modeles\road_sign_speed_trainers/"))
|
|
||||||
|
|
||||||
l=os.listdir(video_dir)
|
|
||||||
random.shuffle(l)
|
|
||||||
|
|
||||||
for video in l:
|
|
||||||
if not video.endswith("mp4"):
|
|
||||||
continue
|
|
||||||
cap=cv2.VideoCapture(video_dir+"/"+video)
|
|
||||||
|
|
||||||
print("video:", video)
|
|
||||||
id_panneau=-1
|
|
||||||
while True:
|
|
||||||
ret, frame=cap.read()
|
|
||||||
if ret is False:
|
|
||||||
break
|
|
||||||
f_w, f_h, f_c=frame.shape
|
|
||||||
frame=cv2.resize(frame, (int(f_h/1.5), int(f_w/1.5)))
|
|
||||||
|
|
||||||
image=frame[200:400, 700:1000]
|
|
||||||
|
|
||||||
# represents the top left corner of rectangle
|
|
||||||
start_point = (600, 50)
|
|
||||||
# Ending coordinate
|
|
||||||
# represents t
|
|
||||||
# he bottom right corner of rectangle
|
|
||||||
end_point = (800, 450)
|
|
||||||
# Color in BGR
|
|
||||||
color = (255, 255, 255)
|
|
||||||
# Line thickness
|
|
||||||
thickness = 1
|
|
||||||
|
|
||||||
cv2.rectangle(frame, start_point, end_point, color, thickness)
|
|
||||||
|
|
||||||
gray=cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
|
||||||
|
|
||||||
circles=cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1, 20, param1=th1, param2=th2, minRadius=5, maxRadius=45)
|
|
||||||
if circles is not None:
|
|
||||||
circles=np.int16(np.around(circles))
|
|
||||||
for i in circles[0,:]:
|
|
||||||
if i[2]!=0:
|
|
||||||
panneau=cv2.resize(image[max(0, i[1]-i[2]):i[1]+i[2], max(0, i[0]-i[2]):i[0]+i[2]], (size, size))/255
|
|
||||||
cv2.imshow("panneau", panneau)
|
|
||||||
prediction=model_panneau(np.array([panneau]), training=False)
|
|
||||||
print("Prediction:", prediction)
|
|
||||||
if np.any(np.greater(prediction[0], 0.6)):
|
|
||||||
id_panneau=np.argmax(prediction[0])
|
|
||||||
print(" -> C'est un panneau:", tab_panneau[id_panneau], "KM/H")
|
|
||||||
w, h, c=tab_image_panneau[id_panneau].shape
|
|
||||||
else:
|
|
||||||
print(" -> Ce n'est pas un panneau")
|
|
||||||
if id_panneau!=-1:
|
|
||||||
frame[0:h, 0:w, :]=tab_image_panneau[id_panneau]
|
|
||||||
cv2.putText(frame, "fichier:"+video, (30, 30), cv2.FONT_HERSHEY_DUPLEX, 1, (0, 255, 0), 1, cv2.LINE_AA)
|
|
||||||
cv2.imshow("Video", frame)
|
|
||||||
key=cv2.waitKey(1)&0xFF
|
|
||||||
if key==ord('q'):
|
|
||||||
quit()
|
|
||||||
if key==ord('a'):
|
|
||||||
for cpt in range(100):
|
|
||||||
ret, frame=cap.read()
|
|
||||||
if key==ord('f'):
|
|
||||||
break
|
|
||||||
|
|
||||||
cv2.destroyAllWindows()
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
import cv2
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
th1=75
|
|
||||||
th2=150
|
|
||||||
stop=0
|
|
||||||
k=3
|
|
||||||
cap=cv2.VideoCapture(0)
|
|
||||||
while True:
|
|
||||||
if not stop:
|
|
||||||
ret, frame=cap.read()
|
|
||||||
if ret is False:
|
|
||||||
quit()
|
|
||||||
image=frame.copy()
|
|
||||||
|
|
||||||
cv2.putText(image, "[u|j]th1: {:d} [i|k]th2: {:d} [y|h]blur: {:d}".format(th1, th2, k), (10, 40), cv2.FONT_HERSHEY_COMPLEX_SMALL, 1, (0, 255, 255), 1)
|
|
||||||
cv2.putText(image, "[a]>> [s]stop [q]quit", (10, 70), cv2.FONT_HERSHEY_COMPLEX_SMALL, 1, (0, 255, 255), 1)
|
|
||||||
cv2.imshow("image", image)
|
|
||||||
gray=cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
|
||||||
if k!=1:
|
|
||||||
gray=cv2.blur(gray, (k, k))
|
|
||||||
gray_canny=cv2.Canny(gray, th1, th2)
|
|
||||||
cv2.imshow("blur", gray)
|
|
||||||
cv2.imshow("canny", gray_canny)
|
|
||||||
|
|
||||||
if not stop:
|
|
||||||
key=cv2.waitKey(10)&0xFF
|
|
||||||
else:
|
|
||||||
key=cv2.waitKey()
|
|
||||||
image=frame.copy()
|
|
||||||
|
|
||||||
if key==ord('q'):
|
|
||||||
break
|
|
||||||
if key==ord('y'):
|
|
||||||
k=min(255, k+2)
|
|
||||||
if key==ord('h'):
|
|
||||||
k=max(1, k-2)
|
|
||||||
if key==ord('u'):
|
|
||||||
th1=min(255, th1+1)
|
|
||||||
if key==ord('j'):
|
|
||||||
th1=max(0, th1-1)
|
|
||||||
if key==ord('i'):
|
|
||||||
th2=min(255, th2+1)
|
|
||||||
if key==ord('k'):
|
|
||||||
th2=max(0, th2-1)
|
|
||||||
if key==ord('s'):
|
|
||||||
stop=not stop
|
|
||||||
if key==ord('a'):
|
|
||||||
for cpt in range(200):
|
|
||||||
ret, frame=cap.read()
|
|
||||||
image=frame.copy()
|
|
||||||
cap.release()
|
|
||||||
cv2.destroyAllWindows()
|
|
||||||
@@ -1,147 +0,0 @@
|
|||||||
import cv2
|
|
||||||
import numpy as np
|
|
||||||
import time
|
|
||||||
|
|
||||||
ymin=400
|
|
||||||
ymax=401
|
|
||||||
xmin1=20
|
|
||||||
xmax1=120
|
|
||||||
xmin2=550
|
|
||||||
xmax2=620
|
|
||||||
|
|
||||||
def point(capteur):
|
|
||||||
s1=len(capteur)-1
|
|
||||||
s2=len(capteur)-1
|
|
||||||
for i in range(len(capteur)):
|
|
||||||
if capteur[i]!=0:
|
|
||||||
s1=i
|
|
||||||
break
|
|
||||||
if s1!=len(capteur)-1:
|
|
||||||
for i in range(len(capteur)-1, s1-1, -1):
|
|
||||||
if capteur[i]!=0:
|
|
||||||
s2=i
|
|
||||||
break
|
|
||||||
return int((s1+s2)/2)
|
|
||||||
return -1
|
|
||||||
|
|
||||||
s1_old=0
|
|
||||||
s2_old=0
|
|
||||||
s1=0
|
|
||||||
s2=0
|
|
||||||
s1_time=0
|
|
||||||
s2_time=0
|
|
||||||
th1=75
|
|
||||||
th2=150
|
|
||||||
stop=0
|
|
||||||
k=3
|
|
||||||
url = "http://192.168.74.194:8081"
|
|
||||||
|
|
||||||
cap=cv2.VideoCapture(url)
|
|
||||||
while True:
|
|
||||||
if not stop:
|
|
||||||
ret, frame=cap.read()
|
|
||||||
if ret is False:
|
|
||||||
quit()
|
|
||||||
image=frame.copy()
|
|
||||||
|
|
||||||
gray1=cv2.cvtColor(frame[ymin:ymax, xmin1:xmax1], cv2.COLOR_BGR2GRAY)
|
|
||||||
if k!=1:
|
|
||||||
gray1=cv2.blur(gray1, (k, k))
|
|
||||||
capteur1=cv2.Canny(gray1, th1, th2)
|
|
||||||
|
|
||||||
gray2=cv2.cvtColor(frame[ymin:ymax, xmin1:xmax1], cv2.COLOR_BGR2GRAY)
|
|
||||||
if k!=1:
|
|
||||||
gray2=cv2.blur(gray2, (k, k))
|
|
||||||
capteur2=cv2.Canny(gray2, th1, th2)
|
|
||||||
|
|
||||||
cv2.rectangle(image, (xmin1, ymin), (xmax1, ymax), (0, 0, 255), 1)
|
|
||||||
cv2.rectangle(image, (xmin2, ymin), (xmax2, ymax), (0, 0, 255), 1)
|
|
||||||
|
|
||||||
s1=point(capteur1[0])
|
|
||||||
if s1!=-1:
|
|
||||||
cv2.circle(image, (s1+xmin1, ymin), 3, (0, 255, 0), 3)
|
|
||||||
s1_old=s1
|
|
||||||
s1_time=time.time()
|
|
||||||
else:
|
|
||||||
if time.time()-s1_time<1:
|
|
||||||
cv2.circle(image, (s1_old+xmin1, ymin), 3, (100, 255, 255), 3)
|
|
||||||
s1=s1_old
|
|
||||||
else:
|
|
||||||
s1=-1
|
|
||||||
|
|
||||||
s2=point(capteur2[0])
|
|
||||||
if s2!=-1:
|
|
||||||
cv2.circle(image, (s2+xmin2, ymin), 3, (0, 255, 0), 3)
|
|
||||||
s2_old=s2
|
|
||||||
s2_time=time.time()
|
|
||||||
else:
|
|
||||||
if time.time()-s2_time<1:
|
|
||||||
cv2.circle(image, (s2_old+xmin2, ymin), 3, (100, 255, 255), 3)
|
|
||||||
s2=s2_old
|
|
||||||
else:
|
|
||||||
s2=-1
|
|
||||||
|
|
||||||
if s1!=-1 and s2!=-1:
|
|
||||||
s2_=abs(xmax2-xmin2-s2)
|
|
||||||
if abs(s2_-s1)>20:
|
|
||||||
c=(0, max(0, 255-10*int(abs(s1-s2_)/2)), min(255, 10*int(abs(s1-s2_)/2)))
|
|
||||||
cv2.circle(image, (int((xmax2-xmin1)/2)+xmin1, ymax-25), 5, c, 7)
|
|
||||||
cv2.arrowedLine(image, (int((xmax2-xmin1)/2)+xmin1, ymax-25), (int((xmax2-xmin1)/2)+xmin1+2*int((s1-s2_)/2), ymax-25), c, 3, tipLength=0.4)
|
|
||||||
else:
|
|
||||||
cv2.putText(image, "OK", (int((xmax2-xmin1)/2)+xmin1-15, ymax-16), cv2.FONT_HERSHEY_COMPLEX_SMALL, 1, (0, 255, 0), 1)
|
|
||||||
|
|
||||||
cv2.putText(image, "[u|j]th1: {:d} [i|k]th2: {:d} [y|h]blur: {:d}".format(th1, th2, k), (10, 40), cv2.FONT_HERSHEY_COMPLEX_SMALL, 1, (0, 255, 255), 1)
|
|
||||||
cv2.putText(image, "[a]>> [s]stop [q]quit", (10, 70), cv2.FONT_HERSHEY_COMPLEX_SMALL, 1, (0, 255, 255), 1)
|
|
||||||
cv2.imshow("image", image)
|
|
||||||
gray=cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
|
||||||
if k!=1:
|
|
||||||
gray=cv2.blur(gray, (k, k))
|
|
||||||
cv2.imshow("blur", gray)
|
|
||||||
gray_canny=cv2.Canny(gray, th1, th2)
|
|
||||||
cv2.imshow("canny", gray_canny)
|
|
||||||
|
|
||||||
if not stop:
|
|
||||||
key=cv2.waitKey(20)&0xFF
|
|
||||||
else:
|
|
||||||
key=cv2.waitKey()
|
|
||||||
image=frame.copy()
|
|
||||||
|
|
||||||
if key==ord('q'):
|
|
||||||
break
|
|
||||||
if key==ord('m'):
|
|
||||||
ymin+=1
|
|
||||||
ymax+=1
|
|
||||||
if key==ord('p'):
|
|
||||||
ymin-=1
|
|
||||||
ymax-=1
|
|
||||||
if key==ord('o'):
|
|
||||||
xmin1+=1
|
|
||||||
xmax1+=1
|
|
||||||
xmin2+=1
|
|
||||||
xmax2+=1
|
|
||||||
if key==ord('l'):
|
|
||||||
xmin1-=1
|
|
||||||
xmax1-=1
|
|
||||||
xmin2-=1
|
|
||||||
xmax2-=1
|
|
||||||
if key==ord('y'):
|
|
||||||
k=min(255, k+2)
|
|
||||||
if key==ord('h'):
|
|
||||||
k=max(1, k-2)
|
|
||||||
if key==ord('u'):
|
|
||||||
th1=min(255, th1+1)
|
|
||||||
if key==ord('j'):
|
|
||||||
th1=max(0, th1-1)
|
|
||||||
if key==ord('i'):
|
|
||||||
th2=min(255, th2+1)
|
|
||||||
if key==ord('k'):
|
|
||||||
th2=max(0, th2-1)
|
|
||||||
if key==ord('s'):
|
|
||||||
stop=not stop
|
|
||||||
if key==ord('a'):
|
|
||||||
for cpt in range(200):
|
|
||||||
ret, frame=cap.read()
|
|
||||||
image=frame.copy()
|
|
||||||
|
|
||||||
cap.release()
|
|
||||||
cv2.destroyAllWindows()
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
import cv2
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
stop=0
|
|
||||||
cap=cv2.VideoCapture(0)
|
|
||||||
while True:
|
|
||||||
if not stop:
|
|
||||||
ret, frame=cap.read()
|
|
||||||
if ret is False:
|
|
||||||
quit()
|
|
||||||
image=frame.copy()
|
|
||||||
|
|
||||||
cv2.imshow("image", image)
|
|
||||||
gray=cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
|
||||||
|
|
||||||
grad_x=cv2.Sobel(gray, cv2.CV_8U, 1, 0, ksize=5)
|
|
||||||
cv2.imshow("grad x", grad_x)
|
|
||||||
|
|
||||||
grad_y=cv2.Sobel(gray, cv2.CV_8U, 0, 1, ksize=5)
|
|
||||||
cv2.imshow("grad y", grad_y)
|
|
||||||
|
|
||||||
if not stop:
|
|
||||||
key=cv2.waitKey(10)&0xFF
|
|
||||||
else:
|
|
||||||
key=cv2.waitKey()
|
|
||||||
image=frame.copy()
|
|
||||||
|
|
||||||
if key==ord('q'):
|
|
||||||
break
|
|
||||||
if key==ord('s'):
|
|
||||||
stop=not stop
|
|
||||||
if key==ord('a'):
|
|
||||||
for cpt in range(200):
|
|
||||||
ret, frame=cap.read()
|
|
||||||
image=frame.copy()
|
|
||||||
cap.release()
|
|
||||||
cv2.destroyAllWindows()
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
python server-ia/Identification_Yolov3/yolo_opencv.py --image server-ia/data/images/dog.jpg --config server-ia/data/modeles/yolov3/yolov3.cfg --weights server-ia/data/modeles/yolov3/yolov3.weights --classes server-ia/data/modeles/yolov3/yolov3.txt
|
|
||||||
python server-ia/Identification_Yolov3/yolo_opencv_video.py --video cam --config server-ia/data/modeles/yolov3/yolov3.cfg --weights server-ia/data/modeles/yolov3/yolov3.weights --classes server-ia/data/modeles/yolov3/yolov3.txt
|
|
||||||
python server-ia/Identification_Yolov3/yolo_opencv_video.py --video server-ia/data/videos/ville.mp4 --config server-ia/data/modeles/yolov3/yolov3.cfg --weights server-ia/data/modeles/yolov3/yolov3.weights --classes server-ia/data/modeles/yolov3/yolov3.txt
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
import cv2
|
|
||||||
from tensorflow.keras.models import load_model
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
# Charger le modèle sauvegardé
|
|
||||||
model = load_model("server-ia/data/modeles/RoadSign/modele_signaux_routiers.h5")
|
|
||||||
|
|
||||||
# Fonction pour charger les noms de classe à partir d'un fichier
|
|
||||||
def load_class_names(file_path):
|
|
||||||
with open(file_path, 'r') as file:
|
|
||||||
class_names = [line.strip() for line in file.readlines()]
|
|
||||||
return class_names
|
|
||||||
|
|
||||||
# Définir le chemin du fichier contenant les noms de classe
|
|
||||||
class_names_file = "server-ia/data/modeles/RoadSign/class_names.txt"
|
|
||||||
|
|
||||||
# Charger les noms de classe à partir du fichier
|
|
||||||
class_names = load_class_names(class_names_file)
|
|
||||||
|
|
||||||
# Fonction pour détecter les panneaux de signalisation dans une image
|
|
||||||
def detect_sign(image):
|
|
||||||
# Prétraiter l'image
|
|
||||||
preprocessed_img = preprocess_image(image)
|
|
||||||
|
|
||||||
# Faire une prédiction avec le modèle
|
|
||||||
predictions = model.predict(preprocessed_img)
|
|
||||||
|
|
||||||
# Obtenir l'indice de la classe prédite
|
|
||||||
predicted_class_index = np.argmax(predictions)
|
|
||||||
|
|
||||||
# Récupérer le nom de la classe prédite
|
|
||||||
predicted_class_name = class_names[predicted_class_index]
|
|
||||||
|
|
||||||
return predicted_class_name
|
|
||||||
|
|
||||||
# Fonction pour prétraiter l'image
|
|
||||||
def preprocess_image(image):
|
|
||||||
# Mettre à l'échelle l'image aux dimensions attendues par le modèle
|
|
||||||
scaled_image = cv2.resize(image, (224, 224))
|
|
||||||
scaled_image = scaled_image.astype("float") / 255.0
|
|
||||||
|
|
||||||
# Ajouter une dimension pour correspondre à la forme d'entrée du modèle
|
|
||||||
preprocessed_img = np.expand_dims(scaled_image, axis=0)
|
|
||||||
|
|
||||||
return preprocessed_img
|
|
||||||
|
|
||||||
# Définir la source vidéo ou la caméra
|
|
||||||
# Pour une vidéo
|
|
||||||
video_path = "server-ia/data/videos/autoroute.mp4"
|
|
||||||
cap = cv2.VideoCapture(video_path)
|
|
||||||
|
|
||||||
# Pour la caméra
|
|
||||||
# cap = cv2.VideoCapture(0)
|
|
||||||
# Nombre de trames à sauter entre chaque trame lue
|
|
||||||
skip_frames = 5
|
|
||||||
|
|
||||||
# Boucle pour lire les images de la vidéo ou de la caméra
|
|
||||||
frame_count = 0
|
|
||||||
while cap.isOpened():
|
|
||||||
ret, frame = cap.read()
|
|
||||||
if not ret:
|
|
||||||
break
|
|
||||||
|
|
||||||
# Incrémenter le compteur de trames
|
|
||||||
frame_count += 1
|
|
||||||
|
|
||||||
# Si le compteur de trames est un multiple de skip_frames, traiter la trame et afficher
|
|
||||||
if frame_count % skip_frames == 0:
|
|
||||||
# Réinitialiser le compteur de trames
|
|
||||||
frame_count = 0
|
|
||||||
|
|
||||||
# Détecter les panneaux de signalisation dans l'image
|
|
||||||
predicted_class_name = detect_sign(frame)
|
|
||||||
|
|
||||||
# Dessiner un carré autour de chaque objet détecté et afficher le nom de la classe au-dessus
|
|
||||||
# (ici, je vais dessiner un carré au hasard pour donner un exemple)
|
|
||||||
x_min, y_min, x_max, y_max = 900, 50, 1200, 650 # Coordonnées de la boîte englobante (à remplacer par les bonnes valeurs)
|
|
||||||
cv2.rectangle(frame, (x_min, y_min), (x_max, y_max), (0, 255, 0), 2)
|
|
||||||
cv2.putText(frame, predicted_class_name, (x_min, y_min - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 255, 0), 2)
|
|
||||||
|
|
||||||
# Afficher l'image
|
|
||||||
cv2.imshow('Frame', frame)
|
|
||||||
|
|
||||||
# Attendre la touche 'q' pour quitter
|
|
||||||
if cv2.waitKey(1) & 0xFF == ord('q'):
|
|
||||||
break
|
|
||||||
|
|
||||||
# Libérer la capture et fermer les fenêtres
|
|
||||||
cap.release()
|
|
||||||
cv2.destroyAllWindows()
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
import cv2
|
|
||||||
from tensorflow.keras.models import load_model
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
# Charger le modèle sauvegardé
|
|
||||||
model = load_model("server-ia/data/modeles/RoadSign/modele_signaux_routiers.h5")
|
|
||||||
|
|
||||||
# Fonction pour charger les noms de classe à partir d'un fichier
|
|
||||||
def load_class_names(file_path):
|
|
||||||
with open(file_path, 'r') as file:
|
|
||||||
class_names = [line.strip() for line in file.readlines()]
|
|
||||||
return class_names
|
|
||||||
|
|
||||||
# Définir le chemin du fichier contenant les noms de classe
|
|
||||||
class_names_file = "server-ia/data/modeles/RoadSign/class_names.txt"
|
|
||||||
|
|
||||||
# Charger les noms de classe à partir du fichier
|
|
||||||
class_names = load_class_names(class_names_file)
|
|
||||||
|
|
||||||
# Fonction pour prétraiter l'image
|
|
||||||
def preprocess_image(image):
|
|
||||||
# Mettre à l'échelle l'image aux dimensions attendues par le modèle
|
|
||||||
scaled_image = cv2.resize(image, (224, 224))
|
|
||||||
scaled_image = scaled_image.astype("float") / 255.0
|
|
||||||
|
|
||||||
# Ajouter une dimension pour correspondre à la forme d'entrée du modèle
|
|
||||||
preprocessed_img = np.expand_dims(scaled_image, axis=0)
|
|
||||||
|
|
||||||
return preprocessed_img
|
|
||||||
|
|
||||||
# Fonction pour obtenir les coordonnées de la boîte englobante
|
|
||||||
def obtenir_coordonnees_boite(predictions):
|
|
||||||
# A DEFINIR
|
|
||||||
# Supposons que predictions est une liste de [x_min, y_min, x_max, y_max] pour chaque boîte englobante
|
|
||||||
return predictions[0] # Retourne les coordonnées de la première boîte englobante
|
|
||||||
|
|
||||||
# Fonction pour détecter les panneaux de signalisation dans une image
|
|
||||||
def detect_sign(image):
|
|
||||||
# Prétraiter l'image
|
|
||||||
preprocessed_img = preprocess_image(image)
|
|
||||||
|
|
||||||
# Faire une prédiction avec le modèle
|
|
||||||
predictions = model.predict(preprocessed_img)
|
|
||||||
|
|
||||||
# Obtenir l'indice de la classe prédite
|
|
||||||
predicted_class_index = np.argmax(predictions)
|
|
||||||
|
|
||||||
# Récupérer le nom de la classe prédite
|
|
||||||
predicted_class_name = class_names[predicted_class_index]
|
|
||||||
|
|
||||||
return predicted_class_name, predictions
|
|
||||||
|
|
||||||
# Définir la source vidéo ou la caméra
|
|
||||||
# Pour une vidéo
|
|
||||||
video_path = "server-ia/data/videos/autoroute.mp4"
|
|
||||||
cap = cv2.VideoCapture(video_path)
|
|
||||||
|
|
||||||
# Pour la caméra
|
|
||||||
# cap = cv2.VideoCapture(0)
|
|
||||||
# Nombre de trames à sauter entre chaque trame lue
|
|
||||||
skip_frames = 5
|
|
||||||
|
|
||||||
# Boucle pour lire les images de la vidéo ou de la caméra
|
|
||||||
frame_count = 0
|
|
||||||
while cap.isOpened():
|
|
||||||
ret, frame = cap.read()
|
|
||||||
if not ret:
|
|
||||||
break
|
|
||||||
|
|
||||||
# Incrémenter le compteur de trames
|
|
||||||
frame_count += 1
|
|
||||||
|
|
||||||
# Si le compteur de trames est un multiple de skip_frames, traiter la trame et afficher
|
|
||||||
if frame_count % skip_frames == 0:
|
|
||||||
# Réinitialiser le compteur de trames
|
|
||||||
frame_count = 0
|
|
||||||
|
|
||||||
# Détecter les panneaux de signalisation dans l'image
|
|
||||||
predicted_class_name, predictions = detect_sign(frame)
|
|
||||||
|
|
||||||
# Obtenir les coordonnées de la boîte englobante de l'objet détecté
|
|
||||||
x_min, y_min, x_max, y_max = obtenir_coordonnees_boite(predictions)
|
|
||||||
|
|
||||||
# Dessiner un carré autour de chaque objet détecté et afficher le nom de la classe au-dessus
|
|
||||||
cv2.rectangle(frame, (x_min, y_min), (x_max, y_max), (0, 255, 0), 2)
|
|
||||||
cv2.putText(frame, predicted_class_name, (x_min, y_min - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.9, (0, 255, 0), 2)
|
|
||||||
|
|
||||||
# Afficher l'image
|
|
||||||
cv2.imshow('Frame', frame)
|
|
||||||
|
|
||||||
# Attendre la touche 'q' pour quitter
|
|
||||||
if cv2.waitKey(1) & 0xFF == ord('q'):
|
|
||||||
break
|
|
||||||
|
|
||||||
# Libérer la capture et fermer les fenêtres
|
|
||||||
cap.release()
|
|
||||||
cv2.destroyAllWindows()
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
import cv2
|
|
||||||
from tensorflow.keras.models import load_model
|
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
# Charger le modèle sauvegardé
|
|
||||||
model = load_model("server-ia/data/modeles/RoadSign/modele_signaux_routiers.h5")
|
|
||||||
|
|
||||||
# Fonction pour charger les noms de classe à partir d'un fichier
|
|
||||||
def load_class_names(file_path):
|
|
||||||
with open(file_path, 'r') as file:
|
|
||||||
class_names = [line.strip() for line in file.readlines()]
|
|
||||||
return class_names
|
|
||||||
|
|
||||||
# Définir le chemin du fichier contenant les noms de classe
|
|
||||||
class_names_file = "server-ia/data/modeles/RoadSign/class_names.txt"
|
|
||||||
|
|
||||||
# Charger les noms de classe à partir du fichier
|
|
||||||
class_names = load_class_names(class_names_file)
|
|
||||||
|
|
||||||
# Fonction pour détecter les panneaux de signalisation dans une image
|
|
||||||
def detect_sign(image):
|
|
||||||
# Prétraiter l'image
|
|
||||||
preprocessed_img = preprocess_image(image)
|
|
||||||
|
|
||||||
# Faire une prédiction avec le modèle
|
|
||||||
predictions = model.predict(preprocessed_img)
|
|
||||||
|
|
||||||
# Obtenir l'indice de la classe prédite
|
|
||||||
predicted_class_index = np.argmax(predictions)
|
|
||||||
|
|
||||||
# Récupérer le nom de la classe prédite
|
|
||||||
predicted_class_name = class_names[predicted_class_index]
|
|
||||||
|
|
||||||
return predicted_class_name
|
|
||||||
|
|
||||||
# Fonction pour prétraiter l'image
|
|
||||||
def preprocess_image(image):
|
|
||||||
# Mettre à l'échelle l'image aux dimensions attendues par le modèle
|
|
||||||
scaled_image = cv2.resize(image, (224, 224))
|
|
||||||
scaled_image = scaled_image.astype("float") / 255.0
|
|
||||||
|
|
||||||
# Ajouter une dimension pour correspondre à la forme d'entrée du modèle
|
|
||||||
preprocessed_img = np.expand_dims(scaled_image, axis=0)
|
|
||||||
|
|
||||||
return preprocessed_img
|
|
||||||
|
|
||||||
# Définir la source vidéo ou la caméra
|
|
||||||
# Pour une vidéo
|
|
||||||
video_path = "server-ia/data/videos/autoroute.mp4"
|
|
||||||
cap = cv2.VideoCapture(video_path)
|
|
||||||
|
|
||||||
# Pour la caméra
|
|
||||||
# cap = cv2.VideoCapture(0)
|
|
||||||
|
|
||||||
# Boucle pour lire les images de la vidéo ou de la caméra
|
|
||||||
while cap.isOpened():
|
|
||||||
ret, frame = cap.read()
|
|
||||||
if not ret:
|
|
||||||
break
|
|
||||||
|
|
||||||
# Détecter les panneaux de signalisation dans l'image
|
|
||||||
predicted_class_name = detect_sign(frame)
|
|
||||||
|
|
||||||
# Afficher le résultat sur l'image
|
|
||||||
cv2.putText(frame, predicted_class_name, (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
|
|
||||||
|
|
||||||
# Afficher l'image
|
|
||||||
cv2.imshow('Frame', frame)
|
|
||||||
|
|
||||||
# Attendre la touche 'q' pour quitter
|
|
||||||
if cv2.waitKey(1) & 0xFF == ord('q'):
|
|
||||||
break
|
|
||||||
|
|
||||||
# Libérer la capture et fermer les fenêtres
|
|
||||||
cap.release()
|
|
||||||
cv2.destroyAllWindows()
|
|
||||||
3
server-ia/README_Yolov3.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
python server-ia/yolov3_opencv_picture.py --image server-ia/data/images/dog.jpg --config server-ia/data/modeles/yolov3/yolov3.cfg --weights server-ia/data/modeles/yolov3/yolov3.weights --classes server-ia/data/modeles/yolov3/yolov3.txt
|
||||||
|
python server-ia/yolov3_opencv_video.py --video cam --config server-ia/data/modeles/yolov3/yolov3.cfg --weights server-ia/data/modeles/yolov3/yolov3.weights --classes server-ia/data/modeles/yolov3/yolov3.txt
|
||||||
|
python server-ia/yolov3_opencv_video.py --video server-ia/data/videos/ville.mp4 --config server-ia/data/modeles/yolov3/yolov3.cfg --weights server-ia/data/modeles/yolov3/yolov3.weights --classes server-ia/data/modeles/yolov3/yolov3.txt
|
||||||
7
server-ia/README_cv2_ligne_detection.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
Largeur route 35cm
|
||||||
|
Largeur voiture ~19 cm
|
||||||
|
Analyse des bandes - 50cm
|
||||||
|
-------------------------
|
||||||
|
Réel
|
||||||
|
Largeur route 3,5m
|
||||||
|
Largeur voiture 1,8 m
|
||||||
76
server-ia/TF_Identification_Training_CCB.py
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
import tensorflow as tf
|
||||||
|
import numpy as np
|
||||||
|
import cv2
|
||||||
|
import os
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
size = 60 # Taille des images à laquelle le modèle a été entraîné
|
||||||
|
model_path = "server-ia/data/modeles/tensorflow/tf_modele_speed_panneau.keras"
|
||||||
|
labels_csv_path = "server-ia/data/modeles/tensorflow/train_labels.csv"
|
||||||
|
confidence_threshold = 0.6 # Seuil de confiance pour considérer une prédiction comme valide
|
||||||
|
|
||||||
|
# Fonction pour charger le mapping des labels depuis le fichier CSV
|
||||||
|
def load_labels_mapping(labels_csv_path):
|
||||||
|
df = pd.read_csv(labels_csv_path)
|
||||||
|
unique_labels = df['label'].unique()
|
||||||
|
labels_mapping = {label: idx for idx, label in enumerate(unique_labels)}
|
||||||
|
print(f"Mapping des labels chargé : {labels_mapping}")
|
||||||
|
return labels_mapping
|
||||||
|
|
||||||
|
# Chargement du mapping des labels
|
||||||
|
labels_mapping = load_labels_mapping(labels_csv_path)
|
||||||
|
|
||||||
|
# Inversion du mapping pour obtenir l'étiquette à partir de l'index
|
||||||
|
reverse_labels_mapping = {v: k for k, v in labels_mapping.items()}
|
||||||
|
|
||||||
|
# Chargement du modèle
|
||||||
|
model = tf.keras.models.load_model(model_path)
|
||||||
|
print(f"Modèle chargé depuis {model_path}")
|
||||||
|
|
||||||
|
# Fonction pour prédire la catégorie d'une image, encadrer la zone reconnue et afficher les résultats
|
||||||
|
def predict_and_draw_bounding_box(image_path, model, labels_mapping, size, confidence_threshold):
|
||||||
|
# Chargement de l'image originale
|
||||||
|
image = cv2.imread(image_path)
|
||||||
|
if image is None:
|
||||||
|
raise ValueError(f"Erreur de chargement de l'image : {image_path}")
|
||||||
|
|
||||||
|
# Redimensionnement et normalisation pour la prédiction
|
||||||
|
image_resized = cv2.resize(image, (size, size), cv2.INTER_LANCZOS4)
|
||||||
|
image_normalized = image_resized.astype('float32') / 255.0 # Normalisation
|
||||||
|
image_batch = np.expand_dims(image_normalized, axis=0) # Ajout d'une dimension pour le batch
|
||||||
|
|
||||||
|
# Prédiction
|
||||||
|
predictions = model.predict(image_batch)
|
||||||
|
predicted_index = np.argmax(predictions, axis=1)[0]
|
||||||
|
confidence = np.max(predictions)
|
||||||
|
|
||||||
|
# Récupération du label prédictif ou "Inconnu" si la confiance est faible
|
||||||
|
if confidence < confidence_threshold:
|
||||||
|
predicted_label = "Inconnu"
|
||||||
|
print(f"Confiance faible ({confidence:.2f}). La prédiction n'est pas fiable.")
|
||||||
|
else:
|
||||||
|
predicted_label = reverse_labels_mapping[predicted_index]
|
||||||
|
|
||||||
|
# Affichage de la prédiction dans la console
|
||||||
|
print(f"Image: {image_path}, Prédiction: {predicted_label} (Confiance: {confidence:.2f})")
|
||||||
|
|
||||||
|
# Encadrement de la zone reconnue (l'ensemble de l'image redimensionnée)
|
||||||
|
height, width, _ = image.shape
|
||||||
|
cv2.rectangle(image, (0, 0), (width, height), (0, 255, 0), 2) # Couleur verte et épaisseur de 2
|
||||||
|
|
||||||
|
# Ajout du texte de la prédiction sur l'image
|
||||||
|
cv2.putText(image, f'Predicted: {predicted_label}', (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 2)
|
||||||
|
|
||||||
|
# Affichage de l'image avec le cadre
|
||||||
|
cv2.imshow("Image avec zone reconnue", image)
|
||||||
|
cv2.waitKey(0)
|
||||||
|
cv2.destroyAllWindows()
|
||||||
|
|
||||||
|
# Exemple d'utilisation
|
||||||
|
image_to_classify = "server-ia/data/images/panneaux/France_road_sign_B14_(10).svg.png" # Remplacez par le chemin exact de l'image à classifier
|
||||||
|
|
||||||
|
try:
|
||||||
|
predict_and_draw_bounding_box(image_to_classify, model, labels_mapping, size, confidence_threshold)
|
||||||
|
except ValueError as e:
|
||||||
|
print(e)
|
||||||
12213
server-ia/data/haarcascades/haarcascade_eye.xml
Normal file
22619
server-ia/data/haarcascades/haarcascade_eye_tree_eyeglasses.xml
Normal file
14382
server-ia/data/haarcascades/haarcascade_frontalcatface.xml
Normal file
13394
server-ia/data/haarcascades/haarcascade_frontalcatface_extended.xml
Normal file
24350
server-ia/data/haarcascades/haarcascade_frontalface_alt.xml
Normal file
20719
server-ia/data/haarcascades/haarcascade_frontalface_alt2.xml
Normal file
96484
server-ia/data/haarcascades/haarcascade_frontalface_alt_tree.xml
Normal file
33314
server-ia/data/haarcascades/haarcascade_frontalface_default.xml
Normal file
17030
server-ia/data/haarcascades/haarcascade_fullbody.xml
Normal file
7390
server-ia/data/haarcascades/haarcascade_lefteye_2splits.xml
Normal file
14056
server-ia/data/haarcascades/haarcascade_lowerbody.xml
Normal file
29690
server-ia/data/haarcascades/haarcascade_profileface.xml
Normal file
7407
server-ia/data/haarcascades/haarcascade_righteye_2splits.xml
Normal file
2656
server-ia/data/haarcascades/haarcascade_russian_plate_number.xml
Normal file
6729
server-ia/data/haarcascades/haarcascade_smile.xml
Normal file
28134
server-ia/data/haarcascades/haarcascade_upperbody.xml
Normal file
BIN
server-ia/data/images/dog.jpg
Normal file
|
After Width: | Height: | Size: 160 KiB |
BIN
server-ia/data/images/panneaux.jpg
Normal file
|
After Width: | Height: | Size: 113 KiB |
BIN
server-ia/data/images/panneaux/France_road_sign_B14_(10).svg.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
BIN
server-ia/data/images/panneaux/France_road_sign_B14_(15).svg.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
server-ia/data/images/panneaux/France_road_sign_B14_(20).svg.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
server-ia/data/images/panneaux/France_road_sign_B14_(30).svg.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
server-ia/data/images/panneaux/France_road_sign_B14_(40).svg.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
server-ia/data/images/panneaux/France_road_sign_B14_(45).svg.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
server-ia/data/images/panneaux/France_road_sign_B14_(5).svg.png
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
BIN
server-ia/data/images/panneaux/France_road_sign_B14_(50).svg.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
server-ia/data/images/panneaux/France_road_sign_B14_(60).svg.png
Normal file
|
After Width: | Height: | Size: 3.6 KiB |
BIN
server-ia/data/images/panneaux/France_road_sign_B14_(70).svg.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
server-ia/data/images/panneaux/France_road_sign_B14_(80).svg.png
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
server-ia/data/images/panneaux/France_road_sign_B14_(90).svg.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
2
server-ia/data/modeles/CV2/README.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Généré par server-trainer\UsersIdentification-ModelTraining.py
|
||||||
|
Utilisé pour server-ia\Camera_Identification_User\identifie.py
|
||||||
BIN
server-ia/data/modeles/CV2/labels.pickle
Normal file
1
server-ia/data/modeles/MobileNetV2/README.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Generé par CARIA\server-trainer\RoadSigns-ModelTraining.py
|
||||||
43
server-ia/data/modeles/MobileNetV2/class_names.txt
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
0
|
||||||
|
1
|
||||||
|
10
|
||||||
|
11
|
||||||
|
12
|
||||||
|
13
|
||||||
|
14
|
||||||
|
15
|
||||||
|
16
|
||||||
|
17
|
||||||
|
18
|
||||||
|
19
|
||||||
|
2
|
||||||
|
20
|
||||||
|
21
|
||||||
|
22
|
||||||
|
23
|
||||||
|
24
|
||||||
|
25
|
||||||
|
26
|
||||||
|
27
|
||||||
|
28
|
||||||
|
29
|
||||||
|
3
|
||||||
|
30
|
||||||
|
31
|
||||||
|
32
|
||||||
|
33
|
||||||
|
34
|
||||||
|
35
|
||||||
|
36
|
||||||
|
37
|
||||||
|
38
|
||||||
|
39
|
||||||
|
4
|
||||||
|
40
|
||||||
|
41
|
||||||
|
42
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
||||||
2
server-ia/data/modeles/tensorflow/README.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Générer par server-trainer\Camera_Identification_VitesseRoadSign-ModelTraining.py
|
||||||
|
Utilisé pour server-ia\Camera_Identification_VitesseRoadSign\lire_panneau.py
|
||||||
1790
server-ia/data/modeles/tensorflow/train_labels.csv
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
item {
|
||||||
|
id: 1
|
||||||
|
name: 'person'
|
||||||
|
}
|
||||||
|
item {
|
||||||
|
id: 2
|
||||||
|
name: 'bicycle'
|
||||||
|
}
|
||||||
|
item {
|
||||||
|
id: 3
|
||||||
|
name: 'car'
|
||||||
|
}
|
||||||
|
item {
|
||||||
|
id: 4
|
||||||
|
name: 'motorcycle'
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<08><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>_<10><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>âݠ<><DDA0><EFBFBD><EFBFBD>Ø <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28>݃<EFBFBD><DD83>ǚ<EFBFBD><C79A>2
|
||||||
21
server-ia/data/modeles/traffic_signs_model/keras_metadata.pb
Normal file
80
server-ia/data/modeles/yolov3-tiny/coco.names
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
person
|
||||||
|
bicycle
|
||||||
|
car
|
||||||
|
motorbike
|
||||||
|
aeroplane
|
||||||
|
bus
|
||||||
|
train
|
||||||
|
truck
|
||||||
|
boat
|
||||||
|
traffic light
|
||||||
|
fire hydrant
|
||||||
|
stop sign
|
||||||
|
parking meter
|
||||||
|
bench
|
||||||
|
bird
|
||||||
|
cat
|
||||||
|
dog
|
||||||
|
horse
|
||||||
|
sheep
|
||||||
|
cow
|
||||||
|
elephant
|
||||||
|
bear
|
||||||
|
zebra
|
||||||
|
giraffe
|
||||||
|
backpack
|
||||||
|
umbrella
|
||||||
|
handbag
|
||||||
|
tie
|
||||||
|
suitcase
|
||||||
|
frisbee
|
||||||
|
skis
|
||||||
|
snowboard
|
||||||
|
sports ball
|
||||||
|
kite
|
||||||
|
baseball bat
|
||||||
|
baseball glove
|
||||||
|
skateboard
|
||||||
|
surfboard
|
||||||
|
tennis racket
|
||||||
|
bottle
|
||||||
|
wine glass
|
||||||
|
cup
|
||||||
|
fork
|
||||||
|
knife
|
||||||
|
spoon
|
||||||
|
bowl
|
||||||
|
banana
|
||||||
|
apple
|
||||||
|
sandwich
|
||||||
|
orange
|
||||||
|
broccoli
|
||||||
|
carrot
|
||||||
|
hot dog
|
||||||
|
pizza
|
||||||
|
donut
|
||||||
|
cake
|
||||||
|
chair
|
||||||
|
sofa
|
||||||
|
pottedplant
|
||||||
|
bed
|
||||||
|
diningtable
|
||||||
|
toilet
|
||||||
|
tvmonitor
|
||||||
|
laptop
|
||||||
|
mouse
|
||||||
|
remote
|
||||||
|
keyboard
|
||||||
|
cell phone
|
||||||
|
microwave
|
||||||
|
oven
|
||||||
|
toaster
|
||||||
|
sink
|
||||||
|
refrigerator
|
||||||
|
book
|
||||||
|
clock
|
||||||
|
vase
|
||||||
|
scissors
|
||||||
|
teddy bear
|
||||||
|
hair drier
|
||||||
|
toothbrush
|
||||||
182
server-ia/data/modeles/yolov3-tiny/yolov3-tiny.cfg
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
[net]
|
||||||
|
# Testing
|
||||||
|
batch=1
|
||||||
|
subdivisions=1
|
||||||
|
# Training
|
||||||
|
# batch=64
|
||||||
|
# subdivisions=2
|
||||||
|
width=416
|
||||||
|
height=416
|
||||||
|
channels=3
|
||||||
|
momentum=0.9
|
||||||
|
decay=0.0005
|
||||||
|
angle=0
|
||||||
|
saturation = 1.5
|
||||||
|
exposure = 1.5
|
||||||
|
hue=.1
|
||||||
|
|
||||||
|
learning_rate=0.001
|
||||||
|
burn_in=1000
|
||||||
|
max_batches = 500200
|
||||||
|
policy=steps
|
||||||
|
steps=400000,450000
|
||||||
|
scales=.1,.1
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=16
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[maxpool]
|
||||||
|
size=2
|
||||||
|
stride=2
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=32
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[maxpool]
|
||||||
|
size=2
|
||||||
|
stride=2
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=64
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[maxpool]
|
||||||
|
size=2
|
||||||
|
stride=2
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=128
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[maxpool]
|
||||||
|
size=2
|
||||||
|
stride=2
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[maxpool]
|
||||||
|
size=2
|
||||||
|
stride=2
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=512
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[maxpool]
|
||||||
|
size=2
|
||||||
|
stride=1
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=1024
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
###########
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=512
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
filters=255
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[yolo]
|
||||||
|
mask = 3,4,5
|
||||||
|
anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319
|
||||||
|
classes=80
|
||||||
|
num=6
|
||||||
|
jitter=.3
|
||||||
|
ignore_thresh = .7
|
||||||
|
truth_thresh = 1
|
||||||
|
random=1
|
||||||
|
|
||||||
|
[route]
|
||||||
|
layers = -4
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=128
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[upsample]
|
||||||
|
stride=2
|
||||||
|
|
||||||
|
[route]
|
||||||
|
layers = -1, 8
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
filters=255
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
[yolo]
|
||||||
|
mask = 0,1,2
|
||||||
|
anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319
|
||||||
|
classes=80
|
||||||
|
num=6
|
||||||
|
jitter=.3
|
||||||
|
ignore_thresh = .7
|
||||||
|
truth_thresh = 1
|
||||||
|
random=1
|
||||||
789
server-ia/data/modeles/yolov3/yolov3.cfg
Normal file
@@ -0,0 +1,789 @@
|
|||||||
|
[net]
|
||||||
|
# Testing
|
||||||
|
# batch=1
|
||||||
|
# subdivisions=1
|
||||||
|
# Training
|
||||||
|
batch=64
|
||||||
|
subdivisions=16
|
||||||
|
width=608
|
||||||
|
height=608
|
||||||
|
channels=3
|
||||||
|
momentum=0.9
|
||||||
|
decay=0.0005
|
||||||
|
angle=0
|
||||||
|
saturation = 1.5
|
||||||
|
exposure = 1.5
|
||||||
|
hue=.1
|
||||||
|
|
||||||
|
learning_rate=0.001
|
||||||
|
burn_in=1000
|
||||||
|
max_batches = 500200
|
||||||
|
policy=steps
|
||||||
|
steps=400000,450000
|
||||||
|
scales=.1,.1
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=32
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
# Downsample
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=64
|
||||||
|
size=3
|
||||||
|
stride=2
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=32
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=64
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
# Downsample
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=128
|
||||||
|
size=3
|
||||||
|
stride=2
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=64
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=128
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=64
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=128
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
# Downsample
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=3
|
||||||
|
stride=2
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=128
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=128
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=128
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=128
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=128
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=128
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=128
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=128
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
# Downsample
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=512
|
||||||
|
size=3
|
||||||
|
stride=2
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=512
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=512
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=512
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=512
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=512
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=512
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=512
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=512
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
# Downsample
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=1024
|
||||||
|
size=3
|
||||||
|
stride=2
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=512
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=1024
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=512
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=1024
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=512
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=1024
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=512
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=1024
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[shortcut]
|
||||||
|
from=-3
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
######################
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=512
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
filters=1024
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=512
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
filters=1024
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=512
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
filters=1024
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
filters=255
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
|
||||||
|
[yolo]
|
||||||
|
mask = 6,7,8
|
||||||
|
anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326
|
||||||
|
classes=80
|
||||||
|
num=9
|
||||||
|
jitter=.3
|
||||||
|
ignore_thresh = .7
|
||||||
|
truth_thresh = 1
|
||||||
|
random=1
|
||||||
|
|
||||||
|
|
||||||
|
[route]
|
||||||
|
layers = -4
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[upsample]
|
||||||
|
stride=2
|
||||||
|
|
||||||
|
[route]
|
||||||
|
layers = -1, 61
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
filters=512
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
filters=512
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=256
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
filters=512
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
filters=255
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
|
||||||
|
[yolo]
|
||||||
|
mask = 3,4,5
|
||||||
|
anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326
|
||||||
|
classes=80
|
||||||
|
num=9
|
||||||
|
jitter=.3
|
||||||
|
ignore_thresh = .7
|
||||||
|
truth_thresh = 1
|
||||||
|
random=1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[route]
|
||||||
|
layers = -4
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=128
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[upsample]
|
||||||
|
stride=2
|
||||||
|
|
||||||
|
[route]
|
||||||
|
layers = -1, 36
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=128
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
filters=256
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=128
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
filters=256
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
filters=128
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
batch_normalize=1
|
||||||
|
size=3
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
filters=256
|
||||||
|
activation=leaky
|
||||||
|
|
||||||
|
[convolutional]
|
||||||
|
size=1
|
||||||
|
stride=1
|
||||||
|
pad=1
|
||||||
|
filters=255
|
||||||
|
activation=linear
|
||||||
|
|
||||||
|
|
||||||
|
[yolo]
|
||||||
|
mask = 0,1,2
|
||||||
|
anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326
|
||||||
|
classes=80
|
||||||
|
num=9
|
||||||
|
jitter=.3
|
||||||
|
ignore_thresh = .7
|
||||||
|
truth_thresh = 1
|
||||||
|
random=1
|
||||||
|
|
||||||
80
server-ia/data/modeles/yolov3/yolov3.txt
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
person
|
||||||
|
bicycle
|
||||||
|
car
|
||||||
|
motorcycle
|
||||||
|
airplane
|
||||||
|
bus
|
||||||
|
train
|
||||||
|
truck
|
||||||
|
boat
|
||||||
|
traffic light
|
||||||
|
fire hydrant
|
||||||
|
stop sign
|
||||||
|
parking meter
|
||||||
|
bench
|
||||||
|
bird
|
||||||
|
cat
|
||||||
|
dog
|
||||||
|
horse
|
||||||
|
sheep
|
||||||
|
cow
|
||||||
|
elephant
|
||||||
|
bear
|
||||||
|
zebra
|
||||||
|
giraffe
|
||||||
|
backpack
|
||||||
|
umbrella
|
||||||
|
handbag
|
||||||
|
tie
|
||||||
|
suitcase
|
||||||
|
frisbee
|
||||||
|
skis
|
||||||
|
snowboard
|
||||||
|
sports ball
|
||||||
|
kite
|
||||||
|
baseball bat
|
||||||
|
baseball glove
|
||||||
|
skateboard
|
||||||
|
surfboard
|
||||||
|
tennis racket
|
||||||
|
bottle
|
||||||
|
wine glass
|
||||||
|
cup
|
||||||
|
fork
|
||||||
|
knife
|
||||||
|
spoon
|
||||||
|
bowl
|
||||||
|
banana
|
||||||
|
apple
|
||||||
|
sandwich
|
||||||
|
orange
|
||||||
|
broccoli
|
||||||
|
carrot
|
||||||
|
hot dog
|
||||||
|
pizza
|
||||||
|
donut
|
||||||
|
cake
|
||||||
|
chair
|
||||||
|
couch
|
||||||
|
potted plant
|
||||||
|
bed
|
||||||
|
dining table
|
||||||
|
toilet
|
||||||
|
tv
|
||||||
|
laptop
|
||||||
|
mouse
|
||||||
|
remote
|
||||||
|
keyboard
|
||||||
|
cell phone
|
||||||
|
microwave
|
||||||
|
oven
|
||||||
|
toaster
|
||||||
|
sink
|
||||||
|
refrigerator
|
||||||
|
book
|
||||||
|
clock
|
||||||
|
vase
|
||||||
|
scissors
|
||||||
|
teddy bear
|
||||||
|
hair drier
|
||||||
|
toothbrush
|
||||||
108
server-ia/test_cv2_identifier_user.py
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
import cv2
|
||||||
|
import pickle
|
||||||
|
import numpy as np
|
||||||
|
import time
|
||||||
|
|
||||||
|
# Configuration des tailles et couleurs
|
||||||
|
MIN_SIZE = 50
|
||||||
|
COLOR_INFO = (255, 255, 255)
|
||||||
|
COLOR_KO = (0, 0, 255)
|
||||||
|
COLOR_OK = (0, 255, 0)
|
||||||
|
|
||||||
|
# Facteur d'agrandissement pour la fenêtre d'affichage
|
||||||
|
SCALE_FACTOR = 1.3
|
||||||
|
|
||||||
|
# Chargement des classificateurs et des modèles
|
||||||
|
FACE_CASCADE_PATH = "server-ia/data/haarcascades/haarcascade_frontalface_alt2.xml"
|
||||||
|
MODEL_PATH = "server-ia/data/modeles/CV2/trainner.yml"
|
||||||
|
LABELS_PATH = "server-ia/data/modeles/CV2/labels.pickle"
|
||||||
|
|
||||||
|
face_cascade = cv2.CascadeClassifier(FACE_CASCADE_PATH)
|
||||||
|
recognizer = cv2.face.LBPHFaceRecognizer_create()
|
||||||
|
recognizer.read(MODEL_PATH)
|
||||||
|
|
||||||
|
# Chargement des labels
|
||||||
|
with open(LABELS_PATH, "rb") as f:
|
||||||
|
og_labels = pickle.load(f)
|
||||||
|
labels = {v: k for k, v in og_labels.items()}
|
||||||
|
|
||||||
|
# Initialisation de la capture vidéo
|
||||||
|
#cap = cv2.VideoCapture(0)
|
||||||
|
cap = cv2.VideoCapture("http://192.168.253.194:8081")
|
||||||
|
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
|
||||||
|
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
|
||||||
|
|
||||||
|
def calculate_sharpness(image):
|
||||||
|
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
||||||
|
variance = cv2.Laplacian(gray, cv2.CV_64F).var()
|
||||||
|
return variance
|
||||||
|
|
||||||
|
def process_frame(frame):
|
||||||
|
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
||||||
|
faces = face_cascade.detectMultiScale(gray, scaleFactor=1.2, minNeighbors=4, minSize=(MIN_SIZE, MIN_SIZE))
|
||||||
|
|
||||||
|
for (x, y, w, h) in faces:
|
||||||
|
roi_gray = gray[y:y+h, x:x+w]
|
||||||
|
id_, conf = recognizer.predict(roi_gray)
|
||||||
|
|
||||||
|
if conf <= 95:
|
||||||
|
color = COLOR_OK
|
||||||
|
name = labels.get(id_, "Inconnu")
|
||||||
|
else:
|
||||||
|
color = COLOR_KO
|
||||||
|
name = "Inconnu"
|
||||||
|
|
||||||
|
label = f"{name} {conf:.2f}"
|
||||||
|
cv2.putText(frame, label, (x, y-10), cv2.FONT_HERSHEY_DUPLEX, 1, COLOR_INFO, 1, cv2.LINE_AA)
|
||||||
|
cv2.rectangle(frame, (x, y), (x+w, y+h), color, 2)
|
||||||
|
|
||||||
|
# Afficher la résolution actuelle
|
||||||
|
resolution_text = f"Resolution: {frame.shape[1]}x{frame.shape[0]}"
|
||||||
|
cv2.putText(frame, resolution_text, (10, frame.shape[0] - 40), cv2.FONT_HERSHEY_SIMPLEX, 0.6, COLOR_INFO, 1, cv2.LINE_AA)
|
||||||
|
|
||||||
|
# Calculer et afficher la netteté
|
||||||
|
sharpness = calculate_sharpness(frame)
|
||||||
|
sharpness_text = f"Sharpness: {sharpness:.2f}"
|
||||||
|
cv2.putText(frame, sharpness_text, (10, frame.shape[0] - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.6, COLOR_INFO, 1, cv2.LINE_AA)
|
||||||
|
|
||||||
|
return frame
|
||||||
|
|
||||||
|
def main():
|
||||||
|
prev_time = time.time()
|
||||||
|
while True:
|
||||||
|
ret, frame = cap.read()
|
||||||
|
if not ret:
|
||||||
|
print("Erreur lors de la capture de la vidéo.")
|
||||||
|
break
|
||||||
|
|
||||||
|
frame = process_frame(frame)
|
||||||
|
|
||||||
|
# Calculer et afficher le FPS
|
||||||
|
curr_time = time.time()
|
||||||
|
fps = 1 / (curr_time - prev_time)
|
||||||
|
prev_time = curr_time
|
||||||
|
|
||||||
|
fps_text = f"FPS: {fps:.2f}"
|
||||||
|
cv2.putText(frame, fps_text, (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 0.6, COLOR_INFO, 1, cv2.LINE_AA)
|
||||||
|
|
||||||
|
# Redimensionner la frame pour l'affichage
|
||||||
|
frame_resized = cv2.resize(frame, (int(frame.shape[1] * SCALE_FACTOR), int(frame.shape[0] * SCALE_FACTOR)))
|
||||||
|
cv2.imshow('CARIA Project - Identification du client', frame_resized)
|
||||||
|
|
||||||
|
key = cv2.waitKey(1) & 0xFF
|
||||||
|
if key == ord('q'):
|
||||||
|
break
|
||||||
|
elif key == ord('a'):
|
||||||
|
# Capture 50 frames to avoid blocking
|
||||||
|
for _ in range(50):
|
||||||
|
ret, _ = cap.read()
|
||||||
|
if not ret:
|
||||||
|
break
|
||||||
|
|
||||||
|
cap.release()
|
||||||
|
cv2.destroyAllWindows()
|
||||||
|
print("Fin")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
172
server-ia/test_cv2_ligne_detection.py
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
import cv2
|
||||||
|
import numpy as np
|
||||||
|
import time
|
||||||
|
|
||||||
|
# Initialisation des variables
|
||||||
|
th1 = 75
|
||||||
|
th2 = 150
|
||||||
|
k = 3
|
||||||
|
stop = 0
|
||||||
|
|
||||||
|
# Coordonnées des zones d'intérêt pour le traitement
|
||||||
|
ymin = 350
|
||||||
|
ymax = 351
|
||||||
|
xmin1 = 30
|
||||||
|
xmax1 = 130
|
||||||
|
xmin2 = 520
|
||||||
|
xmax2 = 620
|
||||||
|
|
||||||
|
# Fonction pour déterminer le point central des contours détectés
|
||||||
|
def point(capteur):
|
||||||
|
s1 = len(capteur) - 1
|
||||||
|
s2 = len(capteur) - 1
|
||||||
|
for i in range(len(capteur)):
|
||||||
|
if capteur[i] != 0:
|
||||||
|
s1 = i
|
||||||
|
break
|
||||||
|
if s1 != len(capteur) - 1:
|
||||||
|
for i in range(len(capteur) - 1, s1 - 1, -1):
|
||||||
|
if capteur[i] != 0:
|
||||||
|
s2 = i
|
||||||
|
break
|
||||||
|
return int((s1 + s2) / 2)
|
||||||
|
return -1
|
||||||
|
|
||||||
|
# Variables pour suivre les positions précédentes et le temps
|
||||||
|
s1_old = 0
|
||||||
|
s2_old = 0
|
||||||
|
s1_time = 0
|
||||||
|
s2_time = 0
|
||||||
|
|
||||||
|
# Capture vidéo
|
||||||
|
# cap = cv2.VideoCapture(0)
|
||||||
|
cap = cv2.VideoCapture("http://192.168.253.194:8081")
|
||||||
|
|
||||||
|
while True:
|
||||||
|
if not stop:
|
||||||
|
ret, frame = cap.read()
|
||||||
|
if not ret:
|
||||||
|
break
|
||||||
|
image = frame.copy()
|
||||||
|
|
||||||
|
# Détection de contours dans les zones d'intérêt
|
||||||
|
gray1 = cv2.cvtColor(frame[ymin:ymax, xmin1:xmax1], cv2.COLOR_BGR2GRAY)
|
||||||
|
gray2 = cv2.cvtColor(frame[ymin:ymax, xmin2:xmax2], cv2.COLOR_BGR2GRAY)
|
||||||
|
|
||||||
|
if k != 1:
|
||||||
|
gray1 = cv2.blur(gray1, (k, k))
|
||||||
|
gray2 = cv2.blur(gray2, (k, k))
|
||||||
|
|
||||||
|
capteur1 = cv2.Canny(gray1, th1, th2)
|
||||||
|
capteur2 = cv2.Canny(gray2, th1, th2)
|
||||||
|
|
||||||
|
cv2.rectangle(image, (xmin1, ymin), (xmax1, ymax), (0, 0, 255), 1)
|
||||||
|
cv2.rectangle(image, (xmin2, ymin), (xmax2, ymax), (0, 0, 255), 1)
|
||||||
|
|
||||||
|
# Calcul du point central des contours détectés
|
||||||
|
s1 = point(capteur1[0])
|
||||||
|
s2 = point(capteur2[0])
|
||||||
|
|
||||||
|
if s1 != -1:
|
||||||
|
cv2.circle(image, (s1 + xmin1, ymin), 3, (0, 255, 0), 3)
|
||||||
|
s1_old = s1
|
||||||
|
s1_time = time.time()
|
||||||
|
else:
|
||||||
|
if time.time() - s1_time < 1:
|
||||||
|
cv2.circle(image, (s1_old + xmin1, ymin), 3, (100, 255, 255), 3)
|
||||||
|
s1 = s1_old
|
||||||
|
else:
|
||||||
|
s1 = -1
|
||||||
|
|
||||||
|
if s2 != -1:
|
||||||
|
cv2.circle(image, (s2 + xmin2, ymin), 3, (0, 255, 0), 3)
|
||||||
|
s2_old = s2
|
||||||
|
s2_time = time.time()
|
||||||
|
else:
|
||||||
|
if time.time() - s2_time < 1:
|
||||||
|
cv2.circle(image, (s2_old + xmin2, ymin), 3, (100, 255, 255), 3)
|
||||||
|
s2 = s2_old
|
||||||
|
else:
|
||||||
|
s2 = -1
|
||||||
|
|
||||||
|
# Affichage de l'état de l'alignement
|
||||||
|
if s1 != -1 and s2 != -1:
|
||||||
|
s2_ = abs(xmax2 - xmin2 - s2)
|
||||||
|
if abs(s2_ - s1) > 20:
|
||||||
|
c = (0, max(0, 255 - 10 * int(abs(s1 - s2_) / 2)), min(255, 10 * int(abs(s1 - s2_) / 2)))
|
||||||
|
cv2.circle(image, (int((xmax2 - xmin1) / 2) + xmin1, ymax - 25), 5, c, 7)
|
||||||
|
cv2.arrowedLine(image, (int((xmax2 - xmin1) / 2) + xmin1, ymax - 25),
|
||||||
|
(int((xmax2 - xmin1) / 2) + xmin1 + 2 * int((s1 - s2_) / 2), ymax - 25),
|
||||||
|
c, 3, tipLength=0.4)
|
||||||
|
else:
|
||||||
|
cv2.putText(image, "OK", (int((xmax2 - xmin1) / 2) + xmin1 - 15, ymax - 16),
|
||||||
|
cv2.FONT_HERSHEY_COMPLEX_SMALL, 1, (0, 255, 0), 1)
|
||||||
|
|
||||||
|
# Affichage des images dans des fenêtres distinctes
|
||||||
|
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
|
||||||
|
if k != 1:
|
||||||
|
gray = cv2.blur(gray, (k, k))
|
||||||
|
gray_canny = cv2.Canny(gray, th1, th2)
|
||||||
|
|
||||||
|
# Superposition des commandes après tous les traitements
|
||||||
|
cv2.putText(image, "[u|j]th1: {:d} [i|k]th2: {:d} [y|h]blur: {:d}".format(th1, th2, k),
|
||||||
|
(10, 40), cv2.FONT_HERSHEY_COMPLEX_SMALL, 1, (0, 255, 255), 2)
|
||||||
|
cv2.putText(image, "[a]>> [s]stop [q]quit", (10, 70), cv2.FONT_HERSHEY_COMPLEX_SMALL, 1, (0, 255, 255), 2)
|
||||||
|
|
||||||
|
# Affichage des fenêtres d'image
|
||||||
|
cv2.imshow("image", image)
|
||||||
|
cv2.imshow("blur", gray)
|
||||||
|
cv2.imshow("canny", gray_canny)
|
||||||
|
|
||||||
|
# Gestion des événements clavier
|
||||||
|
if not stop:
|
||||||
|
key = cv2.waitKey(20) & 0xFF
|
||||||
|
else:
|
||||||
|
key = cv2.waitKey()
|
||||||
|
|
||||||
|
if key == ord('q'):
|
||||||
|
break
|
||||||
|
if key == ord('s'):
|
||||||
|
stop = not stop
|
||||||
|
if key == ord('a'):
|
||||||
|
for cpt in range(200):
|
||||||
|
ret, frame = cap.read()
|
||||||
|
if not ret:
|
||||||
|
break
|
||||||
|
image = frame.copy()
|
||||||
|
|
||||||
|
# Contrôle des paramètres de seuil et de flou
|
||||||
|
if key == ord('y'):
|
||||||
|
k = min(255, k + 2)
|
||||||
|
if key == ord('h'):
|
||||||
|
k = max(1, k - 2)
|
||||||
|
if key == ord('u'):
|
||||||
|
th1 = min(255, th1 + 1)
|
||||||
|
if key == ord('j'):
|
||||||
|
th1 = max(0, th1 - 1)
|
||||||
|
if key == ord('i'):
|
||||||
|
th2 = min(255, th2 + 1)
|
||||||
|
if key == ord('k'):
|
||||||
|
th2 = max(0, th2 - 1)
|
||||||
|
|
||||||
|
# Déplacement des zones d'intérêt
|
||||||
|
if key == ord('m'):
|
||||||
|
ymin += 1
|
||||||
|
ymax += 1
|
||||||
|
if key == ord('p'):
|
||||||
|
ymin -= 1
|
||||||
|
ymax -= 1
|
||||||
|
if key == ord('o'):
|
||||||
|
xmin1 += 1
|
||||||
|
xmax1 += 1
|
||||||
|
xmin2 += 1
|
||||||
|
xmax2 += 1
|
||||||
|
if key == ord('l'):
|
||||||
|
xmin1 -= 1
|
||||||
|
xmax1 -= 1
|
||||||
|
xmin2 -= 1
|
||||||
|
xmax2 -= 1
|
||||||
|
|
||||||
|
# Libération des ressources
|
||||||
|
cap.release()
|
||||||
|
cv2.destroyAllWindows()
|
||||||
@@ -74,5 +74,5 @@ for i in indices:
|
|||||||
cv2.imshow("object detection", image)
|
cv2.imshow("object detection", image)
|
||||||
cv2.waitKey()
|
cv2.waitKey()
|
||||||
|
|
||||||
cv2.imwrite("object-detection.jpg", image)
|
# cv2.imwrite("object-detection.jpg", image)
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||