I am trying the SavedModel format export method #1079
Replies: 1 comment 3 replies
-
Hi @famy040326 👋, A workaround would be to follow the way we used in tests for onnx export: So the key is to set the arg exportable to True which skips the postprocessing and returns the raw logits (without applying sigmoid activation), then the model should be saved model exportable. https://github.com/mindee/doctr/blob/main/doctr/models/detection/differentiable_binarization/base.py
|
Beta Was this translation helpful? Give feedback.
-
I am trying the SavedModel format export method described in the link below.
However, I get an error and cannot execute it.
I would be grateful if you could help me with a solution.
https://mindee.github.io/doctr/using_doctr/using_model_export.html#using-savedmodel
import tensorflow as from doctr.models import db_resnet50 model = db_resnet50(pretrained=True) input_t = tf.random.uniform(shape=[1, 1024, 1024, 3], maxval=1, dtype=tf.float32) _ = model(input_t, training=False) tf.saved_model.save(model, './doctr_SavedModel/')
The following is the content of the error.
`Traceback (most recent call last):
File "", line 1, in
File "C:\Python_dev\env1\lib\site-packages\tensorflow\python\saved_model\save.py", line 1334, in save
save_and_return_nodes(obj, export_dir, signatures, options)
File "C:\Python_dev\env1\lib\site-packages\tensorflow\python\saved_model\save.py", line 1369, in save_and_return_nodes
_build_meta_graph(obj, signatures, options, meta_graph_def))
File "C:\Python_dev\env1\lib\site-packages\tensorflow\python\saved_model\save.py", line 1536, in _build_meta_graph
return _build_meta_graph_impl(obj, signatures, options, meta_graph_def)
File "C:\Python_dev\env1\lib\site-packages\tensorflow\python\saved_model\save.py", line 1477, in _build_meta_graph_impl
signatures = signature_serialization.find_function_to_export(
File "C:\Python_dev\env1\lib\site-packages\tensorflow\python\saved_model\signature_serialization.py", line 103, in find_function_to_export
for name, child in children:
File "C:\Python_dev\env1\lib\site-packages\tensorflow\python\saved_model\save.py", line 133, in list_children
super(_AugmentedGraphView, self).list_children(
File "C:\Python_dev\env1\lib\site-packages\tensorflow\python\training\tracking\graph_view.py", line 256, in list_children
in obj._trackable_children(save_type, **kwargs).items()]
File "C:\Python_dev\env1\lib\site-packages\tensorflow\python\training\tracking\base.py", line 1479, in _trackable_children
return self._get_legacy_saved_model_children(cache)
File "C:\Python_dev\env1\lib\site-packages\tensorflow\python\training\tracking\base.py", line 1490, in _get_legacy_saved_model_children
functions = self._list_functions_for_serialization(serialization_cache)
File "C:\Python_dev\env1\lib\site-packages\keras\engine\training.py", line 3081, in _list_functions_for_serialization
functions = super(
File "C:\Python_dev\env1\lib\site-packages\keras\engine\base_layer.py", line 3168, in _list_functions_for_serialization
return (self._trackable_saved_model_saver
File "C:\Python_dev\env1\lib\site-packages\keras\saving\saved_model\base_serialization.py", line 93, in list_functions_for_serialization
fns = self.functions_to_serialize(serialization_cache)
File "C:\Python_dev\env1\lib\site-packages\keras\saving\saved_model\layer_serialization.py", line 72, in functions_to_serialize
return (self._get_serialized_attributes(
File "C:\Python_dev\env1\lib\site-packages\keras\saving\saved_model\layer_serialization.py", line 88, in _get_serialized_attributes
object_dict, function_dict = self._get_serialized_attributes_internal(
File "C:\Python_dev\env1\lib\site-packages\keras\saving\saved_model\model_serialization.py", line 51, in _get_serialized_attributes_internal
default_signature = save_impl.default_save_signature(self.obj)
File "C:\Python_dev\env1\lib\site-packages\keras\saving\saved_model\save_impl.py", line 208, in default_save_signature
fn = saving_utils.trace_model_call(layer)
File "C:\Python_dev\env1\lib\site-packages\keras\saving\saving_utils.py", line 148, in trace_model_call
return _wrapped_model.get_concrete_function(*model_args, **model_kwargs)
File "C:\Python_dev\env1\lib\site-packages\tensorflow\python\eager\def_function.py", line 1264, in get_concrete_function
concrete = self._get_concrete_function_garbage_collected(*args, **kwargs)
File "C:\Python_dev\env1\lib\site-packages\tensorflow\python\eager\def_function.py", line 1244, in _get_concrete_function_garbage_collected
self._initialize(args, kwargs, add_initializers_to=initializers)
File "C:\Python_dev\env1\lib\site-packages\tensorflow\python\eager\def_function.py", line 785, in _initialize
self._stateful_fn._get_concrete_function_internal_garbage_collected( # pylint: disable=protected-access
File "C:\Python_dev\env1\lib\site-packages\tensorflow\python\eager\function.py", line 2983, in _get_concrete_function_internal_garbage_collected
graph_function, _ = self._maybe_define_function(args, kwargs)
File "C:\Python_dev\env1\lib\site-packages\tensorflow\python\eager\function.py", line 3292, in _maybe_define_function
graph_function = self._create_graph_function(args, kwargs)
File "C:\Python_dev\env1\lib\site-packages\tensorflow\python\eager\function.py", line 3130, in _create_graph_function
func_graph_module.func_graph_from_py_func(
File "C:\Python_dev\env1\lib\site-packages\tensorflow\python\framework\func_graph.py", line 1161, in func_graph_from_py_func
func_outputs = python_func(*func_args, **func_kwargs)
File "C:\Python_dev\env1\lib\site-packages\tensorflow\python\eager\def_function.py", line 677, in wrapped_fn
out = weak_wrapped_fn().wrapped(*args, **kwds)
File "C:\Python_dev\env1\lib\site-packages\tensorflow\python\framework\func_graph.py", line 1147, in autograph_handler
raise e.ag_error_metadata.to_exception(e)
AttributeError: in user code:
Beta Was this translation helpful? Give feedback.
All reactions