xuannianz / EfficientDet

EfficientDet (Scalable and Efficient Object Detection) implementation in Keras and Tensorflow
Apache License 2.0
1.39k stars 395 forks source link

ValueError: Unexpectedly found an instance of type `<class 'keras.engine.keras_tensor.KerasTensor'>`. Expected a symbolic tensor instance. #270

Open hmoghimifam opened 1 year ago

hmoghimifam commented 1 year ago

Traceback (most recent call last): File "/home/wolverine/Documents/git/EfficientDet/inference.py", line 62, in <module> main() File "/home/wolverine/Documents/git/EfficientDet/inference.py", line 29, in main score_threshold=score_threshold) File "/home/wolverine/Documents/git/EfficientDet/model.py", line 430, in efficientdet features = backbone_cls(input_tensor=image_input, freeze_bn=freeze_bn) File "/home/wolverine/Documents/git/EfficientDet/utils/__init__.py", line 45, in wrapper return func(*args, **kwargs) File "/home/wolverine/Documents/git/EfficientDet/efficientnet.py", line 475, in EfficientNetB1 **kwargs) File "/home/wolverine/Documents/git/EfficientDet/efficientnet.py", line 382, in EfficientNet if not is_keras_tensor(input_tensor): File "/home/wolverine/anaconda3/envs/py37/lib/python3.7/site-packages/tensorflow/python/keras/backend.py", line 1282, in is_keras_tensor '. Expected a symbolic tensor instance.') ValueError: Unexpectedly found an instance of type <class 'keras.engine.keras_tensor.KerasTensor'>. Expected a symbolic tensor instance.`

I keep getting the following error whether I try inference or training. I tried uncommenting import keras and import tensorflow parts but it didn't help. I'm using tensorflow 2.9.2

YuraLi88 commented 1 year ago

The best way to solve the issue is to downgrade your TF version. Use the appropriate docker image for the environment isolation. For example, TF 2.2.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

AbhinavGopal commented 1 year ago

With tf 2.2, the following error appears:

` /home/abhinavg/EfficientDet/layers.py:302 _filterdetections * ratios, /home/abhinavg/EfficientDet/layers.py:197 filter_detections labels = c tf.ones((keras.backend.shape(scores)[0],), dtype='int64') /home/abhinavg/.local/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py:2967 ones ** output = _constant_if_small(one, shape, dtype, name) /home/abhinavg/.local/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py:2662 _constant_if_small if np.prod(shape) < 1000:

<__array_function__ internals>:6 prod /home/abhinavg/.local/lib/python3.7/site-packages/numpy/core/fromnumeric.py:3052 prod keepdims=keepdims, initial=initial, where=where) /home/abhinavg/.local/lib/python3.7/site-packages/numpy/core/fromnumeric.py:86 _wrapreduction return ufunc.reduce(obj, axis, dtype, out, **passkwargs) /home/abhinavg/.local/lib/python3.7/site-packages/tensorflow/python/framework/ops.py:749 __array__ " array.".format(self.name)) NotImplementedError: Cannot convert a symbolic Tensor (strided_slice_1:0) to a numpy array.` I basically did a tf-gpu2.2 installation, then deleted the tf requirement from requirements.txt, and then did pip3 install -r requirements.txt