Tianxiaomo / pytorch-YOLOv4

PyTorch ,ONNX and TensorRT implementation of YOLOv4
Apache License 2.0
4.49k stars 1.49k forks source link

Runtime Error when use yolov4-tiny.cfg instead #361

Open ldfinfontainebleau opened 3 years ago

ldfinfontainebleau commented 3 years ago

Thank U for ur great job! I hand on this project this days and met one problem. '''Traceback (most recent call last): File "train.py", line 631, in device=device ) File "train.py", line 385, in train loss, loss_xy, loss_wh, loss_obj, loss_cls, loss_l2 = criterion(bboxes_pred, bboxes) File "/usr/local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 532, in call result = self.forward(*input, **kwargs) File "train.py", line 253, in forward pred[..., 0] += self.grid_x[output_id] RuntimeError: The size of tensor a (19) must match the size of tensor b (76) at non-singleton dimension 3'''

I run yolov4 fluently,but when I change yolov4.cfg into yolov4-tiny.cfg, I met this error. I have change image_size into 608 in yolov4-tiny.cfg, anchors and masks in Yolo_loss. Plz tell me how can I fix it.

AshikSaibabu commented 3 years ago

@ldfinfontainebleau Try changing self.strides = [8, 16, 32] to self.strides = [32, 16] in the "Yolo_loss" class.

EdwardChiang commented 3 years ago

And remember to replace the line from for i in range(3): to for i in range(len(self.strides)):