leap-model-parser 0.1.242__tar.gz → 0.1.243.dev1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/PKG-INFO +3 -3
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/model_parser.py +47 -6
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/pyproject.toml +1 -1
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/LICENSE +0 -0
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/README.md +0 -0
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/__init__.py +0 -0
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/contract/__init__.py +0 -0
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/contract/graph.py +0 -0
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/contract/importmodelresponse.py +0 -0
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/contract/nodedata.py +0 -0
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/contract/ui_components.json +0 -0
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/keras_json_model_import.py +0 -0
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/leap_graph_editor.py +0 -0
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/utils/__init__.py +0 -0
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/utils/layerpedia/__init__.py +0 -0
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/utils/layerpedia/layerpedia.py +0 -0
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/utils/tlinspection/__init__.py +0 -0
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/utils/tlinspection/leapinspection.py +0 -0
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/utils/uicomponents/__init__.py +0 -0
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/utils/uicomponents/generatenodedata.py +0 -0
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/utils/uicomponents/tensorflowinscpection.py +0 -0
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/utils/uicomponents/ui_components.json +0 -0
- {leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/utils/uicomponents/ui_components_config.yaml +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
2
|
Name: leap-model-parser
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.243.dev1
|
|
4
4
|
Summary:
|
|
5
|
+
Home-page: https://github.com/tensorleap/leap-model-parser
|
|
5
6
|
License: MIT
|
|
6
7
|
Author: idan
|
|
7
8
|
Author-email: idan.yogev@tensorleap.ai
|
|
@@ -20,7 +21,6 @@ Requires-Dist: onnx2kerastl (==0.0.186)
|
|
|
20
21
|
Requires-Dist: tensorflow (==2.12.0) ; platform_machine == "x86_64"
|
|
21
22
|
Requires-Dist: tensorflow-io-gcs-filesystem (==0.34.0)
|
|
22
23
|
Requires-Dist: tensorflow-macos (==2.12.0) ; platform_machine == "arm64"
|
|
23
|
-
Project-URL: Homepage, https://github.com/tensorleap/leap-model-parser
|
|
24
24
|
Project-URL: Repository, https://github.com/tensorleap/leap-model-parser
|
|
25
25
|
Description-Content-Type: text/markdown
|
|
26
26
|
|
{leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/model_parser.py
RENAMED
|
@@ -34,7 +34,46 @@ if spec is not None:
|
|
|
34
34
|
import onnx # type: ignore
|
|
35
35
|
|
|
36
36
|
onnx_imported = True
|
|
37
|
-
|
|
37
|
+
#Deal with broken models
|
|
38
|
+
GIT_LFS_CONTENT = b"version https://git-lfs.github.com/spec/v1"
|
|
39
|
+
|
|
40
|
+
class InvalidModelFile(Exception):
|
|
41
|
+
pass
|
|
42
|
+
|
|
43
|
+
def _is_git_lfs_pointer(path: str) -> bool:
|
|
44
|
+
try:
|
|
45
|
+
with open(path, "rb") as f:
|
|
46
|
+
return f.read(128).startswith(GIT_LFS_CONTENT)
|
|
47
|
+
except OSError:
|
|
48
|
+
return False
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _text_snippet(path: str, n: int = 200) -> Optional[str]:
|
|
52
|
+
try:
|
|
53
|
+
with open(path, "rb") as f:
|
|
54
|
+
b = f.read(n)
|
|
55
|
+
if b"\x00" in b:
|
|
56
|
+
return None
|
|
57
|
+
s = b.decode("utf-8", errors="replace").strip()
|
|
58
|
+
return s or None
|
|
59
|
+
except OSError:
|
|
60
|
+
return None
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _raise_model_file_error(path: str, kind: str, original_exc: Exception) -> None:
|
|
64
|
+
suffix = Path(path).suffix
|
|
65
|
+
if _is_git_lfs_pointer(path):
|
|
66
|
+
raise InvalidModelFile(
|
|
67
|
+
f"This {suffix} file is a Git LFS pointer, not the actual model binary. "
|
|
68
|
+
"Run `git lfs pull` (or re-download the artifact) to fetch the real file."
|
|
69
|
+
) from original_exc
|
|
70
|
+
snippet = _text_snippet(path)
|
|
71
|
+
if snippet is not None:
|
|
72
|
+
raise InvalidModelFile(
|
|
73
|
+
f"The provided model is not a real {kind} model binary although its suffix is {suffix}. "
|
|
74
|
+
f"File's content starts with:\n{snippet}."
|
|
75
|
+
) from original_exc
|
|
76
|
+
raise InvalidModelFile(f"Failed to open {kind} model file: {original_exc}") from original_exc
|
|
38
77
|
|
|
39
78
|
class ModelParser:
|
|
40
79
|
def __init__(self, should_transform_inputs_and_outputs=False,
|
|
@@ -135,7 +174,10 @@ class ModelParser:
|
|
|
135
174
|
if not onnx_imported:
|
|
136
175
|
raise OnnxUnsupported()
|
|
137
176
|
|
|
138
|
-
|
|
177
|
+
try:
|
|
178
|
+
onnx_model = onnx.load_model(file_path)
|
|
179
|
+
except Exception as e:
|
|
180
|
+
_raise_model_file_error(file_path, "onnx", e)
|
|
139
181
|
input_all = [_input.name for _input in onnx_model.graph.input]
|
|
140
182
|
input_initializer = [
|
|
141
183
|
node.name for node in onnx_model.graph.initializer]
|
|
@@ -153,10 +195,9 @@ class ModelParser:
|
|
|
153
195
|
try:
|
|
154
196
|
return load_model(file_path, custom_objects=custom_objects, compile=False)
|
|
155
197
|
except OSError as e:
|
|
156
|
-
if
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
raise e
|
|
198
|
+
if "signature" in str(e):
|
|
199
|
+
_raise_model_file_error(file_path, "keras", e)
|
|
200
|
+
raise
|
|
160
201
|
|
|
161
202
|
def convert_h5_model(self, file_path: str) -> Tuple[Dict[str, Node], Model, Optional[str]]:
|
|
162
203
|
imported_model = self._load_keras_model_with_custom_layers(file_path)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/contract/__init__.py
RENAMED
|
File without changes
|
{leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/contract/graph.py
RENAMED
|
File without changes
|
|
File without changes
|
{leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/contract/nodedata.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/leap_graph_editor.py
RENAMED
|
File without changes
|
{leap_model_parser-0.1.242 → leap_model_parser-0.1.243.dev1}/leap_model_parser/utils/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|