YAD2K
YAD2K copied to clipboard
Add tiny yolo model body, but cannot retrain
Hey,
I am trying to retrain tiny YOLO to predict traffic signs using gtsdb. I have finished the tiny YOLO body, but when I followed the instructions to retrain the model, I got "Incompatible shapes" in yolo_loss. Here is the command to replicate the issue. And the npz data file is shared here, and the class file is shared here. Note, there is loads of code duplication right now, but after debugging I will clean up.
retrain_tiny_yolo.py --data_path "my_dataset.npz" --classes_path "gtsdb_classes.txt"
Train on 666 samples, validate on 75 samples Epoch 1/5 Traceback (most recent call last): File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1323, in _do_call return fn(*args) File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1302, in _run_fn status, run_metadata) File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 473, in exit c_api.TF_GetCode(self.status.status)) tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [32,13,13,5,1] vs. [32,6,6,5,1] [[Node: yolo_loss/mul_8 = Mul[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](yolo_loss/mul_7, yolo_loss/Square_2)]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "retrain_tiny_yolo.py", line 356, in
Caused by op 'yolo_loss/mul_8', defined at:
File "retrain_tiny_yolo.py", line 356, in
InvalidArgumentError (see above for traceback): Incompatible shapes: [32,13,13,5,1] vs. [32,6,6,5,1] [[Node: yolo_loss/mul_8 = Mul[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](yolo_loss/mul_7, yolo_loss/Square_2)]]
I know it's been a while, but the Theano support branch supports loading the tiny yolo darknet model and retraining.
I know it's been a while, but your problem is related to your re-implementation of TinyYolo.
Your darknet should be :
def darknetref_body():
"""Generate first 8 conv layers of Darknet-Ref."""
return compose(
DarknetConv2D_BN_Leaky(16, (3, 3)),
MaxPooling2D(),
DarknetConv2D_BN_Leaky(32, (3, 3)),
MaxPooling2D(),
DarknetConv2D_BN_Leaky(64, (3, 3)),
MaxPooling2D(),
DarknetConv2D_BN_Leaky(128, (3, 3)),
MaxPooling2D(),
DarknetConv2D_BN_Leaky(256, (3, 3)),
MaxPooling2D(),
DarknetConv2D_BN_Leaky(512, (3, 3)),
MaxPooling2D(strides=1, padding='same'),
DarknetConv2D_BN_Leaky(1024, (3, 3)),
DarknetConv2D_BN_Leaky(512, (3, 3))
)