Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

py_func: list out of range #151

Closed
SharonZhu opened this issue Dec 12, 2017 · 6 comments
Closed

py_func: list out of range #151

SharonZhu opened this issue Dec 12, 2017 · 6 comments

Comments

@SharonZhu
Copy link

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
Copy link
Owner

DrSleep commented Jan 9, 2018

where does that occur exactly? more information would be helpful

@yuqian1023
Copy link

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
Copy link

@DrSleep

@Kimyoonkyoung
Copy link

Kimyoonkyoung commented Feb 27, 2018

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
Copy link

Kimyoonkyoung commented Feb 27, 2018

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 deeplab_model.py

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

and function [decode_labels] 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
Copy link
Owner

DrSleep commented Apr 8, 2018

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants