LED2-Net
LED2-Net copied to clipboard
Error in calculating IoU
HI, Thanks for your work. However, I recently found that there are unreasonable situations in calculating IoU, which may lead to errors.
Use image to calculate IoU in your code:
def IoU_2D(pred, gt, dummy_height1=None, dummy_height2=None):
intersect = np.sum(np.logical_and(pred, gt))
union = np.sum(np.logical_or(pred, gt))
iou_2d = intersect / union
return iou_2d
Calculate IoU using polygon in HorizonNet code:
dt_poly = Polygon(dt_floor_xy)
gt_poly = Polygon(gt_floor_xy)
# 2D IoU
area_dt = dt_poly.area
area_gt = gt_poly.area
area_inter = dt_poly.intersection(gt_poly).area
iou2d = area_inter / (area_gt + area_dt - area_inter)
When I set fp_meters=20 in config file:
Use the floor plan image to calculate IoU2D: 0.8690
Use the floor plan polygon to calculate IoU2D: 0.8722
Use the floor plan image to calculate IoU2D: 0.7491
Use the floor plan polygon to calculate IoU2D: 0.6429
It can be found that there is error in the different calculation.My test results show that the IOU calculated using images is generally greater than that calculated using polygon in Matterport3D's test dataset. I think one reason is that the radius of many layouts stored in the test set exceeds fp_meters, so they are not included in the floor plan image.
I tried to modify fp_meters to a larger value, but the error caused by pixel rounding is enlarged. When I set fp_meters=50 in config file:
Use the floor plan image to calculate IoU2D: 0.8934
Use the floor plan polygon to calculate IoU2D:0.8722