2019-08-13 20:18:29 8 Comments
I get the error message that session graph is empty.. I have looked into different questions on stackoverflow page but nothing worked for me..
import os
import sys
import scipy.io
import scipy.misc
import matplotlib.pyplot as plt
from matplotlib.pyplot import imshow
from PIL import Image
from nst_utils import *
import numpy as np
import tensorflow as tf
model = load_vgg_model("imagenet-vgg-verydeep-19.mat")
tf.reset_default_graph()
# Start interactive session
sess = tf.InteractiveSession()
content_image = scipy.misc.imresize(arr = scipy.misc.imread("content.jpeg"), size=(300,400,3))
content_image = reshape_and_normalize_image(content_image)
style_image = scipy.misc.imresize(arr = scipy.misc.imread("monet.jpg"), size=(300,400,3))
style_image = reshape_and_normalize_image(style_image)
generated_image = generate_noise_image(content_image)
imshow(generated_image[0])
# Assign the content image to be the input of the VGG model.
with tf.Session() as sess:
sess.run(model['input'].assign(content_image))
I get "RuntimeError: The Session graph is empty. Add operations to the graph before calling run()." Appreciate every advise I can get :)
Related Questions
Sponsored Content
13 Answered Questions
26 Answered Questions
[SOLVED] Check if PHP session has already started
- 2011-06-06 09:00:51
- Logan
- 422800 View
- 439 Score
- 26 Answer
- Tags: php session session-variables
1 Answered Questions
[SOLVED] graph session empty error in Keras with Tensorflow backend
- 2018-03-09 15:04:46
- Rehan Aziz
- 1032 View
- 0 Score
- 1 Answer
- Tags: python tensorflow keras
1 Answered Questions
[SOLVED] Tensorflow: how to run prediction (using image as input) for a saved model?
- 2018-08-07 03:18:30
- Leo
- 3492 View
- 4 Score
- 1 Answer
- Tags: python tensorflow
14 Answered Questions
6 Answered Questions
[SOLVED] Do sessions really violate RESTfulness?
- 2011-05-20 06:13:09
- deceze
- 121981 View
- 473 Score
- 6 Answer
- Tags: session rest cookies restful-authentication
1 comments
@gorjan 2019-08-13 20:38:07
A couple of errors:
model = load_vgg_model("imagenet-vgg-verydeep-19.mat")
then reseting the default graphtf.reset_default_graph()
→ it should be the other way around.tf.InteractiveSession()
started and you are creating anothertf.Session()
→ You don't need the first one.This should work for you:
import os import sys import scipy.io import scipy.misc import matplotlib.pyplot as plt from matplotlib.pyplot import imshow from PIL import Image from nst_utils import * import numpy as np import tensorflow as tf
@Enyang Wang 2019-08-13 20:47:59
hi! thanks for all the advises, much appreciation! :) if i prefer to have the sess = tf.InteractiveSession() at the beginning, then I wouldnt need the 'with tf.Session() as sess:" statement, right?
@gorjan 2019-08-13 20:55:29
I updated my answer based on your feedback. Yes, you wouldn't need it. Assuming that your other functions are in order, this should work.
@Enyang Wang 2019-08-13 22:12:59
thanks a lot, much appreciation!