Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with the tutorial (https://modeldepot.io/hellochick/pspnet) - shapeless image #37

Open
PascalWB opened this issue May 20, 2018 · 1 comment

Comments

@PascalWB
Copy link

Thank you for all the input.
I have, however, problems to get the tutorial (https://modeldepot.io/hellochick/pspnet) running on my machine. Unfortunately, I'm very new to python.

Minimal example:
import tensorflow as tf
import numpy as np
from scipy import misc
import matplotlib.pyplot as plt

from PIL import Image

from model import PSPNet101, PSPNet50
from tools import *

image_path = './input/test1.png'

img_np, filename = load_img(image_path)
plt.imshow(img_np)


This leads to an error message:

_img_np, filename = load_img(image_path)
plt.imshow(img_np)
successful load img: ./input/test1.png
Traceback (most recent call last):

File "", line 2, in
plt.imshow(img_np)

File "C:\Anaconda3\lib\site-packages\matplotlib\pyplot.py", line 3080, in imshow
**kwargs)

File "C:\Anaconda3\lib\site-packages\matplotlib_init_.py", line 1710, in inner
return func(ax, *args, **kwargs)

File "C:\Anaconda3\lib\site-packages\matplotlib\axes_axes.py", line 5194, in imshow
im.set_data(X)

File "C:\Anaconda3\lib\site-packages\matplotlib\image.py", line 600, in set_data
raise TypeError("Image data cannot be converted to float")

TypeError: Image data cannot be converted to float_


The problem seems to be that img_np is shapeless:
img_np
Out[3]: <tf.Tensor 'DecodePng:0' shape=(?, ?, 3) dtype=uint8>


This issue is well discussed (tensorflow/tensorflow#9356), but I could not figure out the solution - does anybody has a hint?

I'd like to read in images of different sizes.

All the best,
Pascal

@PascalWB
Copy link
Author

PascalWB commented Jun 7, 2018

For anyone facing issues with the tutorial:

There are a couple of code lines missing. You have to run the session before plotting the images.

Insert:

Run and get result image

    preds = sess.run(pred)
    data = sess.run(img_np)

just before plotting.

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

No branches or pull requests

1 participant