Hi,
I’m getting the following error when running the yolo_eval function. Does someone know how to solve this?
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-26-14e5cd22cb79> in <module>
5 tf.random.normal([19, 19, 5, 1], mean=1, stddev=4, seed = 1),
6 tf.random.normal([19, 19, 5, 80], mean=1, stddev=4, seed = 1))
----> 7 scores, boxes, classes = yolo_eval(yolo_outputs)
8 print("scores[2] = " + str(scores[2].numpy()))
9 print("boxes[2] = " + str(boxes[2].numpy()))
<ipython-input-25-a0575d2c92bd> in yolo_eval(yolo_outputs, image_shape, max_boxes, score_threshold, iou_threshold)
31
32 # Use one of the functions you've implemented to perform Score-filtering with a threshold of score_threshold (≈1 line)
---> 33 scores, boxes, classes = yolo_non_max_suppression(boxes, box_confidence, box_class_probs, score_threshold)
34
35 # Scale boxes back to original image shape.
<ipython-input-18-8f7110a2511a> in yolo_non_max_suppression(scores, boxes, classes, max_boxes, iou_threshold)
22 """
23
---> 24 max_boxes_tensor = tf.Variable(max_boxes, dtype='int32') # tensor to be used in tf.image.non_max_suppression()
25
26 ### START CODE HERE
/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/variables.py in __call__(cls, *args, **kwargs)
260 return cls._variable_v1_call(*args, **kwargs)
261 elif cls is Variable:
--> 262 return cls._variable_v2_call(*args, **kwargs)
263 else:
264 return super(VariableMetaclass, cls).__call__(*args, **kwargs)
/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/variables.py in _variable_v2_call(cls, initial_value, trainable, validate_shape, caching_device, name, variable_def, dtype, import_scope, constraint, synchronization, aggregation, shape)
254 synchronization=synchronization,
255 aggregation=aggregation,
--> 256 shape=shape)
257
258 def __call__(cls, *args, **kwargs):
/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/variables.py in <lambda>(**kws)
235 shape=None):
236 """Call on Variable class. Useful to force the signature."""
--> 237 previous_getter = lambda **kws: default_variable_creator_v2(None, **kws)
238 for _, getter in ops.get_default_graph()._variable_creator_stack: # pylint: disable=protected-access
239 previous_getter = _make_getter(getter, previous_getter)
/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/variable_scope.py in default_variable_creator_v2(next_creator, **kwargs)
2644 synchronization=synchronization,
2645 aggregation=aggregation,
-> 2646 shape=shape)
2647
2648
/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/variables.py in __call__(cls, *args, **kwargs)
262 return cls._variable_v2_call(*args, **kwargs)
263 else:
--> 264 return super(VariableMetaclass, cls).__call__(*args, **kwargs)
265
266
/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/resource_variable_ops.py in __init__(self, initial_value, trainable, collections, validate_shape, caching_device, name, dtype, variable_def, import_scope, constraint, distribute_strategy, synchronization, aggregation, shape)
1516 aggregation=aggregation,
1517 shape=shape,
-> 1518 distribute_strategy=distribute_strategy)
1519
1520 def _init_from_args(self,
/opt/conda/lib/python3.7/site-packages/tensorflow/python/ops/resource_variable_ops.py in _init_from_args(self, initial_value, trainable, collections, caching_device, name, dtype, constraint, synchronization, aggregation, distribute_strategy, shape)
1650 initial_value = ops.convert_to_tensor(
1651 initial_value() if init_from_fn else initial_value,
-> 1652 name="initial_value", dtype=dtype)
1653 if shape is not None:
1654 if not initial_value.shape.is_compatible_with(shape):
/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in convert_to_tensor(value, dtype, name, as_ref, preferred_dtype, dtype_hint, ctx, accepted_result_types)
1497
1498 if ret is None:
-> 1499 ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
1500
1501 if ret is NotImplemented:
/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/tensor_conversion_registry.py in _default_conversion_function(***failed resolving arguments***)
50 def _default_conversion_function(value, dtype, name, as_ref):
51 del as_ref # Unused.
---> 52 return constant_op.constant(value, dtype, name=name)
53
54
/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/constant_op.py in constant(value, dtype, shape, name)
262 """
263 return _constant_impl(value, dtype, shape, name, verify_shape=False,
--> 264 allow_broadcast=True)
265
266
/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/constant_op.py in _constant_impl(value, dtype, shape, name, verify_shape, allow_broadcast)
273 with trace.Trace("tf.constant"):
274 return _constant_eager_impl(ctx, value, dtype, shape, verify_shape)
--> 275 return _constant_eager_impl(ctx, value, dtype, shape, verify_shape)
276
277 g = ops.get_default_graph()
/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/constant_op.py in _constant_eager_impl(ctx, value, dtype, shape, verify_shape)
298 def _constant_eager_impl(ctx, value, dtype, shape, verify_shape):
299 """Implementation of eager constant."""
--> 300 t = convert_to_eager_tensor(value, ctx, dtype)
301 if shape is None:
302 return t
/opt/conda/lib/python3.7/site-packages/tensorflow/python/framework/constant_op.py in convert_to_eager_tensor(value, ctx, dtype)
96 dtype = dtypes.as_dtype(dtype).as_datatype_enum
97 ctx.ensure_initialized()
---> 98 return ops.EagerTensor(value, ctx.device_name, dtype)
99
100
TypeError: Cannot convert 0.6 to EagerTensor of dtype int32