From d14b2008882b23b5326cc21c4d24199a7a7e0d7c Mon Sep 17 00:00:00 2001 From: LinGeLin <1057445597@qq.com> Date: Thu, 1 Aug 2024 21:30:04 +0800 Subject: [PATCH] Make sure the path to save onnx zip file exist Signed-off-by: LinGeLin <1057445597@qq.com> --- tf2onnx/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tf2onnx/utils.py b/tf2onnx/utils.py index 3bbb7639f..7f2f53daa 100644 --- a/tf2onnx/utils.py +++ b/tf2onnx/utils.py @@ -292,6 +292,9 @@ def save_onnx_model(save_path_root, onnx_file_name, feed_dict, model_proto, incl def save_onnx_zip(target_path, model_proto, external_tensor_storage): + dir_name = os.path.dirname(target_path) + if dir_name: + os.makedirs(dir_name, exist_ok=True) with zipfile.ZipFile(target_path, 'w') as z: z.writestr("__MODEL_PROTO.onnx", model_proto.SerializeToString()) for k, v in external_tensor_storage.name_to_tensor_data.items():