84 lines
2.7 KiB
Python
84 lines
2.7 KiB
Python
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' } |