def test_yolo_class_masking(setup_y_true_tensor, setup_true_box_tensor): # 1. setup y_true placeholder # 2. setup y_true feed value y_true, y_true_value = setup_y_true_tensor true_box_class, true_box_class_value = setup_true_box_tensor # 3. create coord_mask operation yolo_mask = _Mask(nb_class=4, coord_scale=1.0, class_scale=1.0, object_scale=5.0, no_object_scale=1.0) class_mask_op = yolo_mask.create_class_mask(y_true, true_box_class) # 4. run loss_op in session class_mask_value = run_op(class_mask_op, feed_dict={ y_true: y_true_value, true_box_class: true_box_class_value }) # coordinate mask value : (N, grid, grid, nb_box) # object �� �ִ� (grid_x, grid_y, anchor_idx) ���� 1, �������� 0 expected_class_mask = np.zeros((1, 9, 9, 5)) expected_class_mask[0, 4, 3, 2] = 1.0 expected_class_mask[0, 4, 4, 2] = 1.0 assert np.allclose(class_mask_value, expected_class_mask)
def test_yolo_conf_masking(setup_y_true_tensor, setup_true_boxes_tensor, setup_y_pred_tensor): y_true, y_true_value = setup_y_true_tensor true_boxes, true_boxes_value = setup_true_boxes_tensor y_pred, y_pred_value = setup_y_pred_tensor yolo_mask = _Mask(nb_class=4, coord_scale=1.0, class_scale=1.0, object_scale=5.0, no_object_scale=1.0) conf_mask_op = yolo_mask.create_conf_mask(y_true, y_pred, batch_size=1) conf_mask_value = run_op(conf_mask_op, feed_dict={y_true:y_true_value, true_boxes: true_boxes_value, y_pred:y_pred_value}) expected_conf_mask_value = np.ones((1,9,9,5)) expected_conf_mask_value[0,4,3,2] = 5 expected_conf_mask_value[0,4,4,2] = 5 assert np.allclose(conf_mask_value, expected_conf_mask_value)
def test_yolo_coord_masking(setup_y_true_tensor): # 1. setup y_true placeholder # 2. setup y_true feed value y_true, y_true_value = setup_y_true_tensor # 3. create coord_mask operation yolo_mask = _Mask(nb_class=4, coord_scale=1.0, class_scale=1.0, object_scale=5.0, no_object_scale=1.0) coord_mask_op = yolo_mask.create_coord_mask(y_true) # 4. run loss_op in session coord_mask_value = run_op(coord_mask_op, feed_dict={y_true: y_true_value}) # coordinate mask value : (N, grid, grid, nb_box, 1) # object �� �ִ� (grid_x, grid_y, anchor_idx) ���� 1, �������� 0 expected_coord_mask = np.zeros((1,9,9,5,1)) expected_coord_mask[0, 4, 3, 2, :] = 1.0 expected_coord_mask[0, 4, 4, 2, :] = 1.0 assert np.allclose(coord_mask_value, expected_coord_mask)