Skip to content

Update run_keras_server.py#8

Open
richardson-souza wants to merge 1 commit intojrosebr1:masterfrom
richardson-souza:richardson-souza-patch-1
Open

Update run_keras_server.py#8
richardson-souza wants to merge 1 commit intojrosebr1:masterfrom
richardson-souza:richardson-souza-patch-1

Conversation

@richardson-souza
Copy link
Copy Markdown

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