-
Notifications
You must be signed in to change notification settings - Fork 0
/
classify_images.py
61 lines (59 loc) · 1.56 KB
/
classify_images.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
from call_model import *
import os
class_name = ['Speed limit (20km/h)',
'Speed limit (30km/h)',
'No passing for vehicles over 3.5 metric tons',
'Right-of-way at the next intersection',
'Priority road',
'Yield',
'Stop',
'No vehicles',
'Vehicles over 3.5 metric tons prohibited',
'No entry',
'General caution',
'Dangerous curve to the left',
'Speed limit (50km/h)',
'Dangerous curve to the right',
'Double curve',
'Bumpy road',
'Slippery road',
'Road narrows on the right',
'Road work',
'Traffic signals',
'Pedestrians',
'Children crossing',
'Bicycles crossing',
'Speed limit (60km/h)',
'Beware of ice/snow',
'Wild animals crossing',
'End of all speed and passing limits',
'Turn right ahead',
'Turn left ahead',
'Ahead only',
'Go straight or right',
'Go straight or left',
'Keep right',
'Keep left',
'Speed limit (70km/h)',
'Roundabout mandatory',
'End of no passing',
'End of no passing by vehicles over 3.5 metric tons',
'Speed limit (80km/h)',
'End of speed limit (80km/h)',
'Speed limit (100km/h)',
'Speed limit (120km/h)',
'No passing'
]
# Enter path of folder to test
image_path = 'images\\original'
for root, dirs, files in os.walk(image_path):
model = load_model_weights("models/weights_cnn.hdf5")
WIDTH, HEIGHT = 32, 32
for i in range(len(files)):
path = image_path+"\\"+files[i]
img = image.load_img(path, target_size = (WIDTH, HEIGHT))
img = image.img_to_array(img)
img = np.expand_dims(img, axis = 0)
res = model.predict(img)
Ypred = np.argmax(res, axis=1)
print(class_name[Ypred[0]],"\t",files[i],"\t",Ypred[0])