Skip to content

Commit fb7e7d2

Browse files
authored
Prevent NoneType return
1 parent 795087b commit fb7e7d2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Section #3 - Faces/faces_train.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ def create_train():
2121
img_path = os.path.join(path,img)
2222

2323
img_array = cv.imread(img_path)
24+
if img_array is None:
25+
continue
26+
2427
gray = cv.cvtColor(img_array, cv.COLOR_BGR2GRAY)
2528

2629
faces_rect = haar_cascade.detectMultiScale(gray, scaleFactor=1.1, minNeighbors=4)
@@ -43,4 +46,4 @@ def create_train():
4346

4447
face_recognizer.save('face_trained.yml')
4548
np.save('features.npy', features)
46-
np.save('labels.npy', labels)
49+
np.save('labels.npy', labels)

0 commit comments

Comments
 (0)