DrSleep / tensorflow-deeplab-resnet

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

Training with unknown/variable image sizes #135

Closed markzampoglou closed 6 years ago

markzampoglou commented 7 years ago

I am trying to train the model with variable input image sizes. However, by setting: input_size = None in main(), I get:

Traceback (most recent call last):
  File "/.../tensorflow-deeplab-resnet/train.py", line 254, in <module>
    main()
  File "/.../tensorflow-deeplab-resnet/train.py", line 142, in main
    image_batch, label_batch = reader.dequeue(args.batch_size)
  File ".../tensorflow-deeplab-resnet/deeplab_resnet/image_reader.py", line 179, in dequeue
    image_batch, label_batch = tf.train.batch([self.image, self.label], num_elements)
  File "/.../python2.7/site-packages/tensorflow/python/training/input.py", line 922, in batch
    name=name)
  File "/.../python2.7/site-packages/tensorflow/python/training/input.py", line 707, in _batch
    capacity=capacity, dtypes=types, shapes=shapes, shared_name=shared_name)
  File "/.../python2.7/site-packages/tensorflow/python/ops/data_flow_ops.py", line 688, in __init__
    shapes = _as_shape_list(shapes, dtypes)
  File "/.../python2.7/site-packages/tensorflow/python/ops/data_flow_ops.py", line 76, in _as_shape_list
    raise ValueError("All shapes must be fully defined: %s" % shapes)
ValueError: All shapes must be fully defined: [TensorShape([Dimension(None), Dimension(None), Dimension(3)]), TensorShape([Dimension(None), Dimension(None), Dimension(1)])]

It seems the current approach, of defining a batch in dequeue() in image_reader.py, is incompatible with variable input image dimensions. Is it currently possible to train without fixed image dims?

DrSleep commented 6 years ago

i think you can use tf.shape outputs coupled with the set_shape function to achieve that. You'd better consult the tensorflow resources for that; this issue is out of scope of this repo.