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

add mask to loss #1

Merged
merged 4 commits into from
Oct 18, 2022
Merged

add mask to loss #1

merged 4 commits into from
Oct 18, 2022

Conversation

marouaneamz
Copy link

this pull request adds option of the mask to the loss which allows not to take into account images in the loss if they do not have labels for certain task

Copy link
Owner

@piercus piercus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marouaneamz please see inline comments

mmcls/datasets/pipelines/formatting.py Outdated Show resolved Hide resolved
mmcls/models/heads/multi_task_head.py Outdated Show resolved Hide resolved
@marouaneamz
Copy link
Author

marouaneamz commented Oct 12, 2022

I try to adapt the pipeline if there is no mask , but I can't do your method because we add the labels with the first if (if we haven't hardcoded the tasks here ), and in this block we add the labels and the maks we go through the whole results list and not all of them at once

Comment on lines 86 to 92
for k, v in results.items():
if k.endswith('_img_label'):
task = k[:-10]
gt_label[task] = to_tensor(v)
elif k.endswith('_mask'):
task = k[:-5]
gt_mask[task] = v
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for k, v in results.items():
if k.endswith('_img_label'):
task = k[:-10]
gt_label[task] = to_tensor(v)
elif k.endswith('_mask'):
task = k[:-5]
gt_mask[task] = v
for k, v in results.items():
if k.endswith('_img_label'):
task = k[:-10]
if task not in gt_label:
gt_label[task] = dict()
gt_label[task]['label'] = to_tensor(v)
elif k.endswith('_mask'):
task = k[:-5]
if task not in gt_label:
gt_label[task] = dict()
gt_label[task]['mask'] = v

@piercus piercus merged commit 8784684 into piercus:multi-task Oct 18, 2022
@marouaneamz marouaneamz deleted the add_mask_loss branch January 13, 2023 23:44
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

Successfully merging this pull request may close these issues.

2 participants