Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize MTCNN with ValueError #90

Open
freddie0216 opened this issue May 1, 2020 · 0 comments
Open

Initialize MTCNN with ValueError #90

freddie0216 opened this issue May 1, 2020 · 0 comments

Comments

@freddie0216
Copy link

System information
Python: 3.6.5
Numpy: 1.18.2
Tensorflow: 2.0.0

Describe the current behavior
I am trying to create an object of MTCNN with following code:
from mtcnn.mtcnn import MTCNN
detector = MTCNN()

But got error call stack like following:
ValueError Traceback (most recent call last)
in ()
1 from mtcnn.mtcnn import MTCNN
----> 2 detector = MTCNN()

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\mtcnn\mtcnn.py in init(self, weights_file, min_face_size, steps_threshold, scale_factor)
86 self._scale_factor = scale_factor
87
---> 88 self._pnet, self._rnet, self._onet = NetworkFactory().build_P_R_O_nets_from_file(weights_file)
89
90

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\mtcnn\network\factory.py in build_P_R_O_nets_from_file(self, weights_file)
122
123 p_net = self.build_pnet()
--> 124 r_net = self.build_rnet()
125 o_net = self.build_onet()
126

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\mtcnn\network\factory.py in build_rnet(self, input_shape)
74 r_layer = PReLU(shared_axes=[1, 2])(r_layer)
75 r_layer = Flatten()(r_layer)
---> 76 r_layer = Dense(128)(r_layer)
77 r_layer = PReLU()(r_layer)
78

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\keras\backend\tensorflow_backend.py in symbolic_fn_wrapper(*args, **kwargs)
73 if _SYMBOLIC_SCOPE.value:
74 with get_graph().as_default():
---> 75 return func(*args, **kwargs)
76 else:
77 return func(*args, **kwargs)

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\keras\engine\base_layer.py in call(self, inputs, **kwargs)
461 'You can build it manually via: '
462 'layer.build(batch_input_shape)')
--> 463 self.build(unpack_singleton(input_shapes))
464 self.built = True
465

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\keras\layers\core.py in build(self, input_shape)
893 name='kernel',
894 regularizer=self.kernel_regularizer,
--> 895 constraint=self.kernel_constraint)
896 if self.use_bias:
897 self.bias = self.add_weight(shape=(self.units,),

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\keras\engine\base_layer.py in add_weight(self, name, shape, dtype, initializer, regularizer, trainable, constraint)
277 if dtype is None:
278 dtype = self.dtype
--> 279 weight = K.variable(initializer(shape, dtype=dtype),
280 dtype=dtype,
281 name=name,

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\keras\initializers.py in call(self, shape, dtype)
225 limit = np.sqrt(3. * scale)
226 x = K.random_uniform(shape, -limit, limit,
--> 227 dtype=dtype, seed=self.seed)
228 if self.seed is not None:
229 self.seed += 1

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\keras\backend\tensorflow_backend.py in random_uniform(shape, minval, maxval, dtype, seed)
4355 with tf_ops.init_scope():
4356 return tf_keras_backend.random_uniform(
-> 4357 shape, minval=minval, maxval=maxval, dtype=dtype, seed=seed)
4358
4359

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tensorflow_core\python\keras\backend.py in random_uniform(shape, minval, maxval, dtype, seed)
5596 seed = np.random.randint(10e6)
5597 return random_ops.random_uniform(
-> 5598 shape, minval=minval, maxval=maxval, dtype=dtype, seed=seed)
5599
5600

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tensorflow_core\python\ops\random_ops.py in random_uniform(shape, minval, maxval, dtype, seed, name)
235 maxval = 1
236 with ops.name_scope(name, "random_uniform", [shape, minval, maxval]) as name:
--> 237 shape = tensor_util.shape_tensor(shape)
238 minval = ops.convert_to_tensor(minval, dtype=dtype, name="min")
239 maxval = ops.convert_to_tensor(maxval, dtype=dtype, name="max")

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tensorflow_core\python\framework\tensor_util.py in shape_tensor(shape)
962 # not convertible to Tensors becasue of mixed content.
963 shape = tuple(map(tensor_shape.dimension_value, shape))
--> 964 return ops.convert_to_tensor(shape, dtype=dtype, name="shape")
965
966

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tensorflow_core\python\framework\ops.py in convert_to_tensor(value, dtype, name, preferred_dtype, dtype_hint)
1182 preferred_dtype = deprecation.deprecated_argument_lookup(
1183 "dtype_hint", dtype_hint, "preferred_dtype", preferred_dtype)
-> 1184 return convert_to_tensor_v2(value, dtype, preferred_dtype, name)
1185
1186

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tensorflow_core\python\framework\ops.py in convert_to_tensor_v2(value, dtype, dtype_hint, name)
1240 name=name,
1241 preferred_dtype=dtype_hint,
-> 1242 as_ref=False)
1243
1244

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tensorflow_core\python\framework\ops.py in internal_convert_to_tensor(value, dtype, name, as_ref, preferred_dtype, ctx, accept_composite_tensors)
1294
1295 if ret is None:
-> 1296 ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
1297
1298 if ret is NotImplemented:

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tensorflow_core\python\framework\constant_op.py in _constant_tensor_conversion_function(v, dtype, name, as_ref)
284 as_ref=False):
285 _ = as_ref
--> 286 return constant(v, dtype=dtype, name=name)
287
288

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tensorflow_core\python\framework\constant_op.py in constant(value, dtype, shape, name)
225 """
226 return _constant_impl(value, dtype, shape, name, verify_shape=False,
--> 227 allow_broadcast=True)
228
229

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tensorflow_core\python\framework\constant_op.py in _constant_impl(value, dtype, shape, name, verify_shape, allow_broadcast)
233 ctx = context.context()
234 if ctx.executing_eagerly():
--> 235 t = convert_to_eager_tensor(value, ctx, dtype)
236 if shape is None:
237 return t

C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64\lib\site-packages\tensorflow_core\python\framework\constant_op.py in convert_to_eager_tensor(value, ctx, dtype)
94 dtype = dtypes.as_dtype(dtype).as_datatype_enum
95 ctx.ensure_initialized()
---> 96 return ops.EagerTensor(value, ctx.device_name, dtype)
97
98

ValueError: Attempt to convert a value (576) with an unsupported type () to a Tensor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant