Open zithiat opened 5 years ago
210 model_config = json.loads(model_config.decode('utf-8'))
211 model = model_config_lib.model_from_config(model_config,
ValueError: No model found in config file.``
please help... im not able to reuse :(((
Hi,
I'm using your amazing code, and able to make a prediction. However, I cannot re-use the loaded model from global scope. It told me to define the image path.
If I load model each request, the 1st request passed, and the 2nd request failed:
[2019-06-19 00:04:23,160] ERROR in app: Exception on /detection [POST] Traceback (most recent call last): File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1092, in _run subfeed, allow_tensor=True, allow_operation=False) File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3478, in as_graph_element return self._as_graph_element_locked(obj, allow_tensor, allow_operation) File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3557, in _as_graph_element_locked raise ValueError("Tensor %s is not an element of this graph." % obj) ValueError: Tensor Tensor("Placeholder:0", shape=(7, 7, 3, 64), dtype=float32) is not an element of this graph. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/conda/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "/opt/conda/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "/opt/conda/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "/opt/conda/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise raise value File "/opt/conda/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "/opt/conda/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/notebook/flask_app/App_fruit_detection.py", line 38, in dectect detector.loadModel(detection_speed="fast") File "/opt/conda/lib/python3.6/site-packages/imageai/Detection/__init__.py", line 185, in loadModel model.load_weights(self.modelPath) File "/opt/conda/lib/python3.6/site-packages/Keras-2.2.4-py3.6.egg/keras/engine/network.py", line 1166, in load_weights f, self.layers, reshape=reshape) File "/opt/conda/lib/python3.6/site-packages/Keras-2.2.4-py3.6.egg/keras/engine/saving.py", line 1059, in load_weights_from_hdf5_group K.batch_set_value(weight_value_tuples) File "/opt/conda/lib/python3.6/site-packages/Keras-2.2.4-py3.6.egg/keras/backend/tensorflow_backend.py", line 2470, in batch_set_value get_session().run(assign_ops, feed_dict=feed_dict) File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 929, in run run_metadata_ptr) File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1095, in _run 'Cannot interpret feed_dict key as Tensor: ' + e.args[0]) TypeError: Cannot interpret feed_dict key as Tensor: Tensor Tensor("Placeholder:0", shape=(7, 7, 3, 64), dtype=float32) is not an element of this graph. 209.152.96.166 - - [19/Jun/2019 00:04:23] "POST /detection HTTP/1.1" 500 -
I use global, it also prints error:
Running on http://0.0.0.0:5000/ (Press CTRL+C to quit) /notebook/flask_app/upload/car_1560902791.jpg /notebook/flask_app/output/car_1560902791.jpg [2019-06-19 00:06:31,660] ERROR in app: Exception on /detection [POST] Traceback (most recent call last): File "/opt/conda/lib/python3.6/site-packages/imageai/Detection/__init__.py", line 327, in detectObjectsFromImage _, _, detections = model.predict_on_batch(np.expand_dims(image, axis=0)) File "/opt/conda/lib/python3.6/site-packages/Keras-2.2.4-py3.6.egg/keras/engine/training.py", line 1273, in predict_on_batch self._make_predict_function() File "/opt/conda/lib/python3.6/site-packages/Keras-2.2.4-py3.6.egg/keras/engine/training.py", line 554, in _make_predict_function **kwargs) File "/opt/conda/lib/python3.6/site-packages/Keras-2.2.4-py3.6.egg/keras/backend/tensorflow_backend.py", line 2744, in function return Function(inputs, outputs, updates=updates, **kwargs) File "/opt/conda/lib/python3.6/site-packages/Keras-2.2.4-py3.6.egg/keras/backend/tensorflow_backend.py", line 2546, in __init__ with tf.control_dependencies(self.outputs): File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 5028, in control_dependencies return get_default_graph().control_dependencies(control_inputs) File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 4528, in control_dependencies c = self.as_graph_element(c) File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3478, in as_graph_element return self._as_graph_element_locked(obj, allow_tensor, allow_operation) File "/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3557, in _as_graph_element_locked raise ValueError("Tensor %s is not an element of this graph." % obj) ValueError: Tensor Tensor("regression/concat:0", shape=(?, ?, 4), dtype=float32) is not an element of this graph. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/opt/conda/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app response = self.full_dispatch_request() File "/opt/conda/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request rv = self.handle_user_exception(e) File "/opt/conda/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception reraise(exc_type, exc_value, tb) File "/opt/conda/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise raise value File "/opt/conda/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request rv = self.dispatch_request() File "/opt/conda/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "/notebook/flask_app/App_fruit_detection.py", line 40, in dectect detections = detector.detectObjectsFromImage(input_image=inputname, output_image_path=outputname) File "/opt/conda/lib/python3.6/site-packages/imageai/Detection/__init__.py", line 517, in detectObjectsFromImage raise ValueError("Ensure you specified correct input image, input type, output type and/or output image path ") ValueError: Ensure you specified correct input image, input type, output type and/or output image path
My code is below: