Closed umarjibrilmohd closed 9 months ago
Idx Ratio Train Val Name 1 1.02 1150 112 defect
this is my object information in txt file
because setting the number of classes to 2 and equating the pallet to the number of classes still leads to this /pytorch/aten/src/ATen/native/cuda/NLLLoss2d.cu:95: nll_loss2d_forward_kernel: block: [0,0,0], thread: [63,0,0] Assertion t >= 0 && t < n_classes
failed.
Traceback (most recent call last):
File "ssseg/train.py", line 261, in
all responses im getting are related to class label.
the below are some. It seems not only -1 but also class labels larger than n_classes are not allowed as t >= 0 && t < n_classes.
This is an error with your target labels: t >= 0 && t < n_classes. print your labels and make sure that they are positive and smaller than the number of outputs of your last layer. n_classes should be same as the output of the last layer.
can you please advice?
First check your labels, make sure there are only two classes in your dataset.
Next, make sure the ignore index consistent with yours. In SSSegmentation, the default ignore index is set as 255, you should change labels with -1 as 255
Finally, make sure the num classes you set in the config is the same as your dataset
sorry to ask again, be patient with me please, im new in the fireld, and you're really helping.
i prefer to maintain one class as my thermography images has only one class, which of the loss should i consider to fit my one class?
to my experience, cross entropy loss setting classes as 2 usually obtain similar performance to binary cross entropy loss. So both losses is ok.
the previous error has gone when i made the number of classes 2, now left with this. File "/home/mohammed/sssegmentation/ssseg/modules/datasets/ade20k.py", line 83, in
class ADE20kDataset(BaseDataset):
File "/home/mohammed/sssegmentation/ssseg/modules/datasets/ade20k.py", line 108, in ADE20kDataset
assert num_classes == len(classnames) and num_classes == len(palette)
AssertionError
ERROR:torch.distributed.elastic.multiprocessing.api:failed (exitcode: 1) local_rank: 0 (pid: 1615854) of binary: /home/mohammed/miniconda3/envs/myenv/bin/python
Traceback (most recent call last):
i set the number of classes as 2 which you can see below. class ADE20kDataset(BaseDataset): num_classes = 2 classnames = ['defect'] palette = [(255, 0, 255)] clsid2label = {0: 0}
when i set it like this
num_classes = 2
it leads to the previous error were it shows
t >= 0 && t < n_classes
failed.the below is how my scenecategory looks
NT_label_2 defect NT_label_1 defect NF_label_1 defect NF_label_0 defect N7_label_1 defect N7_label_0 defect N4_label_2 defect N4_label_1 defect N4_label_0 defect N3_label_3 defect N3_label_2 defect N3_label_1 defect N3_label_0 defect N2_label_2 defect N2_label_1 defect N2_label_0 defect N1_label_3 defect N1_label_2 defect N1_label_1 defect N1_label_0 defect m9614_label_9 defect m9614_label_8 defect M9287_label_6 defect M9287_label_4 defect M9287_label_3 defect M9287_label_1 defect M7436_label_8 defect M7436_label_6 defect M7436_label_2 defect