About setting “NUM_CLASSES: 15 #only used in set criterion”
Thank you so much for sharing your work, this model is really amazing, so I'm excited to try your model on my dataset. My data set is in a format similar to VOC2012, so I didn't have any problems following your instructions step by step. only the configuration "NUM_CLASSES: 15 #only used in set criterion" in the FreeSeg/configs/voc-11k-15/mask2former_R50_bs16_20k.yaml configuration file confused me. There are only 4 classes in my data set, so the configuration of the number of classes in the previous configuration file was changed to 4, and the code did not report an error, but here I changed the code to 4 and reported an error: RuntimeError: weight tensor should be defined either for all or no classes, and then modify it back to 15 (which obviously doesn't match the number of classes in my dataset), but the code magically works, and the training output is a staggering nine sets of evaluation loss values, This, too, puzzles me. In addition, I noticed your comment after the configuration, but I did not understand the reason, I hope you can solve my confusion in your busy schedule, thank you very much!
I found the problem after trying to and violence to solve the (may not be reasonable, but works), in FreeSeg/mask2former/modeling/criterion. Py file has the following code:
if self.use_ignore_idx:
loss_ce = F.cross_entropy(
src_logits.transpose(1, 2),
target_classes,
ignore_index=self.num_classes,
)
else:
if "empty_weight" in outputs:
empty_weight = torch.cat(
[outputs["empty_weight"], self.empty_weight[-1:]]
).detach()
else:
empty_weight = self.empty_weight
loss_ce = F.cross_entropy(
src_logits.transpose(1, 2), target_classes, empty_weight
)
I guess this piece of code is a judgment when calculating loss for ignoring classes. There is something wrong with the weight parameter empty_weight assigned to each class when ignoring classes are not used (that is, all classes participate in loss calculation). There may be something wrong with the parameter I configured, but I can't find the problem. In the end, I simply deleted this parameter. Anyway, all categories are involved in loss calculation, and the weight of each category is equal, so this part of the function is not needed.
# loss_ce = F.cross_entropy(
# src_logits.transpose(1, 2), target_classes, empty_weight
# )
loss_ce = F.cross_entropy(
src_logits.transpose(1, 2), target_classes
)
请问你的自定义数据集效果如何,我按照作者reamdeme每一步跑通了,但是效果很差你的prompt也是训练16000iter就可以了吗