PyTorch-YOLOv3 icon indicating copy to clipboard operation
PyTorch-YOLOv3 copied to clipboard

Modify YOLOv3 backbone from DarkNet to AdderNet

Open buttercutter opened this issue 5 years ago • 17 comments

How to correctly modify https://github.com/eriklindernoren/PyTorch-YOLOv3 to use https://github.com/huawei-noah/AdderNet ?

The following colab ipynb notebook is what I have so far with the helps of others:

https://colab.research.google.com/drive/1VCafwykgNKAO6144LssBFFy0TmruDNSE#scrollTo=W3e-WcVxnKfs

How to solve the error on this models.py file ?

addernet_error

Namespace(batch_size=8, class_path='data/coco.names', conf_thres=0.001, data_config='config/coco.data', img_size=416, iou_thres=0.5, model_def='config/yolov3.cfg', n_cpu=8, nms_thres=0.5, weights_path='weights/yolov3.weights')
Traceback (most recent call last):
  File "test.py", line 84, in <module>
    model.load_darknet_weights(opt.weights_path)
  File "/content/PyTorch-YOLOv3/models.py", line 321, in load_darknet_weights
    num_w = conv_layer.weight.numel()
  File "/usr/local/lib/python3.6/dist-packages/torch/nn/modules/module.py", line 576, in __getattr__
    type(self).__name__, name))
AttributeError: 'adder2d' object has no attribute 'weight'

buttercutter avatar Apr 10 '20 15:04 buttercutter

I have solved the above compilation error.

However, why training train.py always stop at epoch 0 ?

yolo_addernet_epoch_0

buttercutter avatar Apr 13 '20 07:04 buttercutter

I have solved the epoch 0 issue by using the advice given at https://github.com/huawei-noah/AdderNet/issues/16#issuecomment-612288299

See the latest ipynb file

However, I am still stuck at how the image dataloader works.

Note : I have already ran voc_label.py

yolov3_dataloader_error

buttercutter avatar Apr 13 '20 12:04 buttercutter

batch_size=4???

dabblle avatar Apr 14 '20 12:04 dabblle

@dabblle See https://github.com/huawei-noah/AdderNet/issues/6#issuecomment-613362421 in which I am trying to reduce the GPU memory usage footprint.

buttercutter avatar Apr 14 '20 12:04 buttercutter

Check your resources of cpu???

dabblle avatar Apr 14 '20 13:04 dabblle

@dabblle I am asking about reducing GPU memory usage, not CPU resource usage. Or did I miss anything ?

buttercutter avatar Apr 14 '20 14:04 buttercutter

Hello,Promach .This is problem 'adder2d' object has no attribute 'weight',I changed the class adder2d init method and self.weight = torch.nn.Parameter(nn.init.normal_(torch.randn(output_channel,input_channel,kernel_size,kernel_size)))But it reported an error "bool' object has no attribute 'numel"

summeryumyee avatar Apr 18 '20 06:04 summeryumyee

Using yolov3-tiny.cfg also does not help in solving GPU out-of-memory issue.

Any advices ?

buttercutter avatar Apr 18 '20 11:04 buttercutter

@dabblle See https://github.com/eriklindernoren/PyTorch-YOLOv3/issues/58#issuecomment-616986029

buttercutter avatar Apr 21 '20 07:04 buttercutter

sorry,i don't know

dabblle avatar Apr 24 '20 09:04 dabblle

It seems like _temp1 = torch.unsqueeze(X, 2).expand(X.shape[0], X.shape[1], W.shape[0]).permute(1, 0, 2) in back-propagation equation of AdderNet had caused the surge in GPU memory usage.

I was told to either

  1. decrease the tensors dimension, then increase the tensors dimension again or
  2. increase the tensors dimensions and then use depth-wise convolution or
  3. use mixed-precision training

I know I can use https://github.com/NVIDIA/apex for the mixed precision training. However, I am not sure how to modify the code for suggestions 1 and 2 above.

buttercutter avatar Apr 24 '20 09:04 buttercutter

Sorry, I don't have any good advice for you。 maybe,you can try half-precision。 good luck!!

dabblle avatar Apr 24 '20 10:04 dabblle

@promach how did you solve the first issue?

Meriem-Bouagila avatar May 02 '20 15:05 Meriem-Bouagila

@Meriem-Bouagila See https://github.com/promach/PyTorch-YOLOv3/blob/addernet/adder.py

buttercutter avatar May 02 '20 15:05 buttercutter

@promach with any version of Python did you work please?

Meriem-Bouagila avatar May 02 '20 16:05 Meriem-Bouagila

@Meriem-Bouagila See https://github.com/huawei-noah/AdderNet/issues/16#issuecomment-623064131

buttercutter avatar May 03 '20 06:05 buttercutter

VOC2007 is not the default dataset for YOLOv3, do I need to re-create new anchors ?

buttercutter avatar Jun 24 '20 12:06 buttercutter