ultralytics / yolov3

YOLOv3 in PyTorch > ONNX > CoreML > TFLite
https://docs.ultralytics.com
GNU Affero General Public License v3.0
10.22k stars 3.45k forks source link

AttributeError: 'YOLOLayer' object has no attribute 'grid' #1173

Closed jingweirobot closed 4 years ago

jingweirobot commented 4 years ago

python3 train.py --batch-size 8

Apex recommended for faster mixed precision training: https://github.com/NVIDIA/apex Your branch is behind 'origin/master' by 9 commits, and can be fast-forwarded. (use "git pull" to update your local branch)

Namespace(adam=False, batch_size=8, bucket='', cache_images=False, cfg='cfg/yolov3-spp.cfg', data='data/coco2017.data', device='', epochs=1, evolve=False, img_size=[320, 640], multi_scale=False, name='', nosave=False, notest=False, rect=False, resume=False, single_cls=False, weights='weights/yolov3-spp-ultralytics.pt') Using CPU

Start Tensorboard with "tensorboard --logdir=runs", view at http://localhost:6006/ Model Summary: 225 layers, 6.29987e+07 parameters, 6.29987e+07 gradients Optimizer groups: 76 .bias, 76 Conv2d.weight, 73 other Caching labels (117266 found, 1021 missing, 0 empty, 0 duplicate, for 118287 ima Caching labels (4952 found, 48 missing, 0 empty, 0 duplicate, for 5000 images): Image sizes 320 - 640 train, 640 test Using 8 dataloader workers Starting training for 1 epochs...

 Epoch   gpu_mem      GIoU       obj       cls     total   targets  img_size
   0/0        0G      1.95      1.66      0.37      3.98        79       512/home/jingwei/yolov3/utils/layers.py:60: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!

if nx == na: # same shape /home/jingwei/yolov3/models.py:187: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs! if (self.nx, self.ny) != (nx, ny): 0/0 0G 1.95 1.66 0.37 3.98 79 512 Traceback (most recent call last): File "train.py", line 416, in train() # train normally File "train.py", line 298, in train tb_writer.add_graph(model, imgs) # add model to tensorboard File "/home/jingwei/miniconda3/lib/python3.7/site-packages/torch/utils/tensorboard/writer.py", line 707, in add_graph self._get_file_writer().add_graph(graph(model, input_to_model, verbose)) File "/home/jingwei/miniconda3/lib/python3.7/site-packages/torch/utils/tensorboard/_pytorch_graph.py", line 285, in graph trace = torch.jit.trace(model, args) File "/home/jingwei/miniconda3/lib/python3.7/site-packages/torch/jit/init.py", line 882, in trace check_tolerance, _force_outplace, _module_class) File "/home/jingwei/miniconda3/lib/python3.7/site-packages/torch/jit/init.py", line 1034, in trace_module module._c._create_method_from_trace(method_name, func, example_inputs, var_lookup_fn, _force_outplace) File "/home/jingwei/miniconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 530, in call result = self._slow_forward(*input, kwargs) File "/home/jingwei/miniconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 516, in _slow_forward result = self.forward(*input, *kwargs) File "/home/jingwei/yolov3/models.py", line 238, in forward return self.forward_once(x) File "/home/jingwei/yolov3/models.py", line 290, in forward_once yolo_out.append(module(x, out)) File "/home/jingwei/miniconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 530, in call result = self._slow_forward(input, kwargs) File "/home/jingwei/miniconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 516, in _slow_forward result = self.forward(*input, **kwargs) File "/home/jingwei/yolov3/models.py", line 212, in forward io[..., :2] = torch.sigmoid(io[..., :2]) + self.grid # xy File "/home/jingwei/miniconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 576, in getattr type(self).name, name)) AttributeError: 'YOLOLayer' object has no attribute 'grid'

jingweirobot commented 4 years ago

there is self.training = False ( models.py ). 146 line. I found someone asked you this question. He/She set self.training = False ( models.py ). But it has still the same issue. Could you help me to solve this issue? Thanks a lot.

glenn-jocher commented 4 years ago

Hello, thank you for your interest in our work! This issue seems to lack the minimum requirements for a proper response, or is insufficiently detailed for us to help you. Please note that most technical problems are due to:

If none of these apply to you, we suggest you close this issue and raise a new one using the Bug Report template, providing screenshots and minimum viable code to reproduce your issue. Thank you!