question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DeepFace.verify fails when using DeepId

See original GitHub issue

For 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:closed
  • Created 2 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
serengilcommented, Jul 17, 2021

I am using tensorflow==2.2.0, could you downgrade your environment?

0reactions
serengilcommented, Jul 27, 2021

I updated the source code. I’m going to publish it in pip soon.

	if tf_major_version == 2 and tf_minor_version >= 5:
		x = input_shape[0]; y = input_shape[1]
		input_shape = (y, x)
         else:
                input_shape = (x, y)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Deepface high distance rate reason · Issue #326 - GitHub
I try to use Deepface for face recognition project and I always got a high ... DeepID: {'verified': False, 'distance': 0.13006360093034186, ...
Read more >
OSError: [Errno 22] Invalid argument in deepface used in flask
I am building a face recognition system using the deepface framework and I got the below error I don't seem to know what...
Read more >
Face Recognition with DeepID in Keras - Sefik Ilkin Serengil
My experiments show that the following threshold values perform well to verify image pairs.
Read more >
DeepFace - Most Popular Deep Face Recognition in 2022 ...
The DeepID face verification algorithm performs face recognition based on deep learning. It was one of the first models using convolutional neural networks...
Read more >
A summary of deep models for face recognition
view Face Detection Using Deep Convolutional Neural Networks." arXiv ... Deep face recognition. 1.DeepID. 2.DeepID2. 3.DeepID2+. 4.DeepID3. 5.DeepFace.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found