Skip to content
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

Question regarding MIL loss #2

Closed
WeiChihChern opened this issue Jan 16, 2023 · 4 comments
Closed

Question regarding MIL loss #2

WeiChihChern opened this issue Jan 16, 2023 · 4 comments

Comments

@WeiChihChern
Copy link

In mask-auto-labeler/models/mal.py,

Line 420:
# Multiple instance learning Loss
loss_mil = self.mil_loss(student_seg_sigmoid, mask)

The mask in self.mil_loss(student_seg_sigmoid, mask) is from line 410, where mask = F.interpolate(x['mask'], size=(oh, ow), mode='bilinear', align_corners=False).reshape(-1, oh, ow)

I wonder does this mean we are not only using bbox but also ground truth masks during training? Thank you.

@WeiChihChern
Copy link
Author

WeiChihChern commented Jan 16, 2023

Is x['mask'] basically a tight bbox of 1s?

@hongyeob-kim
Copy link

hongyeob-kim commented Jan 16, 2023

@WeiChihChern

I'm not the author but If you check below lines in mask-auto-labeler/datasets/voc.py, x['mask'] is simply box shaped masking filled with 1.
Is this what you are looking for?

# box mask
mask = np.zeros((h, w))
bbox = ann['bbox']
x0, y0, x1, y1 = int(bbox[0]), int(bbox[1]), int(bbox[0] + bbox[2]), int(bbox[1] + bbox[3])
mask[y0:y1+1, x0:x1+1] = 1
data = {'image': img, 'mask': mask, 'height': h, 'width': w,
'category_id': ann['category_id'], 'bbox': np.array([bbox[0], bbox[1], bbox[0] + bbox[2], bbox[1] + bbox[3]], dtype=np.float32),
'compact_category_id': self.cat_mapping[int(ann['category_id'])],
'id': ann['id']}

@WeiChihChern
Copy link
Author

@hongyeob-kim Good find, thanks.

@voidrank
Copy link
Contributor

Hi @WeiChihChern @hongyeob-kim ,

Thanks for asking and answering this question. It’s not a good idea to use mask for box-shaped mask. I will put this in the readme and maybe change the name in the future.

Best

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

3 participants