diff --git a/deepface/DeepFace.py b/deepface/DeepFace.py index aaf09f8..ab7f8c4 100644 --- a/deepface/DeepFace.py +++ b/deepface/DeepFace.py @@ -91,7 +91,16 @@ def verify(img1_path, img2_path='' for i in model_names: custom_model = model[i] - input_shape = custom_model.layers[0].input_shape[1:3] + + #input_shape = custom_model.layers[0].input_shape[1:3] #my environment returns (None, 224, 224, 3) but some people mentioned that they got [(None, 224, 224, 3)]. I think this is because of version issue. + + input_shape = custom_model.layers[0].input_shape + + if type(input_shape) == list: + input_shape = input_shape[0][1:3] + else: + input_shape = input_shape[1:3] + img1 = functions.detectFace(img1_path, input_shape, enforce_detection = enforce_detection) img2 = functions.detectFace(img2_path, input_shape, enforce_detection = enforce_detection) @@ -207,7 +216,14 @@ def verify(img1_path, img2_path='' #------------------------------ #face recognition models have different size of inputs - input_shape = model.layers[0].input_shape[1:3] + #input_shape = model.layers[0].input_shape[1:3] #my environment returns (None, 224, 224, 3) but some people mentioned that they got [(None, 224, 224, 3)]. I think this is because of version issue. + + input_shape = model.layers[0].input_shape + + if type(input_shape) == list: + input_shape = input_shape[0][1:3] + else: + input_shape = input_shape[1:3] input_shape_x = input_shape[0] input_shape_y = input_shape[1] @@ -595,7 +611,15 @@ def find(img_path, db_path if model_name != 'Ensemble': - input_shape = model.layers[0].input_shape[1:3] + #input_shape = model.layers[0].input_shape[1:3] #my environment returns (None, 224, 224, 3) but some people mentioned that they got [(None, 224, 224, 3)]. I think this is because of version issue. + + input_shape = model.layers[0].input_shape + + if type(input_shape) == list: + input_shape = input_shape[0][1:3] + else: + input_shape = input_shape[1:3] + input_shape_x = input_shape[0]; input_shape_y = input_shape[1] img = functions.detectFace(employee, (input_shape_y, input_shape_x), enforce_detection = enforce_detection) @@ -612,7 +636,16 @@ def find(img_path, db_path for j in model_names: model = models[j] - input_shape = model.layers[0].input_shape[1:3] + + #input_shape = model.layers[0].input_shape[1:3] #my environment returns (None, 224, 224, 3) but some people mentioned that they got [(None, 224, 224, 3)]. I think this is because of version issue. + + input_shape = model.layers[0].input_shape + + if type(input_shape) == list: + input_shape = input_shape[0][1:3] + else: + input_shape = input_shape[1:3] + input_shape_x = input_shape[0]; input_shape_y = input_shape[1] img = functions.detectFace(employee, (input_shape_y, input_shape_x), enforce_detection = enforce_detection) @@ -650,7 +683,16 @@ def find(img_path, db_path if model_name == 'Ensemble': for j in model_names: model = models[j] - input_shape = model.layers[0].input_shape[1:3] + + #input_shape = model.layers[0].input_shape[1:3] #my environment returns (None, 224, 224, 3) but some people mentioned that they got [(None, 224, 224, 3)]. I think this is because of version issue. + + input_shape = model.layers[0].input_shape + + if type(input_shape) == list: + input_shape = input_shape[0][1:3] + else: + input_shape = input_shape[1:3] + img = functions.detectFace(img_path, input_shape, enforce_detection = enforce_detection) target_representation = model.predict(img)[0,:] @@ -719,7 +761,16 @@ def find(img_path, db_path #---------------------------------- if model_name != 'Ensemble': - input_shape = model.layers[0].input_shape[1:3] + + #input_shape = model.layers[0].input_shape[1:3] #my environment returns (None, 224, 224, 3) but some people mentioned that they got [(None, 224, 224, 3)]. I think this is because of version issue. + + input_shape = model.layers[0].input_shape + + if type(input_shape) == list: + input_shape = input_shape[0][1:3] + else: + input_shape = input_shape[1:3] + input_shape_x = input_shape[0]; input_shape_y = input_shape[1] img = functions.detectFace(img_path, (input_shape_y, input_shape_x), enforce_detection = enforce_detection)