JunshengFu / semantic_segmentation

Semantically segment the road in the given image.
GNU General Public License v3.0
109 stars 41 forks source link

Unable to load saved model #7

Open Waffleboy opened 4 years ago

Waffleboy commented 4 years ago

Hello,

I cloned and followed the instructions, and put the saved model as specified.

Tried predicting images, and it crashes. Any ideas?

Restored the saved Model in file: ./model/model.ckpt
Predicting images...
Traceback (most recent call last):
  File "main.py", line 266, in <module>
    predict_images(test_data_path, print_speed=True)
  File "main.py", line 246, in predict_images
    helper.pred_samples(runs_dir, test_data_path, sess, image_shape, logits, keep_prob, input_image, print_speed)
  File "/storage/git/semantic_segmentation/helper.py", line 203, in pred_samples
    for name, image, speed_ in image_outputs:
  File "/storage/git/semantic_segmentation/helper.py", line 175, in gen_output
    {keep_prob: 1.0, image_pl: [image]})
  File "/storage/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 905, in run
    run_metadata_ptr)
  File "/storage/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1113, in _run
    str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (1, 576, 160, 4) for Tensor 'image_input:0', which has shape '(?, ?, ?, 3)'
DogukanAltay commented 4 years ago

That error caused by feeding 4-channel images to the network. You can solve the problem with the following fix.

In helper.py, after line 161 you should add line below:

image = scipy.misc.imresize(scipy.misc.imread(image_file), image_shape)
image = image[:, :, :3] # This line should be added.
startTime = time.clock()