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

where you ignore labels of pixels belonging to unseen classes during training #5

Open
ghost opened this issue Dec 27, 2019 · 3 comments

Comments

@ghost
Copy link

ghost commented Dec 27, 2019

Thank you for sharing the useful code.

@subhc , as you discussed in article you consider all images during training, but pixels which relate to unseen classes will be ignored in calculating loss.

I completely explore your codes, but all classes are considered ( 0 to 15 for seen and 16 to 20 for unseen) for calculating loss.

I checked target tensor in this part which calculate loss. Some times in target we have pixels relate to unseen classes ( index from 16 to 20), but they are not ignored for calculating loss.

        for output in outputs:
            # Resize target for {100%, 75%, 50%, Max} outputs
            target_ = resize_target(target, output.size(2))
            target_ = torch.tensor(target_).to(device)
            loss += criterion.forward(output, target_)

Thank you for your answer

@qiang92
Copy link

qiang92 commented Dec 28, 2019

Their code ignored labels which is equal -1.
criterion = nn.CrossEntropyLoss(ignore_index=-1))

And they processed the target labels in their loader, which is "LoaderZLS".
It changed labels of unseen classes and background to -1 in file cocostuff.py.
tmp_label = label
if(self.visibility_mask is not None):
#2 ("novel {}".format(with_novel))
;label = self.visibility_mask[with_novel][tmp_label]

@ghost
Copy link
Author

ghost commented Dec 28, 2019

Thanks @qiang92 ,

I am using the code for fewshot.

I saw this part in cocostuff. But again when I print target unique indexes, there are some labels for unseen classes.

When i change inputmix input variable to 'seen' option (there are three options seen, novel, both), it is correct and there are not any unseen indexes in target tensor.

But in this situation, when fine tuning for few shots of novel classes happen (as discussed in paper )?

@ghost
Copy link
Author

ghost commented Dec 28, 2019

I noticed that when input mix is in 'both' option, code considers few shots of unseen (same shot for all iterations) classes during training. So, some times during training we have labels of unseen classes in target tensor.

As discussed in article, training few shots of unseen classes during training of seen classes is not best one. Fine tuning for unseen classes after training seen classes works better. But this code trains fewshots of unseen classes during training of seen classes.

I hope authors of article @subhc , write a better read me file for using this useful code.

@ghost ghost closed this as completed Dec 30, 2019
@ghost ghost reopened this Dec 30, 2019
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

1 participant