hfslyc / AdvSemiSeg

Adversarial Learning for Semi-supervised Semantic Segmentation, BMVC 2018
504 stars 129 forks source link

Facing Issue for running Adversarial Semi-Segmentation code on Custom dataset or CityScapes dataset #69

Open tasveerahmad opened 1 year ago

tasveerahmad commented 1 year ago

Hello everyone, Recently, I have managed to run the code correctly on Pascal VOC dataset, but when I tried to run the code on my own custom dataset or CityScape dataset, I am unable to run and faced debugging issues. Since I am working on python3.6, I made the following changes in the source code:

Also, I change the tensor type from gpu to cpu, e.g. images = Variable(images).cuda(args.gpu) to images = Variable(images).cpu(). As I searched on the internet, I noticed there might be some issue with the number of class. But then I guessed that I have correctly chosen the number of classes, as 30 classes in cityscapes case; or I changed the number of class to 31, but even then facing the same error. BTW, I'm running the code on GoogleColab, and it worked successfully for Pascal VOC dataset. The Error report is as below,

/usr/local/lib/python3.7/dist-packages/torch/optim/sgd.py:105: UserWarning: optimizer contains a parameter group with duplicate parameters; in future, this will cause an error; see github.com/pytorch/pytorch/issues/40967 for more information super(SGD, self).init(params, defaults) train.py:379: UserWarning: Implicit dimension choice for softmax has been deprecated. Change the call to include dim=X as an argument. D_out = interp(modelD(F.softmax(pred))) /usr/local/lib/python3.7/dist-packages/torch/nn/functional.py:1960: UserWarning: nn.functional.sigmoid is deprecated. Use torch.sigmoid instead. warnings.warn("nn.functional.sigmoid is deprecated. Use torch.sigmoid instead.") train.py:382: DeprecationWarning: np.bool is a deprecated alias for the builtin bool. To silence this warning, use bool by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool` here. Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations ignore_mask_remain = np.zeros(D_out_sigmoid.shape).astype(np.bool) /usr/local/lib/python3.7/dist-packages/torch/nn/_reduction.py:42: UserWarning: size_average and reduce args will be deprecated, please use reduction='mean' instead. warnings.warn(warning.format(ret)) pred_train = 88 label_train = 88 Traceback (most recent call last): File "train.py", line 524, in main() File "train.py", line 435, in main loss_seg = loss_calc(pred, labels) File "train.py", line 178, in loss_calc return criterion(pred, label) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "/content/drive/MyDrive/Tasweer_Research/Adversarial_Learning_Semi_supervised/AdvSemiSeg/utils/loss.py", line 49, in forward loss = F.cross_entropy(predict, target, weight=weight, size_average=self.size_average) File "/usr/local/lib/python3.7/dist-packages/torch/nn/functional.py", line 3014, in cross_entropy return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index, label_smoothing) IndexError: Target 119 is out of bounds.