'list' object has no attribute 'dtype' having this error when I implemented car detection model by andrew N.G

850 Views Asked by At
AttributeError                            Traceback (most recent call last)
<ipython-input-74-d69bb71a2d56> in <module>
----> 1 yolo_outputs = yolo_head(yolo_model.output, anchors,len(class_names))

~\Autonomous driving system\yad2k\models\keras_yolo.py in yolo_head(feats,anchors, num_classes)
    106     conv_width_index = K.flatten(K.transpose(conv_width_index))
    107     conv_index = K.transpose(K.stack([conv_height_index, conv_width_index]))
--> 108     conv_index = K.reshape(conv_index, [1, conv_dims[0], conv_dims[1], 1, 2])
    109     conv_index = K.cast(conv_index, K.dtype(feats))
    110 

c:\users\91884\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\util\dispatch.py in wrapper(*args, **kwargs)

c:\users\91884\appdata\local\programs\python\python37\lib\site-packages\tensorflow\python\keras\backend.py in dtype(x)

AttributeError: 'list' object has no attribute 'dtype'

I tried to uninstall my tensorflow==2.3.1 and installed tensorflow==1.15 But the problem didn't solve .Is it because of tensorflow version or there is some error in code or is it because of yolo.h5 file.

1

There are 1 best solutions below

0
On

It is not related to the Tensorflow version,it simply due to the second argument in the line :

conv_index = K.reshape(conv_index, [1, conv_dims[0], conv_dims[1], 1, 2])

you have to convert the list to tensor .e.g:

conv_index = K.reshape(conv_index, tf.constant([[1, conv_dims[0], conv_dims[1]), 1, 2]])