YunYang1994 / tensorflow-yolov3

🔥 TensorFlow Code for technical report: "YOLOv3: An Incremental Improvement"
https://yunyang1994.gitee.io/2018/12/28/YOLOv3-算法的一点理解/
MIT License
3.63k stars 1.36k forks source link

code is wrong in image_preporcess() #562

Closed leo-XUKANG closed 4 years ago

leo-XUKANG commented 4 years ago

@YunYang1994 hello, i found some bug in utils.py
https://github.com/YunYang1994/tensorflow-yolov3/blob/eb02b0731dfb1c2614e216c619ac7b22db57d994/core/utils.py#L38

which will cause the xind or yind is bigger than the image input size, so i change it,

 if ((iw - nw) // 2) > 0:
        dw = np.random.randint(0, ((iw - nw) // 2))
    else:
        dw = (iw - nw) // 2
    if (ih - nh) // 2 > 0:
        dh = np.random.randint(0, (ih - nh) // 2)
    else:
        dh = (ih - nh) // 2
    image_paded[dh:nh+dh, dw:nw+dw, :] = image_resized
    image_paded = image_paded / 255.

    if gt_boxes is None:
        return image_paded
    else:
        gt_boxes[:, [0, 2]] = gt_boxes[:, [0, 2]] * nw / w + dw
        gt_boxes[:, [1, 3]] = gt_boxes[:, [1, 3]] * nh / h + dh
        return image_paded, gt_boxes