bubbliiiing / yolo3-pytorch

这是一个yolo3-pytorch的源码,可以用于训练自己的模型。
MIT License
2.01k stars 585 forks source link

损失函数 #159

Closed zhuasd closed 2 years ago

zhuasd commented 2 years ago

在yolov3网络中,如果我想在YOLOloss文件中的GIoU和IoU外增加CIoU和DIoU,get_target()函数中下面两行该如何添加CIoU和DIoU对应的中心点变化呢?

----------------------------------------

            #   tx、ty代表中心调整参数的真实值
            #----------------------------------------#
            if not self.giou:
                #----------------------------------------#
                #   tx、ty代表中心调整参数的真实值
                #----------------------------------------#
                y_true[b, k, j, i, 0] = batch_target[t, 0] - i.float()
                y_true[b, k, j, i, 1] = batch_target[t, 1] - j.float()
                y_true[b, k, j, i, 2] = math.log(batch_target[t, 2] / anchors[best_n][0])
                y_true[b, k, j, i, 3] = math.log(batch_target[t, 3] / anchors[best_n][1])
                y_true[b, k, j, i, 4] = 1
                y_true[b, k, j, i, c + 5] = 1
            else:
                #----------------------------------------#
                #   tx、ty代表中心调整参数的真实值
                #----------------------------------------#
                y_true[b, k, j, i, 0] = batch_target[t, 0]
                y_true[b, k, j, i, 1] = batch_target[t, 1]
                y_true[b, k, j, i, 2] = batch_target[t, 2]
                y_true[b, k, j, i, 3] = batch_target[t, 3]
                y_true[b, k, j, i, 4] = 1
                y_true[b, k, j, i, c + 5] = 1
bubbliiiing commented 2 years ago

建议你看看yolov4