junfu1115/DANet

Convert the Cityscapes dataset to 19 categories

rinawhale opened this issue ยท 18 comments

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 !!

  • Clone this repository https://github.com/freedrone/cityscapes-scripts for python3.6
  • Go to the cityscapesscripts/preparation folder.
  • Edit createTrainIdLabelImgs.py , line 68 to dst = f.replace( "_polygons.json" , "_trainIds.png" ).
  • Check the cityscapes Path.
    Run the code.

@chichilicious Exactly! Yet another example:

  • Clone this repository https://github.com/mcordts/cityscapesScripts/tree/master/cityscapesscripts. The author seems to use python 2. There would be import error for python 3.
  • In cityscapesscripts/preparation/createTrainIdLabelImgs.py, replace dst = f.replace( "_polygons.json" , "_labelTrainIds.png" ) with dst = f.replace( "_polygons.json" , "_trainIds.png" ), for DANet format in datasets/cityscapes/train_fine.txt and datasets/cityscapes/val_fine.txt.
  • Run CITYSCAPES_DATASET=/mnt/data-1/data/houjing.huang/Dataset/cityscapes /mnt/data-1/data/houjing.huang/Software/anaconda2/bin/python2.7 cityscapesscripts/preparation/createTrainIdLabelImgs.py. Note to set your CITYSCAPES_DATASET and your Python executable here.

@chichilicious @huanghoujing Thank you for your help, I have successfully converted the dataset, but I have another problem as below. I have run python setup.py install and install torch-encoding module, I am confused......
File "train.py", line 19, in <module> from encoding.nn import SegmentationMultiLosses ImportError: cannot import name 'SegmentationMultiLosses'

Hi,
Go to your site-packages of the python version you are running from and checking the encodings directory to check if that particular file exists.

Hi, thank you for your reply!!
Do I need to install the torch-encoding module, I found that this module already exists in the code ~/DANet/encoding , but there is an error when import encoding, how can I fix it?

`Traceback (most recent call last):
File "train.py", line 16, in
from encoding.utils import create_logger
ImportError: No module named 'encoding'

@rinawhale Do you run it with python 2 or 3?

@huanghoujing Hi, I run it with python 3.5, I just installed the module torch-encoding, then I found when I use the dataset cityscapes, the dataset/init.py can't not be used for cityscapes. So I uninstall torch-encoding module. But I still cannot import encoding......

You only have to run python setup.py install in this project's main directory, no need to install the original torch-encoding package from HangZhang's repository.

Thank you sooooo much, I have run the code successfully @_@!!

@rinawhale This modification https://github.com/freedrone/cityscapes-scripts of the official cityscapes scripts comes with error-prone modification in cityscapesscripts/helpers/labels.py. Make sure you have the correct labels.py if you use this modified version. Refer to #17 (comment).

You only have to run python setup.py install in this project's main directory, no need to install the original torch-encoding package from HangZhang's repository.

hi, huanghoujing,

I have met the same problem.

Traceback (most recent call last):
File "train.py", line 20, in
from encoding.nn import SegmentationMultiLosses
ImportError: cannot import name 'SegmentationMultiLosses'

how can I solve this? The python version I use is 3.6. Thanks.

hi @junfu1115 @chichilicious and @huanghoujing
i have a question, since the cityscapes dataset already has the images, whose paths end with _labelIds.png, why we need to convert them to new images whose paths end with trainIds.png?

btw, are those end with labelTrainIds.png the same as those end with trainIds.png?

@chichilicious @huanghoujing Hello! I'm new too,Thanks for your advice,but I follow your advice then I met this problem,do you know how to fix it?Thanks very much!

Traceback (most recent call last): File "/home/echostronger/a111/DANet/datasets/cityscapes/cityscapesScripts/cityscapesscripts/preparation/createTrainIdLabelImgs.py", line 27, in <module> from cityscapesscripts.helpers.csHelpers import printError ImportError: No module named 'cityscapesscripts'

@chichilicious @rinawhale @huanghoujing
For the Cityscapes dataset, why do we first convert it to 19 categories rather than directly using the original one?
The question maybe too simple and I'm still looking forword to your replying if you have enough time.

@chichilicious @huanghoujing Hello! I'm new too,Thanks for your advice,but I follow your advice then I met this problem,do you know how to fix it?Thanks very much!

Traceback (most recent call last): File "/home/echostronger/a111/DANet/datasets/cityscapes/cityscapesScripts/cityscapesscripts/preparation/createTrainIdLabelImgs.py", line 27, in <module> from cityscapesscripts.helpers.csHelpers import printError ImportError: No module named 'cityscapesscripts'

Hey have you solved this? I met this problem too.

@chichilicious @huanghoujing Hello! I'm new too,Thanks for your advice,but I follow your advice then I met this problem,do you know how to fix it?Thanks very much!
Traceback (most recent call last): File "/home/echostronger/a111/DANet/datasets/cityscapes/cityscapesScripts/cityscapesscripts/preparation/createTrainIdLabelImgs.py", line 27, in from cityscapesscripts.helpers.csHelpers import printError ImportError: No module named 'cityscapesscripts'

Hey have you solved this? I met this problem too.

That is because you do not run the commend in the file including cityscapesscripts

@chichilicious @huanghoujing Hello! I'm new too,Thanks for your advice,but I follow your advice then I met this problem,do you know how to fix it?Thanks very much!
Traceback (most recent call last): File "/home/echostronger/a111/DANet/datasets/cityscapes/cityscapesScripts/cityscapesscripts/preparation/createTrainIdLabelImgs.py", line 27, in from cityscapesscripts.helpers.csHelpers import printError ImportError: No module named 'cityscapesscripts'

You should run the commend in the file that include cityscapesscripts

@chichilicious @huanghoujing Hello! I'm new too,Thanks for your advice,but I follow your advice then I met this problem,do you know how to fix it?Thanks very much!

Traceback (most recent call last): File "/home/echostronger/a111/DANet/datasets/cityscapes/cityscapesScripts/cityscapesscripts/preparation/createTrainIdLabelImgs.py", line 27, in <module> from cityscapesscripts.helpers.csHelpers import printError ImportError: No module named 'cityscapesscripts'

use PyCharm to open the folder cityscapesScripts as a project, then edit and run createTrainIdLabelImgs.py