Yolov5: ResNet-50 backbone config

Created on 29 Jul 2020  ·  16Comments  ·  Source: ultralytics/yolov5

Hi! thanks for sharing the wonderful yolov5 in pytorch, I'm wondering if you could share backbone configuration for resnet50, currently config only has CSP backbone:

backbone:
# [from, number, module, args]
[[-1, 1, Focus, [64, 3]], # 0-P1/2
[-1, 1, Conv, [128, 3, 2]], # 1-P2/4
[-1, 3, BottleneckCSP, [128]],
[-1, 1, Conv, [256, 3, 2]], # 3-P3/8
[-1, 9, BottleneckCSP, [256]],
[-1, 1, Conv, [512, 3, 2]], # 5-P4/16
[-1, 9, BottleneckCSP, [512]],
[-1, 1, Conv, [1024, 3, 2]], # 7-P5/32
[-1, 1, SPP, [1024, [5, 9, 13]]],
[-1, 3, BottleneckCSP, [1024, False]], # 9
]

Thank you.

Stale question

Most helpful comment

@xoryouyou I'm working on it atm but but due to my inexperience it takes some time. I'll let you know if I got something useful. In the meantime let me know if you got anything.

All 16 comments

@twangnh I don't have time or motivation to but we are open to PRs so feel free to submit one for this!

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@twangnh did you find a backbone config for resnet50?

@Shakesbeer333 you can build your own resnet50.yaml by using the existing ones as templates. The backbone section you'd modify is here:
https://github.com/ultralytics/yolov5/blob/187f7c2ed16b9eb9754b28e7b0aa397f908155aa/models/yolov5s.yaml#L12-L26

@glenn-jocher thank you. Any other section I need to change or to be aware of?

@Shakesbeer333 no just the model.yaml. You want to make a resnet50.yaml basically, with a resnet50 backbone and whatever head you want essentially.

You can use standard pytorch modules to create any architecture, i.e.:

# [from, number, module, args] 
[-1, 1, nn.Conv2d, [128, 3, 2]]
[-1, 1, nn.BatchNorm2d, [128]]
...

@glenn-jocher thanks once again. Can you briefly tell me what args[0], args[1], ... is or where I can find a description?

@Shakesbeer333 these are arguments you would pass to the module. i.e. nn.BatchNorm2d(128)

@glenn-jocher my question was a little bit vague. I retry:

[-1, 1, nn.Conv2d, [128, 3, 2] becomes torch.nn.modules.conv.Conv2d(c1=32, c2=64, k=3, s=2)

I don't understand how args[0] = 128 translates into c1=32, c2=64

@Shakesbeer333 YOLOv5 models are compound scaled in depth and width as shown in yaml comments:
https://github.com/ultralytics/yolov5/blob/187f7c2ed16b9eb9754b28e7b0aa397f908155aa/models/yolov5s.yaml#L1-L5

@glenn-jocher aweseome! Thank you so much for taking time to answer my questions! I really appreciate it

@Shakesbeer333 any success implementing a ResNet backbone ?

@xoryouyou I'm working on it atm but but due to my inexperience it takes some time. I'll let you know if I got something useful. In the meantime let me know if you got anything.

@xoryouyou I used see @FrancescoSaverioZuppichini 's ResNet implementation . ResNet18 runs without error (I didn't check any performance yet) however the other ResNet versions through an error.

@Shakesbeer333 No I haven't seen it. Thanks for the link! I'll give it a spin once my machine is finished training my current yolov5x net.

Edit: looks like pytorch vision already features all we need https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py

@xoryouyou yes we got all we need! However, I was facing tensor shape problems when connecting it to the head.

Was this page helpful?
0 / 5 - 0 ratings