Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yolov4.yaml #153

Closed
wants to merge 3 commits into from
Closed

yolov4.yaml #153

wants to merge 3 commits into from

Conversation

Lornatang
Copy link
Contributor

@Lornatang Lornatang commented Jun 21, 2020

Add support for YOLOv4 for issue #144

πŸ› οΈ PR Summary

Made with ❀️ by Ultralytics Actions

🌟 Summary

Introducing YOLOv4 configuration to the Ultralytics YOLOv5 repository.

πŸ“Š Key Changes

  • Added a new YOLOv4 model configuration file (yolov4.yaml) with specific parameters, anchors, a CSPDarknet-53 backbone, and a YOLOv3-SPP head.
  • Removed the requirements.txt file, indicating a possible shift to a different dependency management approach or a cleanup.

🎯 Purpose & Impact

  • Purpose: The new YOLOv4 configuration is likely introduced to extend the Ultralytics YOLOv5 project's capabilities by supporting the YOLOv4 architecture. Users may choose YOLOv4 for specific use cases where it might perform better.
  • Impact: Users have more options for object detection models within the same framework, potentially boosting performance or accuracy in various scenarios. The deletion of the requirements.txt might affect the setup process, but it also may simplify dependency management if moved to another system like setup.py or conda environments.
  • The impact of removing requirements.txt depends on the new method adopted for managing dependencies, which is not indicated in the diff provided. Users need to watch out for changes in the setup or installation instructions. πŸ› οΈ

@glenn-jocher
Copy link
Member

@Lornatang can you remove the requirements.txt from this PR?

For yolov4, I think the cfg is not correct. @WongKinYiu may have more details, I believe he is testing yolov4 yamls with this repo.

@glenn-jocher glenn-jocher changed the title Add new model config yolov4.yaml Jun 24, 2020
@WongKinYiu
Copy link

@glenn-jocher

For yolov4, I think the cfg is not correct. @WongKinYiu may have more details, I believe he is testing yolov4 yamls with this repo.

No, I do not have more details.
I mainly focus on ultralytics/yolov3 since it compatible with darknet.
Currently ultralytics/yolov5 is easy to use, but not friendly for developing new methods.

@glenn-jocher
Copy link
Member

glenn-jocher commented Jun 24, 2020

@WongKinYiu ok thanks for the feedback! I may try to create a yolov4.yaml here myself if I can find some time. I've archived the 3 main architectures used so far here in the models/hub folder.

One user had interesting feedback that their small object custom dataset had worse results with panet than with fpn. I'm not sure if this is just their dataset, or if in general the fpn model will benefit small objects more, while the panet model may benefit larger objects.

Screen Shot 2020-06-24 at 1 24 48 PM

@WongKinYiu
Copy link

WongKinYiu commented Jun 24, 2020

@glenn-jocher

I think the main reason is panet usually has higher precision and fpn usually has higher recall.
Maybe you could check the precision/recall/AP50/AP75 on their dataset.
Or maybe you have to do hyper-parameter search directly on panet-based models.

By the way, I am training YOLOv4(CSP,Leaky) models based on ultralytics/yolov5, but I only build new layers of the model, the new layers I have created are not fully parameterized, so it can not be a PR.

@glenn-jocher
Copy link
Member

@WongKinYiu yes, I will take a closer looks at the small/medium/large effects between the two. Ah, well at least on COCO it seems PANet is actually helping small objects the most, so my theory was not correct.

For FPN:

 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.455
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.646
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.496
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.283
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.498
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.589
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.355
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.582
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.638
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.469
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.685
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.770

For PANet:

 Average Precision  (AP) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.466
 Average Precision  (AP) @[ IoU=0.50      | area=   all | maxDets=100 ] = 0.650
 Average Precision  (AP) @[ IoU=0.75      | area=   all | maxDets=100 ] = 0.509
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.303
 Average Precision  (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.515
 Average Precision  (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.597
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=  1 ] = 0.364
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets= 10 ] = 0.595
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=   all | maxDets=100 ] = 0.650
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.476
 Average Recall     (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.705
 Average Recall     (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.789

@Lornatang
Copy link
Contributor Author

@glenn-jocher @WongKinYiu I think YOLOv4 lacks very important innovations. His effect in industry is lower than YOLOv3-SPP.

@WongKinYiu
Copy link

WongKinYiu commented Jun 25, 2020

@glenn-jocher

FPN -> PANet

Recall of small object: 46.9 -> 47.6 (+0.7)
Recall of median object: 68.5 -> 70.5 (+2,0)
Recall of large object: 77.0 -> 78.9 (+1.9)

AP of small object: 28.3 -> 30.3 (+2.0)
AP of median object: 49.8 -> 51.5 (+1.7)
AP of large object: 58.9 -> 59.7 (+0.8)

So we can find that the AP improvement of small objects are almost come from better precision/regression.
And small means ~ 32 * 32 in MSCOCO, do you know the object size of the custom dataset?
And do they use mosaic augmentation?

@Lornatang

Industry usually run detector on low end devices, YOLOv4 optimize and balance the memory bandwidth and computation... so it can run on more devices. For example on Jetson nano, YOLOv4 runs 2.x times faster than YOLOv3.

@Lornatang
Copy link
Contributor Author

@WongKinYiu In the real scene, YOLOv4 has a higher detection error detection rate for the target. Although his performance is better, we all use model pruning so that he can be distributed on any device. Therefore, I look forward to a new YOLOv4/YOLOv5. Looking forward to your work!

@Lornatang Lornatang closed this Jul 24, 2020
@zh9369
Copy link

zh9369 commented Jan 29, 2021

i use yolov4.yaml file,but it has some wrong.RuntimeError: Given groups=1, weight of size [1, 24, 1, 1], expected input[1, 1024, 4, 4] to have 24 channels, but got 1024 channels instead.have you ever run successed?

@sharoseali
Copy link

sharoseali commented Apr 23, 2021

@Lornatang @WongKinYiu Can you please share the yolov4 YAML file. I want to test my yolov4 model, Also if you please share some details, how to transform cfg to a YAML file. As i make some changes in my yolov4 cfg file like in upsampling layer.. thanks

@zxsitu
Copy link

zxsitu commented Apr 23, 2021

@zh9369 I encountered the same problem as you, how did you solve the problem?

@sharoseali
Copy link

@zh9369 I encountered the same problem as you, how did you solve the problem?

By the way can you please share this yaml file. i am just listening about this file but un anle to find it anywhere. Can you please share

@zxsitu
Copy link

zxsitu commented Apr 23, 2021

@sharoseali I used this yaml file and encountered the above error.

@sharoseali
Copy link

@sharoseali I used this yaml file and encountered the above error.

Thanks for sharing @ilem777

@zxsitu
Copy link

zxsitu commented Apr 23, 2021

If you can solve the problem like @zh9369 please be sure to let me know the first time, looking forward to. @sharoseali

@Lornatang
Copy link
Contributor Author

@zh9369 Is there?

# parameters
nc: 80  # number of classes
depth_multiple: 1.0  # model depth multiple
width_multiple: 1.0  # layer channel multiple

# anchors
anchors:
  - [10,13, 16,30, 33,23]  # P3/8
  - [30,61, 62,45, 59,119]  # P4/16
  - [116,90, 156,198, 373,326]  # P5/32

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

# YOLOv3-SPP head

head:
  [[-1, 1, Bottleneck, [1024, False]],  # 11
   [-1, 1, Conv, [512, 1, 1]],
   [-1, 1, SPP, [512, [5, 9, 13]]],
   [-1, 1, Bottleneck, [1024, False]],
   [-1, 1, Bottleneck, [1024, False]],
   [-1, 1, nn.Conv2d, [na * (nc + 5), 1, 1]],  # 12 (P5/32-large)

   [-3, 1, Conv, [256, 1, 1]],
   [-1, 1, nn.Upsample, [None, 2, "nearest"]],
   [[-1, 8], 1, Concat, [1]],  # concat backbone P4
   [-1, 1, Bottleneck, [512, False]],
   [-1, 2, Bottleneck, [512, False]],
   [-1, 1, nn.Conv2d, [na * (nc + 5), 1, 1]],  # 18 (P4/16-medium)

   [-3, 1, Conv, [128, 1, 1]],
   [-1, 1, nn.Upsample, [None, 2, "nearest"]],
   [[-1, 6], 1, Concat, [1]],  # concat backbone P3
   [-1, 1, Bottleneck, [256, False]],
   [-1, 2, Bottleneck, [256, False]],
   [-1, 1, nn.Conv2d, [na * (nc + 5), 1, 1]],  # 24 (P3/8-small)

   [[], 1, Detect, [nc, anchors]],   # Detect(P3, P4, P5)
  ]

@zxsitu
Copy link

zxsitu commented Apr 25, 2021

@Lornatang I get the similar error as @zh9369 reported, how should I modify?

(venv) F:\PycharmProjects\yolov5_env\yolov5>python train.py --batch-size 8 --epochs 300 --adam --data data/coco128.yaml --cfg models/hub/yolov4.yaml --weights '' --name yolov4
?[34m?[1mgithub: ?[0mskipping check (offline)
YOLOv5  v5.0-20-gd48a34d torch 1.7.0 CUDA:0 (Quadro P5000, 16384.0MB)

Namespace(adam=True, artifact_alias='latest', batch_size=8, bbox_interval=-1, bucket='', cache_images=False, cfg='models/hub/yolov4.yaml', data='data/coco128.yaml', device='', entity=None, epochs=300, evolve=False, exist_ok=False, glob
al_rank=-1, hyp='data/hyp.scratch.yaml', image_weights=False, img_size=[640, 640], label_smoothing=0.0, linear_lr=False, local_rank=-1, multi_scale=False, name='yolov4', noautoanchor=False, nosave=False, notest=False, project='runs/tra
in', quad=False, rect=False, resume=False, save_dir='runs\\train\\yolov4', save_period=-1, single_cls=False, sync_bn=False, total_batch_size=8, upload_dataset=False, weights="''", workers=8, world_size=1)
?[34m?[1mtensorboard: ?[0mStart with 'tensorboard --logdir runs/train', view at http://localhost:6006/
?[34m?[1mhyperparameters: ?[0mlr0=0.001, lrf=0.2, momentum=0.937, weight_decay=0.0005, warmup_epochs=3.0, warmup_momentum=0.8, warmup_bias_lr=0.1, box=0.05, cls=0.5, cls_pw=1.0, obj=1.0, obj_pw=1.0, iou_t=0.2, anchor_t=4.0, fl_gamma=0.
0, hsv_h=0.015, hsv_s=0.7, hsv_v=0.4, degrees=25, translate=0.3, scale=0.5, shear=25, perspective=0.0, flipud=0.0, fliplr=1.0, mosaic=1.0, mixup=1.0
?[34m?[1mwandb: ?[0mInstall Weights & Biases for YOLOv5 logging with 'pip install wandb' (recommended)

                 from  n    params  module                                  arguments
  0                -1  1       928  models.common.Conv                      [3, 32, 3, 1]
  1                -1  1     18560  models.common.Conv                      [32, 64, 3, 2]
  2                -1  1     19904  models.common.BottleneckCSP             [64, 64, 1]
  3                -1  1     73984  models.common.Conv                      [64, 128, 3, 2]
  4                -1  1    119936  models.common.BottleneckCSP             [128, 128, 2]
  5                -1  1    295424  models.common.Conv                      [128, 256, 3, 2]
  6                -1  1   1463552  models.common.BottleneckCSP             [256, 256, 8]
  7                -1  1   1180672  models.common.Conv                      [256, 512, 3, 2]
  8                -1  1   5843456  models.common.BottleneckCSP             [512, 512, 8]
  9                -1  1   4720640  models.common.Conv                      [512, 1024, 3, 2]
 10                -1  1  12858368  models.common.BottleneckCSP             [1024, 1024, 4]
 11                -1  1   5245952  models.common.Bottleneck                [1024, 1024, False]
 12                -1  1    525312  models.common.Conv                      [1024, 512, 1, 1]
 13                -1  1    656896  models.common.SPP                       [512, 512, [5, 9, 13]]
 14                -1  1   4983808  models.common.Bottleneck                [512, 1024, False]
 15                -1  1   5245952  models.common.Bottleneck                [1024, 1024, False]
 16                -1  1        31  torch.nn.modules.conv.Conv2d            [30, 1, 1]
 17                -3  1    262656  models.common.Conv                      [1024, 256, 1, 1]
 18                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']
 19           [-1, 8]  1         0  models.common.Concat                    [1]
 20                -1  1   1377792  models.common.Bottleneck                [768, 512, False]
 21                -1  2   2624512  models.common.Bottleneck                [512, 512, False]
 22                -1  1        31  torch.nn.modules.conv.Conv2d            [30, 1, 1]
 23                -3  1     65792  models.common.Conv                      [512, 128, 1, 1]
 24                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']
 25           [-1, 6]  1         0  models.common.Concat                    [1]
 26                -1  1    344832  models.common.Bottleneck                [384, 256, False]
 27                -1  2    656896  models.common.Bottleneck                [256, 256, False]
 28                -1  1        31  torch.nn.modules.conv.Conv2d            [30, 1, 1]
 29                []  1         0  models.yolo.Detect                      [5, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]], []]
Traceback (most recent call last):
  File "train.py", line 544, in <module>
    train(hyp, opt, device, tb_writer)
  File "train.py", line 95, in train
    model = Model(opt.cfg, ch=3, nc=nc, anchors=hyp.get('anchors')).to(device)  # create
  File "F:\PycharmProjects\yolov5_env\yolov5\models\yolo.py", line 93, in __init__
    m.stride = torch.tensor([s / x.shape[-2] for x in self.forward(torch.zeros(1, ch, s, s))])  # forward
  File "F:\PycharmProjects\yolov5_env\yolov5\models\yolo.py", line 123, in forward
    return self.forward_once(x, profile)  # single-scale inference, train
  File "F:\PycharmProjects\yolov5_env\yolov5\models\yolo.py", line 139, in forward_once
    x = m(x)  # run
  File "F:\PycharmProjects\yolov5_env\venv\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "F:\PycharmProjects\yolov5_env\venv\lib\site-packages\torch\nn\modules\conv.py", line 423, in forward
    return self._conv_forward(input, self.weight)
  File "F:\PycharmProjects\yolov5_env\venv\lib\site-packages\torch\nn\modules\conv.py", line 419, in _conv_forward
    return F.conv2d(input, weight, self.bias, self.stride,
RuntimeError: Given groups=1, weight of size [1, 30, 1, 1], expected input[1, 1024, 8, 8] to have 30 channels, but got 1024 channels instead

@sharoseali
Copy link

@ilem777 I also get the same error, But now it's time to understand the YAML file. I observe from your, mine, and @zh9369 error report that is a problem with a number of filters in cfg file, which we chose corresponding to our class number. In my case, no of classes was 12 and the corresponding filters were 51, so my error was something like this RuntimeError: Given groups=1, the weight of size [1, 51, 1, 1], expected input[1, 1024, .., ..] In the same way I hope your filters number corresponding to your class number is 30. But all in our case it's showing 1024 and a mismatch occurs. Now looking towards @glenn-jocher (If I am not wrong in understanding) can you please tell where we can make changes at the exact place in our YAML file to solve this mismatch issue.

@zxsitu
Copy link

zxsitu commented Apr 27, 2021

@sharoseali @glenn-jocher Yes, there is a cfg file that can be modified in v4, but now I don't even know where to look.

@glenn-jocher
Copy link
Member

@sharoseali @ilem777 I'm not sure exactly guys, I haven't done any yolov4 imports myself, but you can see successful translations between for example yolov3.cfg and yolov3.yaml here:

@snow-tyan
Copy link

snow-tyan commented May 23, 2021

try this, @ilem777 @sharoseali I modified it on @Lornatang basis and I didn't train

# parameters
nc: 80  # number of classes
depth_multiple: 1.0  # model depth multiple
width_multiple: 1.0  # layer channel multiple

# anchors
anchors:
  - [10,13, 16,30, 33,23]  # P3/8
  - [30,61, 62,45, 59,119]  # P4/16
  - [116,90, 156,198, 373,326]  # P5/32

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

# SPP PANet v3head
head:
  [[-1, 1, Bottleneck, [1024, False]],  # 11
   [-1, 1, SPP, [512, [5, 9, 13]]],  # conv1x1+SPP+conv1x1
   [-1, 1, Conv, [1024, 3, 1]],
   [-1, 1, Conv, [512, 1, 1]],  # 14
   [-1, 1, Conv, [256, 1, 1]],
   [-1, 1, nn.Upsample, [None, 2, "nearest"]],
   [8, 1, Conv, [256, 1, 1]],  # conv backbone P4
   [[-2, -1], 1, Concat, [1]],  # concat backbone P4

   [-1, 2, Bottleneck, [512, False]],
   [-1, 1, Conv, [256, 1, 1]],  # 20
   [-1, 1, Conv, [128, 1, 1]],
   [-1, 1, nn.Upsample, [None, 2, "nearest"]],
   [6, 1, Conv, [128, 1, 1]],  # conv backbone P3
   [[-2, -1], 1, Concat, [1]],  # concat backbone P3

   [-1, 2, Bottleneck, [256, False]],
   [-1, 1, Conv, [128, 1, 1]],  # 26
   [-1, 1, Conv, [256, 3, 1]], # 27 (P3/8-small)

   [26, 1, Conv, [256, 3, 2]], # down sample
   [[-1, 20], 1, Concat, [1]],  # concat 20
   [-1, 2, Bottleneck, [512, False]],
   [-1, 1, Conv, [256, 1, 1]],  # 31
   [-1, 1, Conv, [512, 3, 1]],  # 32 (P4/16-medium)

   [31, 1, Conv, [512, 3, 2]], # down sample
   [[-1, 14], 1, Concat, [1]],  # concat 14
   [-1, 2, Bottleneck, [1024, False]],
   [-1, 1, Conv, [512, 1, 1]],
   [-1, 1, Conv, [1024, 3, 1]],  # 37 (P5/32-large)

   [[27, 32, 37], 1, Detect, [nc, anchors]],   # Detect(P3, P4, P5)
  ]

output:

                 from  n    params  module                                  arguments                     
  0                -1  1       928  models.common.Conv                      [3, 32, 3, 1]                 
  1                -1  1     18560  models.common.Conv                      [32, 64, 3, 2]                
  2                -1  1     19904  models.common.BottleneckCSP             [64, 64, 1]                   
  3                -1  1     73984  models.common.Conv                      [64, 128, 3, 2]               
  4                -1  1    119936  models.common.BottleneckCSP             [128, 128, 2]                 
  5                -1  1    295424  models.common.Conv                      [128, 256, 3, 2]              
  6                -1  1   1463552  models.common.BottleneckCSP             [256, 256, 8]                 
  7                -1  1   1180672  models.common.Conv                      [256, 512, 3, 2]              
  8                -1  1   5843456  models.common.BottleneckCSP             [512, 512, 8]                 
  9                -1  1   4720640  models.common.Conv                      [512, 1024, 3, 2]             
 10                -1  1  12858368  models.common.BottleneckCSP             [1024, 1024, 4]               
 11                -1  1   5245952  models.common.Bottleneck                [1024, 1024, False]           
 12                -1  1   1574912  models.common.SPP                       [1024, 512, [5, 9, 13]]       
 13                -1  1   4720640  models.common.Conv                      [512, 1024, 3, 1]             
 14                -1  1    525312  models.common.Conv                      [1024, 512, 1, 1]             
 15                -1  1    131584  models.common.Conv                      [512, 256, 1, 1]              
 16                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']          
 17                 8  1    131584  models.common.Conv                      [512, 256, 1, 1]              
 18          [-2, -1]  1         0  models.common.Concat                    [1]                           
 19                -1  2   2624512  models.common.Bottleneck                [512, 512, False]             
 20                -1  1    131584  models.common.Conv                      [512, 256, 1, 1]              
 21                -1  1     33024  models.common.Conv                      [256, 128, 1, 1]              
 22                -1  1         0  torch.nn.modules.upsampling.Upsample    [None, 2, 'nearest']          
 23                 6  1     33024  models.common.Conv                      [256, 128, 1, 1]              
 24          [-2, -1]  1         0  models.common.Concat                    [1]                           
 25                -1  2    656896  models.common.Bottleneck                [256, 256, False]             
 26                -1  1     33024  models.common.Conv                      [256, 128, 1, 1]              
 27                -1  1    295424  models.common.Conv                      [128, 256, 3, 1]              
 28                26  1    295424  models.common.Conv                      [128, 256, 3, 2]              
 29          [-1, 20]  1         0  models.common.Concat                    [1]                           
 30                -1  2   2624512  models.common.Bottleneck                [512, 512, False]             
 31                -1  1    131584  models.common.Conv                      [512, 256, 1, 1]              
 32                -1  1   1180672  models.common.Conv                      [256, 512, 3, 1]              
 33                31  1   1180672  models.common.Conv                      [256, 512, 3, 2]              
 34          [-1, 14]  1         0  models.common.Concat                    [1]                           
 35                -1  2  10491904  models.common.Bottleneck                [1024, 1024, False]           
 36                -1  1    525312  models.common.Conv                      [1024, 512, 1, 1]             
 37                -1  1   4720640  models.common.Conv                      [512, 1024, 3, 1]             
 38      [27, 32, 37]  1    457725  Detect                                  [80, [[10, 13, 16, 30, 33, 23], [30, 61, 62, 45, 59, 119], [116, 90, 156, 198, 373, 326]], [256, 512, 1024]]
Model Summary: 472 layers, 64341341 parameters, 64341341 gradients, 138.3 GFLOPS

@zxsitu
Copy link

zxsitu commented May 23, 2021

@snow-tyan Hi, I tried to run YOLOv4 with your modified yaml file, and overall, the results are worse than YOLOv5l and slightly inferior to YOLOv3 after running 200 epochs with my own custom dataset (1000 images).

However, for this running version of YOLOv4(https://github.com/WongKinYiu/PyTorch_YOLOv4οΌ‰, the results are superior.

Result
P R mAP50 mAP infer-time
YOLOv3 0.643 0.637 0.643 0.277 35.3
YOLOv5l 0.669 0.624 0.654 0.298 28.9
YOLOv4(this yamlοΌ‰0.681 0.578 0.641 0.272 31
YOLOv4 0.431 0.718 0.6 0.266 38.5

@snow-tyan
Copy link

@ilem777 emmm... I edited the comment twice. Is your yaml the latest one? I modified it according to this https://github.com/WongKinYiu/PyTorch_YOLOv4/cfg/yolov4.cfg

@zxsitu
Copy link

zxsitu commented May 23, 2021

@snow-tyan The second time I used your last modified model, it was a bit larger than the original, however on my dataset test, the results became a bit worse.
0.674 0.613 0.625 0.271 35.3πŸ˜‚

@snow-tyan
Copy link

@ilem777 Probably because of the activation function, ultralytics/yolov5 uses Swish(nn.SiLU) activation function by default, while yolov4 uses Mish function πŸ˜‚πŸ€”

@zxsitu
Copy link

zxsitu commented May 24, 2021

@snow-tyan Yes you are right, the activation function is an influencing factor. I'll have time to do the test afterwards.
Thank you for configuring v5 version of yolov4.

@antimo22
Copy link

@snow-tyan Yes you are right, the activation function is an influencing factor. I'll have time to do the test afterwards. Thank you for configuring v5 version of yolov4.

Hi, were you able to use the pretrained weights in the pt or weights format for YOLOv4 in the ultralytics repo?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants