-
-
Notifications
You must be signed in to change notification settings - Fork 16.2k
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
yolov4.yaml #153
Conversation
@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. |
No, I do not have more details. |
@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. |
I think the main reason is panet usually has higher precision and fpn usually has higher recall. 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. |
@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:
For PANet:
|
@glenn-jocher @WongKinYiu I think YOLOv4 lacks very important innovations. His effect in industry is lower than YOLOv3-SPP. |
FPN -> PANet Recall of small object: 46.9 -> 47.6 (+0.7) AP of small object: 28.3 -> 30.3 (+2.0) So we can find that the AP improvement of small objects are almost come from better precision/regression. 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. |
@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! |
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? |
@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 |
@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 |
@sharoseali I used this yaml file and encountered the above error. |
Thanks for sharing @ilem777 |
If you can solve the problem like @zh9369 please be sure to let me know the first time, looking forward to. @sharoseali |
@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)
] |
@Lornatang I get the similar error as @zh9369 reported, how should I modify?
|
@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 |
@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. |
@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: |
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:
|
@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 |
@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 |
@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. |
@ilem777 Probably because of the activation function, ultralytics/yolov5 uses Swish(nn.SiLU) activation function by default, while yolov4 uses Mish function ππ€ |
@snow-tyan Yes you are right, the activation function is an influencing factor. I'll have time to do the test afterwards. |
Hi, were you able to use the pretrained weights in the pt or weights format for YOLOv4 in the ultralytics repo? |
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
yolov4.yaml
) with specific parameters, anchors, a CSPDarknet-53 backbone, and a YOLOv3-SPP head.requirements.txt
file, indicating a possible shift to a different dependency management approach or a cleanup.π― Purpose & Impact
requirements.txt
might affect the setup process, but it also may simplify dependency management if moved to another system likesetup.py
or conda environments.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. π οΈ