darknet icon indicating copy to clipboard operation
darknet copied to clipboard

About ciou and diou loss.

Open SpongeBab opened this issue 3 years ago • 7 comments

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?

SpongeBab avatar Apr 15 '21 03:04 SpongeBab

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

WilburZjh avatar May 12 '21 22:05 WilburZjh

@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.

SpongeBab avatar May 19 '21 08:05 SpongeBab

@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.

WilburZjh avatar May 19 '21 13:05 WilburZjh

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 avatar Mar 24 '24 06:03 zzk2021

@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 avatar Mar 24 '24 06:03 zzk2021

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

zzk2021 avatar Mar 24 '24 06:03 zzk2021

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

zzk2021 avatar Mar 24 '24 08:03 zzk2021