Skip to content

about iou #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
zhijiejia opened this issue Feb 8, 2021 · 1 comment
Open

about iou #5

zhijiejia opened this issue Feb 8, 2021 · 1 comment

Comments

@zhijiejia
Copy link

hi feevos, the result in your paper has IOU metric in table. Is the IOU metric for change only ? Or the IOU euqal mIOU for 2 classes

@feevos
Copy link
Owner

feevos commented Feb 8, 2021

Hi @zhijiejia, It is the IoU metric of the class "change" only, i.e. it does not account for the overlap in the background (no change) class. The code I used for calculating IoU over all test images for LEVIRCD is the following (note that in the inner product, 1 stands for change class, 0 for background, thefore, background does not contribute):

total_intersection = 0.0
total_union = 0.0
for name_pred, name_gt in zip(flnames_inf, flnames_gt):
    print ("Processing file:: {}".format(name_gt))
    with rasterio.open(name_pred,mode='r',driver='GTiff') as src1:
        pred = src1.read((1,2))
    pred = np.argmax(pred,0).astype(np.uint8)
    with rasterio.open(name_gt, driver='png',mode='r') as src:
        mask = src.read(1).astype(np.uint8)
    mask[mask>0]=1

    intersection = (pred*mask).sum()
    union = pred.sum() + mask.sum() - intersection
    
    total_intersection += intersection
    total_union += union

print (total_intersection/total_union)

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants