hellochick / ICNet-tensorflow

TensorFlow-based implementation of "ICNet for Real-Time Semantic Segmentation on High-Resolution Images".
405 stars 153 forks source link

InvalidArgumentError: assertion failed: #90

Open ShunLu91 opened 5 years ago

ShunLu91 commented 5 years ago

I have successfully run the train.py but when I run the evaluate.py an error occurred like this:

InvalidArgumentError (see above for traceback): assertion failed: [labels out of bound] [Condition x < y did not hold element-wise:] [x (mean_iou/confusion_matrix/control_dependency:0) = ] [3 3 3...] [y (mean_iou/ToInt64_1:0) = ] [19] [[{{node mean_iou/confusion_matrix/assert_less/Assert/AssertGuard/Assert}} = Assert[T=[DT_STRING, DT_STRING, DT_STRING, DT_INT64, DT_STRING, DT_INT64], summarize=3, _device="/job:localhost/replica:0/task:0/device:CPU:0"](mean_iou/confusion_matrix/assert_less/Assert/AssertGuard/Assert/Switch/_289, mean_iou/confusion_matrix/assert_less/Assert/AssertGuard/Assert/data_0, mean_iou/confusion_matrix/assert_less/Assert/AssertGuard/Assert/data_1, mean_iou/confusion_matrix/assert_less/Assert/AssertGuard/Assert/data_2, mean_iou/confusion_matrix/assert_less/Assert/AssertGuard/Assert/Switch_1/_291, mean_iou/confusion_matrix/assert_less/Assert/AssertGuard/Assert/data_4, mean_iou/confusion_matrix/assert_less/Assert/AssertGuard/Assert/Switch_2/_293)]]

I have searched the Internet for the solutions but nothing worked.I really want to know why this error happened because I used the official cityscapes datasets and I didn't made any modification. I would be appreciate if someone can help me find out the problem.Thanks again!

MarcSchotman commented 5 years ago

This is due to that your labels aren't in the correct format. From the README:

sudo pip install cityscapesscripts
export CITYSCAPES_DATASET=<cityscapes dataset path>
csCreateTrainIdLabelImgs

Then to actually use these images I made a list using the same format as in /data/list/ade20k_train_list.txt You can do something like:

def make_list(path, list_name):
    with open(list_name, 'w') as f:

        for (dirpath, dirnames, filenames) in os.walk(path):
            for filename in filenames:
                if filename.endswith(file_ending_lbl): 

                    lbl = os.path.join(dirpath, filename) 
                    img = lbl.replace(file_ending_lbl, "leftImg8bit.png" )
                    img = img.replace("gtCoarse", "leftImg8bit")

                    f.write( img + " " + lbl + "\n")

file_ending_lbl = 'gtCoarse_labelTrainIds.png'

#CREATE cityscapes_train_list.txt
path = "/some/path/cityscapes/gtCoarse/train/"
list_name= "cityscapes_train_list.txt"
make_list(path,list_name)
print("Created ", path+list_name)

#CREATE cityscapes_val_list.txt
path = "/somepath/cityscapes/gtCoarse/val/"
list_name= "cityscapes_val_list.txt"
make_list(path,list_name)
print("Created ", path+list_name)
ShunLu91 commented 5 years ago

This is due to that your labels aren't in the correct format. From the README:

sudo pip install cityscapesscripts
export CITYSCAPES_DATASET=<cityscapes dataset path>
csCreateTrainIdLabelImgs

Then to actually use these images I made a list using the same format as in /data/list/ade20k_train_list.txt You can do something like:

def make_list(path, list_name):
  with open(list_name, 'w') as f:

      for (dirpath, dirnames, filenames) in os.walk(path):
          for filename in filenames:
              if filename.endswith(file_ending_lbl): 

                  lbl = os.path.join(dirpath, filename) 
                  img = lbl.replace(file_ending_lbl, "leftImg8bit.png" )
                  img = img.replace("gtCoarse", "leftImg8bit")

                  f.write( img + " " + lbl + "\n")

file_ending_lbl = 'gtCoarse_labelTrainIds.png'

#CREATE cityscapes_train_list.txt
path = "/some/path/cityscapes/gtCoarse/train/"
list_name= "cityscapes_train_list.txt"
make_list(path,list_name)
print("Created ", path+list_name)

#CREATE cityscapes_val_list.txt
path = "/somepath/cityscapes/gtCoarse/val/"
list_name= "cityscapes_val_list.txt"
make_list(path,list_name)
print("Created ", path+list_name)

Oh, extremely thanks! But I remember that when I download this code master there is no information about how to handle this dataset. However it appears today and I have successfully run the code!

Jingchensun commented 5 years ago

i have the same problem,when i have successfully trained my own dataset, next when I run the evaluate.py an error occurred like this:

InvalidArgumentError (see above for traceback): assertion failed: [height must be <= target - offset] [[Node: Assert_1/Assert = Assert[T=[DT_STRING], summarize=3, _device="/job:localhost/replica:0/task:0/device:CPU:0"](GreaterEqual_1, Assert_1/Assert/data_0)]]

i have try many method but can not work,why does this happen could you help me thank you very much!

ShunLu91 commented 5 years ago

i have the same problem,when i have successfully trained my own dataset, next when I run the evaluate.py an error occurred like this:

InvalidArgumentError (see above for traceback): assertion failed: [height must be <= target - offset] [[Node: Assert_1/Assert = Assert[T=[DT_STRING], summarize=3, _device="/job:localhost/replica:0/task:0/device:CPU:0"](GreaterEqual_1, Assert_1/Assert/data_0)]]

i have try many method but can not work,why does this happen could you help me thank you very much!

Have you ever tried the data processing method mentioned in the README? When I did that , there is no problem to run the evaluate.py. @Jingchensun