lhoyer / improving_segmentation_with_selfsupervised_depth

[CVPR21] Implementation of our work "Three Ways to Improve Semantic Segmentation with Self-Supervised Depth Estimation"
247 stars 30 forks source link

Is labelIds image necessary in training on custom dataset? #13

Closed Jisu-Choe closed 2 years ago

Jisu-Choe commented 2 years ago

Hello @lhoyer

We are trying to train the model with our custom dataset but we faced this error. It says that we need labelIds image which we do not have. Is it necessary to have the labelIds images to train your model? If so, how can we get them? Is it possible to convert color label images to label Id images? ( We only have color labeled images now.)

Traceback (most recent call last): File "run_experiments.py", line 101, in train.train_main(cfg) File "/media/ais/b9685cf9-7a96-4207-a8bd-0db240b0b60b/lhoyer/improv_seg/train.py", line 963, in train_main trainer.train() File "/media/ais/b9685cf9-7a96-4207-a8bd-0db240b0b60b/lhoyer/improv_seg/train.py", line 766, in train for inputs in self.train_data_loader: File "/home/ais/anaconda3/envs/3ways/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 521, in next data = self._next_data() File "/home/ais/anaconda3/envs/3ways/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1203, in _next_data return self._process_data(data) File "/home/ais/anaconda3/envs/3ways/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 1229, in _process_data data.reraise() File "/home/ais/anaconda3/envs/3ways/lib/python3.7/site-packages/torch/_utils.py", line 425, in reraise raise self.exc_type(msg) FileNotFoundError: Caught FileNotFoundError in DataLoader worker process 0. Original Traceback (most recent call last): File "/home/ais/anaconda3/envs/3ways/lib/python3.7/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop data = fetcher.fetch(index) File "/home/ais/anaconda3/envs/3ways/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/ais/anaconda3/envs/3ways/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/media/ais/b9685cf9-7a96-4207-a8bd-0db240b0b60b/lhoyer/improv_seg/loader/sequence_segmentation_loader.py", line 218, in getitem inputs["lbl"] = self.get_segmentation(index, do_flip) File "/media/ais/b9685cf9-7a96-4207-a8bd-0db240b0b60b/lhoyer/improv_seg/loader/sequence_segmentation_loader.py", line 155, in get_segmentation lbl = pil_loader(lbl_path, self.width, self.height, is_segmentation=True) File "/media/ais/b9685cf9-7a96-4207-a8bd-0db240b0b60b/lhoyer/improv_seg/loader/loader_utils.py", line 43, in pil_loader return load_fn(path, is_segmentation, True, std_width, std_height) File "/media/ais/b9685cf9-7a96-4207-a8bd-0db240b0b60b/lhoyer/improv_seg/loader/loader_utils.py", line 26, in _load with open(_path, 'rb') as f: FileNotFoundError: [Errno 2] No such file or directory: 'datasets/Cityscapes/gtFine/train/Label13/Label13_00gtFine_labelIds.png'

lhoyer commented 2 years ago

The CityscapesLoader also works with color labels as can be seen in https://github.com/lhoyer/improving_segmentation_with_selfsupervised_depth/blob/e6b602922ed280d748f876ee390c6e6a790cee17/loader/cityscapes_loader.py#L88.

Just make sure that the colors defined in Cityscapes.colors match your label colors: https://github.com/lhoyer/improving_segmentation_with_selfsupervised_depth/blob/e6b602922ed280d748f876ee390c6e6a790cee17/loader/cityscapes_loader.py#L15