rodrigo2019 / keras_yolo2

MIT License
46 stars 15 forks source link

Usage of _change_obj_position #28

Open DeepakChandra2612 opened 2 years ago

DeepakChandra2612 commented 2 years ago

In this portion of code from preprocessing.py:

 def _change_obj_position(self, y_batch, anchors_map, idx, box, iou):
        bkp_box = y_batch[idx[0], idx[1], idx[2], idx[3], 0:4].copy()**
        anchors_map[idx[0], idx[1], idx[2], idx[3]] = iou
        y_batch[idx[0], idx[1], idx[2], idx[3], 0:4] = box
        y_batch[idx[0], idx[1], idx[2], idx[3], 4] = 1.
        y_batch[idx[0], idx[1], idx[2], idx[3], 5:] = 0  # clear old values
        y_batch[idx[0], idx[1], idx[2], idx[3], 4 + 1 + idx[4]] = 1

        shifted_box = BoundBox(0, 0, bkp_box[2], bkp_box[3])**

        for i in range(len(self._anchors)):
            anchor = self._anchors[i]
            iou = bbox_iou(shifted_box, anchor)
            if iou > anchors_map[idx[0], idx[1], idx[2], i]:
                self._change_obj_position(y_batch, anchors_map, [idx[0], idx[1], idx[2], i, idx[4]], bkp_box, iou)
                break

The bkp_box is always zero as it is taken from initial y_batch which is zero. What is the use of this portion of code.

rodrigo2019 commented 2 years ago

just in the first iteration, it is a recursive function. self._change_obj_position(y_batch, anchors_map, [idx[0], idx[1], idx[2], i, idx[4]], bkp_box, iou) in this line, the function call itself again