sacmehta / ESPNet

ESPNet: Efficient Spatial Pyramid of Dilated Convolutions for Semantic Segmentation
https://sacmehta.github.io/ESPNet/
MIT License
538 stars 111 forks source link

how to convert the Cityscapes dataset to 19 categories. #64

Closed TianMingChen closed 5 years ago

TianMingChen commented 5 years ago

Hi , I am new to segmentation field, and I meet the problem about how to convert the Cityscapes dataset to 19 categories. Look forward to your reply. Thank you !!

sacmehta commented 5 years ago

You need to follow the directions given on the Cityscapes repository.

See this file for more details:

https://github.com/mcordts/cityscapesScripts/blob/master/cityscapesscripts/preparation/createTrainIdLabelImgs.py

TianMingChen commented 5 years ago

You need to follow the directions given on the Cityscapes repository.

See this file for more details:

https://github.com/mcordts/cityscapesScripts/blob/master/cityscapesscripts/preparation/createTrainIdLabelImgs.py

when I run main.py,how should I to deal this problem? I have python createTrainIdLabelImgs.py image

image

sacmehta commented 5 years ago

You have 255 value in your label files. Use this file from ESPNetv2.

https://github.com/sacmehta/ESPNetv2/blob/master/segmentation/loadData.py

sacmehta commented 5 years ago

Also, use this Dataset.py file

https://github.com/sacmehta/ESPNetv2/blob/master/segmentation/DataSet.py

TianMingChen commented 5 years ago

Also, use this Dataset.py file

https://github.com/sacmehta/ESPNetv2/blob/master/segmentation/DataSet.py

I replace the two file ,but it still have such problem? image

sacmehta commented 5 years ago

You have 255 in labels. Please change loadData.py file as below.

Replace below code

unique_values = np.unique(label_img)
 # if you have 255 label in your label files, map it to the background class (19) in the Cityscapes dataset
if 255 in unique_values:
    label_img[label_img==255] = 19

with

unique_values = np.unique(label_img)
# if you have 255 label in your label files, map it to the background class (19) in the Cityscapes dataset
if 255 in unique_values:
    label_img[label_img==255] = 19
    unique_values = np.unique(label_img)
TianMingChen commented 5 years ago

You have 255 in labels. Please change loadData.py file as below.

Replace below code

unique_values = np.unique(label_img)
 # if you have 255 label in your label files, map it to the background class (19) in the Cityscapes dataset
if 255 in unique_values:
    label_img[label_img==255] = 19

with

unique_values = np.unique(label_img)
# if you have 255 label in your label files, map it to the background class (19) in the Cityscapes dataset
if 255 in unique_values:
  label_img[label_img==255] = 19
  unique_values = np.unique(label_img)

OK,the problem has been solved! Thank you ! And also when PyTorch>=0.5, the index of 0-dim tensor is invalid. The master branch is designed for PyTorch 0.4.1, loss.data[0] works well. Try to change epoch_loss.append(loss.data[0]) to epoch_loss.append(loss.data)

sacmehta commented 5 years ago

You should use loss.item() instead of loss.data for PyTorch version greater than 0.3

TianMingChen commented 5 years ago

You should use loss.item() instead of loss.data for PyTorch version greater than 0.3

OK,thanks!