I want to crop and save images from all the dataset which contains multi classes. but there is no output. and thank you.
def detect_face(img):
detector = MTCNN()
faces = detector.detect_faces(image)
return faces
dataset = '/content/drive/MyDrive/data_LFW/'
for img in glob.glob(dataset+'/*.*'):
var_img = cv2.imread(img)
face = detect_face(var_img)
if (len(face) == 0):
continue
for(ex, ey, ew, eh) in face:
crop_image = var_img[ey:ey+eh, ex:ex+ew]
cv2.imwrite(os.path.join("/content/drive/MyDrive/data_crop",str(img)) ,crop_image)