error in using saved model for inference
my system config: os : windows10 gpu : nvidia-1070 tensorflow-gpu==1.14 i use this script like documentation: python model_inspect.py --runmode=saved_model_infer --model_name=efficientdet-d0 --ckpt_path="C:\Users\Ava\Desktop\automl\efficientdet\models\efficientdet-d0" --max_boxes_to_draw=100 --min_score_thresh=0.2 --line_thickness=4 --saved_model_dir="C:\Users\Ava\Desktop\automl\efficientdet\tmp\saved_model" --input_image=testdata/img1.jpg --output_image_dir="C:\Users\Ava\Desktop\automl\efficientdet\tmp"
then i faced with this error:
W tensorflow/core/framework/op_kernel.cc:1490] Invalid argument: ValueError: callback pyfunc_0 is not found
how can i solve it?
please FULL error log
Traceback (most recent call last):
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/ops/script_ops.py", line 198, in __call__
raise ValueError("callback %s is not found" % token)
ValueError: callback pyfunc_0 is not found
Traceback (most recent call last):
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1356, in _do_call
return fn(*args)
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1341, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1429, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found.
(0) Invalid argument: ValueError: callback pyfunc_0 is not found
Traceback (most recent call last):
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/ops/script_ops.py", line 198, in __call__
raise ValueError("callback %s is not found" % token)
ValueError: callback pyfunc_0 is not found
[[{{node PyFunc}}]]
[[PyFunc/_3999]]
(1) Invalid argument: ValueError: callback pyfunc_0 is not found
Traceback (most recent call last):
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/ops/script_ops.py", line 198, in __call__
raise ValueError("callback %s is not found" % token)
ValueError: callback pyfunc_0 is not found
[[{{node PyFunc}}]]
0 successful operations.
0 derived errors ignored.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "inference_video.py", line 108, in <module>
inference_single_image(image_path=image_path, output_dir=output_dir) #, image_size=image_size)
File "inference_video.py", line 81, in inference_single_image
detections_bs = sess.run('detections:0', {'image_arrays:0': raw_images})
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 950, in run
run_metadata_ptr)
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1173, in _run
feed_dict_tensor, options, run_metadata)
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1350, in _do_run
run_metadata)
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1370, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found.
(0) Invalid argument: ValueError: callback pyfunc_0 is not found
Traceback (most recent call last):
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/ops/script_ops.py", line 198, in __call__
raise ValueError("callback %s is not found" % token)
ValueError: callback pyfunc_0 is not found
[[node PyFunc (defined at inference_video.py:49) ]]
[[PyFunc/_3999]]
(1) Invalid argument: ValueError: callback pyfunc_0 is not found
Traceback (most recent call last):
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/ops/script_ops.py", line 198, in __call__
raise ValueError("callback %s is not found" % token)
ValueError: callback pyfunc_0 is not found
[[node PyFunc (defined at inference_video.py:49) ]]
0 successful operations.
0 derived errors ignored.
Original stack trace for 'PyFunc':
File "inference_video.py", line 108, in <module>
inference_single_image(image_path=image_path, output_dir=output_dir) #, image_size=image_size)
File "inference_video.py", line 49, in inference_single_image
tf.saved_model.load(sess, ['serve'], ckpt_path)
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py", line 324, in new_func
return func(*args, **kwargs)
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/saved_model/loader_impl.py", line 269, in load
return loader.load(sess, tags, import_scope, **saver_kwargs)
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/saved_model/loader_impl.py", line 422, in load
**saver_kwargs)
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/saved_model/loader_impl.py", line 352, in load_graph
meta_graph_def, import_scope=import_scope, **saver_kwargs)
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/training/saver.py", line 1473, in _import_meta_graph_with_return_elements
**kwargs))
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/framework/meta_graph.py", line 857, in import_scoped_meta_graph_with_return_elements
return_elements=return_elements)
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/util/deprecation.py", line 507, in new_func
return func(*args, **kwargs)
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/framework/importer.py", line 443, in import_graph_def
_ProcessNewOps(graph)
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/framework/importer.py", line 236, in _ProcessNewOps
for new_op in graph._add_new_tf_operations(compute_devices=False): # pylint: disable=protected-access
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 3751, in _add_new_tf_operations
for c_op in c_api_util.new_tf_operations(self)
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 3751, in <listcomp>
for c_op in c_api_util.new_tf_operations(self)
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 3641, in _create_op_from_tf_operation
ret = Operation(c_op, self)
File "/home/vakko/.local/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 2005, in __init__
self._traceback = tf_stack.extract_stack()
The original checkpoint was exported to SavedModel according to the instructions in Example 3 of the ServingDriver class; however I had to set disable_pyfun=False when exporting to .pb simply because i would otherwise face this issue: https://github.com/google/automl/issues/267
@mingxingtan Can you shed some light in, please.. The above log is from TF 1.14.0; Is there a way to get a working .pb without keeping pyfun enabled or should I just switch to TF 2?
Hi @vakkov , you cannot export a saved graph with disable_pyfun=False (because python function is not savable). I recommend you installing the latest TF2.1.0 as shown in our tutorial. Thanks!