anishathalye / neural-style

Neural style in TensorFlow! 🎨
https://anishathalye.com/an-ai-that-can-mimic-any-artist/
GNU General Public License v3.0
5.54k stars 1.52k forks source link

Neural style transfer on TensorFlow #123

Closed sagar-m closed 6 years ago

sagar-m commented 6 years ago

Hi Anish, I tried neural style transfer on tensorflow, and I am stuck with the following error, not sure why. My implementation is almost exactly as it is in this link.Thanks!

tf.reset_default_graph()

sess = tf.InteractiveSession()

sess.run(tf.initialize_all_variables())

sess.run(model['input'].assign(content_image))
Traceback (most recent call last):

File "<ipython-input-103-ee79f3610a98>", line 1, in <module>
sess.run(model['input'].assign(content_image))

File "/Users/sherrymukim/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 889, in run
run_metadata_ptr)

File "/Users/sherrymukim/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1105, in _run
self._graph, fetches, feed_dict_tensor, feed_handles=feed_handles)

File "/Users/sherrymukim/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 414, in __init__
self._fetch_mapper = _FetchMapper.for_fetch(fetches)

File "/Users/sherrymukim/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 242, in for_fetch
return _ElementFetchMapper(fetches, contraction_fn)

File "/Users/sherrymukim/anaconda3/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 278, in __init__
'Tensor. (%s)' % (fetch, str(e)))

ValueError: Fetch argument <tf.tensor 'assign_5:0'="" shape="(1," 300,="" 400,="" 3)="" dtype="float32_ref"> cannot be interpreted as a Tensor. (Tensor Tensor("Assign_5:0", shape=(1, 300, 400, 3), dtype=float32_ref) is not an element of this graph.)
anishathalye commented 6 years ago

Oh hmm, for a moment, I thought you were asking about my implementation. I'm not the author of the blog post of chioka.in, so I can't provide support for it.

sagar-m commented 6 years ago

Hi, I noticed that you have also implemented NST on TensorFlow, and thus may have an idea on what is going wrong here! Thank you.

anishathalye commented 6 years ago

Your issue is not about neural style, it's a generic tensorflow issue. Googling "fetch argument is not an element of this graph" leads to this stackoverflow post (https://stackoverflow.com/questions/35826648/about-tensorflow-graph-what-am-i-wrong-with-this-program), which seems relevant to your problem.

sagar-m commented 6 years ago

Thanks a ton. I was googling the entire error statement, and thus never came across this post! Appreciate it.