show-attend-and-tell
show-attend-and-tell copied to clipboard
TyperError with prepro.py, "float() argument must be a string or number, not 'map' "
Hi there,
While running prepro.py, I have the following error in regards to this block of code:
for start, end in zip(range(0, n_examples, batch_size),
range(batch_size, n_examples + batch_size, batch_size)):
image_batch_file = image_path[start:end]
image_batch = np.array(map(lambda x: ndimage.imread(x, mode='RGB'), image_batch_file)).astype(
np.float32)
feats = sess.run(vggnet.features, feed_dict={vggnet.images: image_batch})
all_feats[start:end, :] = feats
print ("Processed {} {} features..".format(end, split))
Error traceback:
Traceback (most recent call last):
File "prepro.py", line 212, in <module>
main()
File "prepro.py", line 201, in main
np.float32)
TypeError: float() argument must be a string or a number, not 'map'
I am running all the code using Python 3.5.x and TensorFlow 1.2.1. I have tried to update most of the code in order for this to run problem-free.
Any thoughts on how I can fix this? I am assuming this may be an error since I am using a more recent version of Python + TF. Thanks!
Change the line :
image_batch = np.array(map(lambda x: ndimage.imread(x, mode='RGB'), image_batch_file)).astype(np.float32)
to
image_batch = np.array(list(map(lambda x: ndimage.imread(x, mode='RGB'), image_batch_file))).astype( np.float32)
i used:
image_batch = np.array(list(map(lambda x: imageio.imread(x,pilmode='RGB'), image_batch_file)),dtype=object).astype( np.float32)