AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.6k stars 7.95k forks source link

how to change darknet53 backbone to ResNet for yolov3. #6540

Open zunairaR opened 3 years ago

zunairaR commented 3 years ago

i want to change yolov3 backbone, can someone guide me in which file should I make changes. is it darknet53 cfg file or yolov3 cfg file.

WongKinYiu commented 3 years ago
  1. replace darknet53 backbone with resnet50 backbone cfg.
  2. change route layers 61 36 to corresponding layers of resnet50 backbone.
zunairaR commented 3 years ago

Thankyou so much @WongKinYiu but im confused in figuring out the corresponding layers in resnet50. will they be 37 and 61 ? Can you help me in this regard. Thanks

WongKinYiu commented 3 years ago

61 -> 55 36 -> 31

zunairaR commented 3 years ago

Ok. Thankyou so much

zunairaR commented 3 years ago

Can you please explain to me a bit, what's the theory behind. Why specifically features from 61 and 36 layers are concatenated. Its not getting into my head :(

On Tue, Aug 25, 2020 at 5:15 PM Kin-Yiu, Wong notifications@github.com wrote:

61 -> 55 36 -> 31

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AlexeyAB/darknet/issues/6540#issuecomment-680339536, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANQKPZG5PE7G73Q7HKYZWM3SCRH3VANCNFSM4QJHVLYQ .

--

Regards: Zunaira Rauf Malick PHD Scholar PIEAS

WongKinYiu commented 3 years ago

https://arxiv.org/abs/1612.03144

WongKinYiu commented 3 years ago

sorry for that i forget the index is from 0 not 1; 61 -> 54 36 -> 30

zunairaR commented 3 years ago

I was wondering the same, shouldn't it be 61--> 53 36-> 29 As in yolo v3 architecture, route connections are from skip/residual connections. Thanks

On Wed, Aug 26, 2020 at 4:48 PM Kin-Yiu, Wong notifications@github.com wrote:

sorry for that i forget the index is from 0 not 1; 61 -> 54 36 -> 30

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/AlexeyAB/darknet/issues/6540#issuecomment-681180755, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANQKPZFKBCJPCC2JWARKBCLSCWNOBANCNFSM4QJHVLYQ .

--

Regards: Zunaira Rauf Malick PHD Scholar PIEAS

WongKinYiu commented 3 years ago

61--> 53 36-> 29

ok, too.

zunairaR commented 3 years ago

Hey! I am getting an error, training is not starting. darknet: ./src/parser.c:981: parse_shortcut: Assertion `params.w == net.layers[index].out_w && params.h == net.layers[index].out_h' failed. how to resolve it?? I have also attached an image below.

On Wed, Aug 26, 2020 at 9:50 PM Kin-Yiu, Wong notifications@github.com wrote:

61--> 53 36-> 29

ok, too.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/AlexeyAB/darknet/issues/6540#issuecomment-681443761, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANQKPZEMCMYFFMWJDQ4UILTSCXQYRANCNFSM4QJHVLYQ .

--

Regards: Zunaira Rauf Malick PHD Scholar PIEAS

zunairaR commented 3 years ago

error-yolo

WongKinYiu commented 3 years ago

it due to the weighted shortcut update. and it effect all of resnet/resnext models. you can modify the code to old version.

or you can use route->maxpool->route to replace route.

zunairaR commented 3 years ago

Can you please share the link for the old version.

On Mon, Aug 31, 2020 at 6:32 PM Kin-Yiu, Wong notifications@github.com wrote:

it due to the weighted shortcut update. and it effect all of resnet/resnext models. you can modify the code to old version.

or you can use route->maxpool->route to replace route.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/AlexeyAB/darknet/issues/6540#issuecomment-684137902, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANQKPZHLNUQ4WKKEFYNZYDLSDRFJ3ANCNFSM4QJHVLYQ .

--

Regards: Zunaira Rauf Malick PHD Scholar PIEAS

zunairaR commented 3 years ago

Here i am attaching my .cfg file for yolo v3 with resnet 50. Can you please once look into it, if i'm doing it right. Thanks

On Tue, Sep 1, 2020 at 10:34 AM zunaira rauf zunirauf01@gmail.com wrote:

Can you please share the link for the old version.

On Mon, Aug 31, 2020 at 6:32 PM Kin-Yiu, Wong notifications@github.com wrote:

it due to the weighted shortcut update. and it effect all of resnet/resnext models. you can modify the code to old version.

or you can use route->maxpool->route to replace route.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/AlexeyAB/darknet/issues/6540#issuecomment-684137902, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANQKPZHLNUQ4WKKEFYNZYDLSDRFJ3ANCNFSM4QJHVLYQ .

--

Regards: Zunaira Rauf Malick PHD Scholar PIEAS

--

Regards: Zunaira Rauf Malick PHD Scholar PIEAS

zunairaR commented 3 years ago

can i add a 1x1 convolution with stride 2 to a shortcut layer?

On Tue, Sep 1, 2020 at 10:45 AM zunaira rauf zunirauf01@gmail.com wrote:

Here i am attaching my .cfg file for yolo v3 with resnet 50. Can you please once look into it, if i'm doing it right. Thanks

On Tue, Sep 1, 2020 at 10:34 AM zunaira rauf zunirauf01@gmail.com wrote:

Can you please share the link for the old version.

On Mon, Aug 31, 2020 at 6:32 PM Kin-Yiu, Wong notifications@github.com wrote:

it due to the weighted shortcut update. and it effect all of resnet/resnext models. you can modify the code to old version.

or you can use route->maxpool->route to replace route.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/AlexeyAB/darknet/issues/6540#issuecomment-684137902, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANQKPZHLNUQ4WKKEFYNZYDLSDRFJ3ANCNFSM4QJHVLYQ .

--

Regards: Zunaira Rauf Malick PHD Scholar PIEAS

--

Regards: Zunaira Rauf Malick PHD Scholar PIEAS

--

Regards: Zunaira Rauf Malick PHD Scholar PIEAS

ali-hafidz commented 3 years ago

@zunairaR hi, have you solve this problem? I also trying to change backbone to resnext, I am confusing how to define route layers on resnext, maybe you have some suggestion for this issue. Thanks

zunairaR commented 3 years ago

For resnext you have to check in which layers fpn has to bw connected i.e at three different levels. Route layers in yolov3 are just like any residual connection in any network. Hope it clears your confusion.

On Thu, Jul 1, 2021, 9:50 AM ali-hafidz @.***> wrote:

@zunairaR https://github.com/zunairaR hi, have you solve this problem? I also trying to change backbone to resnext, I am confusing how to define route layers on resnext, maybe you have some suggestion for this issue. Thanks

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AlexeyAB/darknet/issues/6540#issuecomment-871915352, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANQKPZBK5XXFKGEUI3PY3A3TVPXZ5ANCNFSM4QJHVLYQ .

ali-hafidz commented 3 years ago

@zunairaR let me verify, so the first step that I must do is change cfg file (yolov3.cfg) to resnext( change route etc), then modificating architecture ( using resnext ) and when going to training, i hit that cfg file that contain resnext architecture, cmiiw

zunairaR commented 3 years ago

yes yes, in yolov3 or precisely in darknet if you want to do any change in architecture you have to change yolov3.cfg file. In this file you need to simply replace darknet53 layers with resnext layers. And then for FPN you need to have connections from backbone(resnext) layers followed by some conv layers to yolo layer for detection.

On Sat, Jul 3, 2021 at 5:47 AM ali-hafidz @.***> wrote:

@zunairaR https://github.com/zunairaR let me verify, so the first step that I must do is change cfg file (yolov3.cfg) to resnext( change route etc), then modificating architecture ( using resnext ) and when going to training, i hit that cfg file that contain resnext architecture, cmiiw

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/AlexeyAB/darknet/issues/6540#issuecomment-873410380, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANQKPZCI6WITFMD257L5L6DTV4IILANCNFSM4QJHVLYQ .