DrSleep / tensorflow-deeplab-resnet

DeepLab-ResNet rebuilt in TensorFlow
MIT License
1.25k stars 429 forks source link

py_func: list out of range #151

Closed SharonZhu closed 6 years ago

SharonZhu commented 6 years ago

When I started to run train.py, an error occurred: UnknownError (see above for traceback): IndexError: list index out of range [[Node: PyFunc_1 = PyFunc[Tin=[DT_UINT8, DT_INT32, DT_INT32], Tout=[DT_UINT8], token="pyfunc_1", _device="/job:localhost/replica:0/task:0/cpu:0"](create_inputs/batch:1, PyFunc_1/input_1, PyFunc_1/input_2)]]

It seemed that the py_func used in summary part has some problems. Could someone help me handle it? Thanks a lot.

DrSleep commented 6 years ago

where does that occur exactly? more information would be helpful

yuqian1023 commented 6 years ago

Hi,

I just met the similar problem. It occurs when I change to use my own dataset, which I have already processed following the instruction. The error is : (there are 47 categories in my new dataset) UnknownError (see above for traceback): exceptions.IndexError: list index out of range [[Node: PyFunc_1 = PyFunc[Tin=[DT_UINT8, DT_INT32, DT_INT32], Tout=[DT_UINT8], token="pyfunc_1", _device="/job:localhost/replica:0/task:0/cpu:0"](create_inputs/batch:1, PyFunc_1/input_1, PyFunc_1/input_2)]]

Here is the setting: IMG_MEAN = np.array((225.0, 225.0, 225.0), dtype=np.float32) BATCH_SIZE = 10 DATA_DIRECTORY = '/import/data/Segmentation/train/image/' DATA_LIST_PATH = './dataset/train_cartoon.txt' IGNORE_LABEL = 255 INPUT_SIZE = '750,750' LEARNING_RATE = 2.5e-4 MOMENTUM = 0.9 NUM_CLASSES = 47 NUM_STEPS = 20001 POWER = 0.9 RANDOM_SEED = 1234 RESTORE_FROM = './checkpoints/deeplab_resnet.ckpt' SAVE_NUM_IMAGES = 2 SAVE_PRED_EVERY = 1000 SNAPSHOT_DIR = './snapshots/' WEIGHT_DECAY = 0.0005

Do you have any idea about this problem? Thank you for your potential help!

yuqian1023 commented 6 years ago

@DrSleep

Kimyoonkyoung commented 6 years ago

I just met the similar problem. I think it's occur when using different num of class dataset.. I'm using 32 categories in my dataset. I suspect there is a problem with importing the pre-trained model(resnet-101), like here(https://github.com/DrSleep/tensorflow-deeplab-resnet#using-your-dataset) at 6, but I do not know how to solve it.

Could you help me? And Thank you shared code :) @DrSleep

Kimyoonkyoung commented 6 years ago

Oh! I solved it! @SharonZhu @yuchuochuo1023

I was wrongly predicting.

The pre-trained model(resnet-101) is not problem The model does not include the fc layer.


In the error log.. included

File "/root/tensorflow-deeplab-v3-master/deeplab_model.py", line 181, in deeplabv3_model_fn
    [labels, params['batch_size'], params['num_classes']], tf.uint8)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/script_ops.py", line 212, in py_funcinput=inp, token=token, Tout=Tout, name=name)

So, the session that in _deeplabmodel.py

gt_decoded_labels = tf.py_func(preprocessing.decode_labels, [labels, params['batch_size'], params['num_classes']], tf.uint8)

and function _[decodelabels] at preprocessing.py

  for i in range(num_images):
    img = Image.new('RGB', (len(mask[i, 0]), len(mask[i])))
    pixels = img.load()
    for j_, j in enumerate(mask[i, :, :, 0]):
      for k_, k in enumerate(j):
        if k < num_classes:                        <<<<<< Here is problem!!!
          pixels[k_, j_] = label_colours[k]
    outputs[i] = np.array(img)

In conclusion, You can modify the [label colur] list in preprocessing.py to learn the other class numbers.

DrSleep commented 6 years ago

which is written in README, if you read it carefully: https://github.com/DrSleep/tensorflow-deeplab-resnet#using-your-dataset