DeepFace.verify fails when using DeepId
See original GitHub issueFor the same pair of images that passed the test when using ArcFace, VGG-Face, Dlib, Facenet, OpenFace, DeepFace fails when using DeepID.
obj = DeepFace.verify(img1_path, img2_path, model_name = ‘DeepID’) print(obj)
ValueError Traceback (most recent call last) <ipython-input-9-5c2f23b9a838> in <module> ----> 1 obj = DeepFace.verify(img1_path, img2_path, model_name = ‘DeepID’) 2 print(obj)
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/deepface/DeepFace.py in verify(img1_path, img2_path, model_name, distance_metric, model, enforce_detection, detector_backend, align) 157 158 #img_path, model_name = ‘VGG-Face’, model = None, enforce_detection = True, detector_backend = ‘mtcnn’ –> 159 img1_representation = represent(img_path = img1_path 160 , model_name = model_name, model = custom_model 161 , enforce_detection = enforce_detection, detector_backend = detector_backend
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/deepface/DeepFace.py in represent(img_path, model_name, model, enforce_detection, detector_backend, align) 737 738 #represent –> 739 embedding = model.predict(img)[0].tolist() 740 741 return embedding
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py in predict(self, x, batch_size, verbose, steps, callbacks, max_queue_size, workers, use_multiprocessing) 1725 for step in data_handler.steps(): 1726 callbacks.on_predict_batch_begin(step) -> 1727 tmp_batch_outputs = self.predict_function(iterator) 1728 if data_handler.should_sync: 1729 context.async_wait()
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py in call(self, *args, **kwds) 887 888 with OptionalXlaContext(self._jit_compile): –> 889 result = self._call(*args, **kwds) 890 891 new_tracing_count = self.experimental_get_tracing_count()
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py in _call(self, *args, **kwds) 931 # This is the first call of call, so we have to initialize. 932 initializers = [] –> 933 self._initialize(args, kwds, add_initializers_to=initializers) 934 finally: 935 # At this point we know that the initialization is complete (or less
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py in _initialize(self, args, kwds, add_initializers_to) 761 self._graph_deleter = FunctionDeleter(self._lifted_initializer_graph) 762 self._concrete_stateful_fn = ( –> 763 self._stateful_fn._get_concrete_function_internal_garbage_collected( # pylint: disable=protected-access 764 *args, **kwds)) 765
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/tensorflow/python/eager/function.py in _get_concrete_function_internal_garbage_collected(self, *args, **kwargs) 3048 args, kwargs = None, None 3049 with self._lock: -> 3050 graph_function, _ = self._maybe_define_function(args, kwargs) 3051 return graph_function 3052
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/tensorflow/python/eager/function.py in _maybe_define_function(self, args, kwargs) 3442 3443 self._function_cache.missed.add(call_context_key) -> 3444 graph_function = self._create_graph_function(args, kwargs) 3445 self._function_cache.primary[cache_key] = graph_function 3446
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/tensorflow/python/eager/function.py in _create_graph_function(self, args, kwargs, override_flat_arg_shapes) 3277 arg_names = base_arg_names + missing_arg_names 3278 graph_function = ConcreteFunction( -> 3279 func_graph_module.func_graph_from_py_func( 3280 self._name, 3281 self._python_function,
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/tensorflow/python/framework/func_graph.py in func_graph_from_py_func(name, python_func, args, kwargs, signature, func_graph, autograph, autograph_options, add_control_dependencies, arg_names, op_return_value, collections, capture_by_value, override_flat_arg_shapes)
997 _, original_func = tf_decorator.unwrap(python_func)
998
–> 999 func_outputs = python_func(*func_args, **func_kwargs)
1000
1001 # invariant: func_outputs
contains only Tensors, CompositeTensors,
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py in wrapped_fn(*args, **kwds) 670 # the function a weak reference to itself to avoid a reference cycle. 671 with OptionalXlaContext(compile_with_xla): –> 672 out = weak_wrapped_fn().wrapped(*args, **kwds) 673 return out 674
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/tensorflow/python/framework/func_graph.py in wrapper(*args, **kwargs) 984 except Exception as e: # pylint:disable=broad-except 985 if hasattr(e, “ag_error_metadata”): –> 986 raise e.ag_error_metadata.to_exception(e) 987 else: 988 raise
ValueError: in user code:
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:1569 predict_function *
return step_function(self, iterator)
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:1559 step_function **
outputs = model.distribute_strategy.run(run_step, args=(data,))
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/tensorflow/python/distribute/distribute_lib.py:1285 run
return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs)
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/tensorflow/python/distribute/distribute_lib.py:2833 call_for_each_replica
return self._call_for_each_replica(fn, args, kwargs)
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/tensorflow/python/distribute/distribute_lib.py:3608 _call_for_each_replica
return fn(*args, **kwargs)
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:1552 run_step **
outputs = model.predict_step(data)
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py:1525 predict_step
return self(x, training=False)
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/tensorflow/python/keras/engine/base_layer.py:1013 __call__
input_spec.assert_input_compatibility(self.input_spec, inputs, self.name)
/opt/anaconda/anaconda3/envs/tf/lib/python3.8/site-packages/tensorflow/python/keras/engine/input_spec.py:267 assert_input_compatibility
raise ValueError('Input ' + str(input_index) +
ValueError: Input 0 is incompatible with layer model_3: expected shape=(None, 55, 47, 3), found shape=(None, 47, 55, 3)
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
I am using tensorflow==2.2.0, could you downgrade your environment?
I updated the source code. I’m going to publish it in pip soon.