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

Update run_keras_server.py #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

richardson-souza
Copy link

when the flask server tries to process the prediction the errors happen:
raise ValueError("Tensor %s is not an element of this graph." % obj)
ValueError: Tensor Tensor("activation 5/Sigmoid:0", shape=(?, 1), dtype=float32) is not an element of this graph.
to get around the bug a global variable graph was created.
global model, graph
model = ResNet50(weights="imagenet")
graph = tf.get_default_graph()
And with default graph predictions were made:
with graph.as_default():
preds = model.predict(image)

when the flask server tries to process the prediction the errors happen:
raise ValueError("Tensor %s is not an element of this graph." % obj)
ValueError: Tensor Tensor("activation 5/Sigmoid:0", shape=(?, 1), dtype=float32) is not an element of this graph.
to get around the bug a global variable graph was created.
global model, graph
	model = ResNet50(weights="imagenet")
	graph = tf.get_default_graph()
And with default graph predictions were made:
with graph.as_default():
        preds = model.predict(image)
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

Successfully merging this pull request may close these issues.

1 participant