WongKinYiu / ScaledYOLOv4

Scaled-YOLOv4: Scaling Cross Stage Partial Network
GNU General Public License v3.0
2.02k stars 572 forks source link

Unsupported fields ['objectness_smooth', 'resize', 'obj_normalizer', 'new_coords', 'max_delta'] #98

Open LeoSouquet opened 3 years ago

LeoSouquet commented 3 years ago

Hi Guys,

I tried to train using this repository a Yolov4 model with the Yolov4-csp.cfg of provided in AlexeyAB Darket. However, when launching, I have an error:

Unsupported fields ['objectness_smooth', 'resize', 'obj_normalizer', 'new_coords', 'max_delta']

I tried because it is written that yolov4 csp is compatible with darknet AlexeyAB. Any advice on why the cfg files are not compatible? Will they be or darknet has just added more feature that will just be available in darknet?

Thanks in advance,

Regards,

WongKinYiu commented 3 years ago

cfg file for pytorch: https://github.com/WongKinYiu/ScaledYOLOv4/blob/yolov4-csp/models/yolov4-csp.cfg cfg file for darknet: https://github.com/AlexeyAB/darknet/blob/master/cfg/yolov4-csp.cfg

and share same weights file.

LeoSouquet commented 3 years ago

Thanks!

So we cannot use the same CFG for both pytorch and darknet ? I am saying that because I work on translating from one framework to the other and I cannot use the same file, this might an issue for me. So I just wanna make sure of that before I keep using the CSP version :)

WongKinYiu commented 3 years ago

darknet is more flexible, almost all of htper-parameters are being parameterized. and some of hyper-parameters are fixed in pytorch code, you have to modify some code to enable modifying those hyper-parameters in cfg file.

you could add field to https://github.com/WongKinYiu/ScaledYOLOv4/blob/yolov4-csp/utils/parse_config.py#L39 and modify the corresponding code.

LeoSouquet commented 3 years ago

Thanks a lot for that ! Could you point me out where the hyperparameters are fixed in the python code please? So I can modify supported fields and add parameters.

I would really appreciate the help :)

Thanks a lot !

WongKinYiu commented 3 years ago

if they appeared in https://github.com/WongKinYiu/ScaledYOLOv4/blob/yolov4-csp/utils/parse_config.py#L40-L43 but not appeared in https://github.com/WongKinYiu/ScaledYOLOv4/blob/yolov4-csp/models/models.py#L19 or https://github.com/WongKinYiu/ScaledYOLOv4/blob/yolov4-csp/data/hyp.scratch.yaml#L6-L27 it means they are fixed in somewhere of the code.

LeoSouquet commented 3 years ago

They do not appear in [https://github.com/WongKinYiu/ScaledYOLOv4/blob/yolov4-csp/utils/parse_config.py#L39] Could you point where those parameters are fixed in the code? I am not sure what they correspond to. I don't find any documentation on the actual cost function and the associated hyperparameters.

Thanks in advance,

WongKinYiu commented 3 years ago

they are too many, darknet version has more and more good functions.

actual loss function is in https://github.com/WongKinYiu/ScaledYOLOv4/blob/yolov4-csp/utils/general.py#L443

and for example you could implement objectness_smooth by passing hyper-parameter to https://github.com/WongKinYiu/ScaledYOLOv4/blob/yolov4-csp/utils/general.py#L454

LeoSouquet commented 3 years ago

Okay Thank you 👍 I will check all that out and see how I can implement.

Just a last thing, can you confirm the results reported in your paper CSP Paper have been done using this repository and not darknet ?

WongKinYiu commented 3 years ago

no, some experimental results are conducted by darknet and some by pytorch. we mainly use darknet in our projects, pytorch is used to do quick integration with sota methods.

LeoSouquet commented 3 years ago

Alright, I understand. So to reproduce the results, I should use darknet with this CFF file? https://github.com/AlexeyAB/darknet/blob/master/cfg/yolov4-csp.cfg

LeoSouquet commented 3 years ago

Also, your repo and the darknet one use a different loss function and a different Learning rate scheduler. Could you point towards the formation of the darknet loss function, I struggle to find it.

Thanks in advance you really helping me out a lot!

vishnubanna commented 3 years ago

yeah, i have the same question the loss function seems different, wit no gradient clipping, no ignore threshold, or ignore_thresh == truth_thresh to compute loss everywhere, etc. so if we want to re produce the results, is the darknet repo not viable, use this repo or vice versa. building on the why does this repo not do gradient clipping (or where exactly is it done).

vishnubanna commented 3 years ago

@WongKinYiu

WongKinYiu commented 3 years ago

loss of darknet are *delta* functions in yolo_layer.c

vishnubanna commented 3 years ago

correct while I can see that yolo layer is the deltas and not the original loss, the question still remains, if we were to look at the non-delta equivalent of the darknet yolo_layer.c, is it the same as loss function found in this library? if not, which one was used to get the results in the paper, darknet or pytorch? because the yolo_layer.c seems to be doing far more than the loss found in this library with various components like the ignore threshold. If I was to train from scratch using this library, would I get the same results as the paper? @WongKinYiu

akashAD98 commented 3 years ago

@WongKinYiu can you please explain the impact of new_coord=1, max_delta ?? & what condition we need to use this??