AlexeyAB / darknet

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

About ciou and diou loss. #7608

Open SpongeBab opened 3 years ago

SpongeBab commented 3 years ago

Hi,@cenit, Maybe I found a code bug. It's not a error.But it haven't do the thing correctly. In yolo_layer.c:

                 args->tot_iou += all_ious.iou;
                args->tot_iou_loss += 1 - all_ious.iou;
                // range is -1 <= giou <= 1
                tot_giou += all_ious.giou;
                args->tot_giou_loss += 1 - all_ious.giou;

                tot_diou += all_ious.diou;
                tot_diou_loss += 1 - all_ious.diou;

                tot_ciou += all_ious.ciou;
                tot_ciou_loss += 1 - all_ious.ciou;

the tot_iou_loss and tot_giou_loss use the args pointer to return to yolo_args,so we can see

        yolo_args[b].tot_iou_loss = 0;
        yolo_args[b].tot_giou_loss = 0;

but the I want to use the ciou_loss and diou_loss,maybe it doesn't work. Such as in the cfg file : iou_loss=ciou but in there,it don't have ciou option:

            if (l.iou_loss == GIOU) {
                avg_iou_loss = count > 0 ? l.iou_normalizer * (tot_giou_loss / count) : 0;  //count = batch
            }
            else {
                avg_iou_loss = count > 0 ? l.iou_normalizer * (tot_iou_loss / count) : 0;  //
            }

Am i right?

WilburZjh commented 3 years ago

@AlexeyAB Same concerns, how to use CIOU and DIOU loss? just modify the config file?

SpongeBab commented 3 years ago

@WilburZjh It is seemed that there is no more people that concern the question. I think it doesn't implement the CIoU and DIoU loss.Altough it is defined in the box.c,but it is imperfect.The Scale-yolo used the CIoU and DIoU,but it is implemented in python.Although it is supported in the darknet,but there is no trained result submitted.

WilburZjh commented 3 years ago

@SpongeBab I found some useful information in the wiki, https://github.com/AlexeyAB/darknet/wiki/CFG-Parameters-in-the-different-layers, it defines the CIoU and DIoU as iou_loss, I think we can just change the name in the cfg file.

zzk2021 commented 7 months ago

same question . no use for variable

float tot_diou_loss = 0;
float tot_ciou_loss = 0;  

in function forward_yolo_layer and there is no diou ciou loss added in l.cost some one say that l.cost is only show ,not use for network. but no diou ciou add in args

// range is 0 <= 1
                        args->tot_iou += all_ious.iou;
                        args->tot_iou_loss += 1 - all_ious.iou;
                        // range is -1 <= giou <= 1
                        tot_giou += all_ious.giou;
                        args->tot_giou_loss += 1 - all_ious.giou;

                        tot_diou += all_ious.diou;
                        tot_diou_loss += 1 - all_ious.diou;

                        tot_ciou += all_ious.ciou;
                        tot_ciou_loss += 1 - all_ious.ciou;
zzk2021 commented 7 months ago

@WilburZjh It is seemed that there is no more people that concern the question. I think it doesn't implement the CIoU and DIoU loss.Altough it is defined in the box.c,but it is imperfect.The Scale-yolo used the CIoU and DIoU,but it is implemented in python.Although it is supported in the darknet,but there is no trained result submitted.

Is there a corresponding py file?I confuse about it but I cant find any file claim CIoU and DIoU

zzk2021 commented 7 months ago

It is important for me cause I use own iou loss, I want to know the reason do that

zzk2021 commented 7 months ago

l.delta is used for cost,not l.cost