leap-model-parser 0.1.243.dev4__py3-none-any.whl → 0.1.243.dev6__py3-none-any.whl
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/model_parser.py +1 -48
- {leap_model_parser-0.1.243.dev4.dist-info → leap_model_parser-0.1.243.dev6.dist-info}/METADATA +1 -1
- {leap_model_parser-0.1.243.dev4.dist-info → leap_model_parser-0.1.243.dev6.dist-info}/RECORD +6 -6
- {leap_model_parser-0.1.243.dev4.dist-info → leap_model_parser-0.1.243.dev6.dist-info}/LICENSE +0 -0
- {leap_model_parser-0.1.243.dev4.dist-info → leap_model_parser-0.1.243.dev6.dist-info}/WHEEL +0 -0
- {leap_model_parser-0.1.243.dev4.dist-info → leap_model_parser-0.1.243.dev6.dist-info}/entry_points.txt +0 -0
|
@@ -99,54 +99,7 @@ class ModelParser:
|
|
|
99
99
|
def _add_output_node_shape_to_model_schema(model_schema: Dict, keras_model: Model):
|
|
100
100
|
for i, layer in enumerate(keras_model.layers):
|
|
101
101
|
model_schema['config']['layers'][i]['output_shape'] = list(layer.output_shape)
|
|
102
|
-
|
|
103
|
-
def get_keras_model_and_model_graph(
|
|
104
|
-
self, model_path: Path, model_type: ImportModelTypeEnum) -> Tuple[
|
|
105
|
-
Dict[str, Node], List[InputInfo], Optional[Model], Optional[str]]:
|
|
106
|
-
model_to_keras_converter: Optional[Callable[[str], Tuple[Dict[str, Node], Model, Optional[str]]]] = \
|
|
107
|
-
self._model_types_converter.get(model_type.value)
|
|
108
|
-
if model_to_keras_converter is None:
|
|
109
|
-
raise Exception(
|
|
110
|
-
f"Unable to import external version, {str(model_path)} file format isn't supported")
|
|
111
|
-
|
|
112
|
-
file_path = str(model_path)
|
|
113
|
-
model_schema, keras_model_with_weights, error_info = model_to_keras_converter(file_path)
|
|
114
|
-
|
|
115
|
-
self._add_output_node_shape_to_model_schema(model_schema, keras_model_with_weights)
|
|
116
|
-
|
|
117
|
-
model_generator = KerasJsonModelImport(self.custom_layers)
|
|
118
|
-
|
|
119
|
-
keras_model = keras_model_with_weights
|
|
120
|
-
if keras_model is None:
|
|
121
|
-
keras_model = tf.keras.models.model_from_json(json.dumps(model_schema))
|
|
122
|
-
layer_name_to_inbound_nodes = {
|
|
123
|
-
layer.name: layer.inbound_nodes
|
|
124
|
-
for layer in keras_model.layers
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
graph, connected_inputs = model_generator.generate_graph(
|
|
128
|
-
model_schema, layer_name_to_inbound_nodes)
|
|
129
|
-
# make sure input order is kept with original model
|
|
130
|
-
input_list = []
|
|
131
|
-
for inp in keras_model.inputs:
|
|
132
|
-
name = inp.name
|
|
133
|
-
name = name.replace(".", "_")
|
|
134
|
-
for inp_graph in connected_inputs:
|
|
135
|
-
if inp_graph.name == name:
|
|
136
|
-
input_list.append(inp_graph)
|
|
137
|
-
if self.mapping_connections is not None:
|
|
138
|
-
leap_graph_editor = LeapGraphEditor(graph, keras_model_with_weights)
|
|
139
|
-
leap_graph_editor.add_connections_to_graph(self.mapping_connections)
|
|
140
|
-
|
|
141
|
-
return graph, input_list, keras_model_with_weights, error_info
|
|
142
|
-
|
|
143
|
-
def _get_k_model_from_pb_path(self, file_path: str):
|
|
144
|
-
tar_file = tarfile.open(file_path)
|
|
145
|
-
with tempfile.TemporaryDirectory() as temp_dir:
|
|
146
|
-
tar_file.extractall(temp_dir)
|
|
147
|
-
pb_files = glob.glob(temp_dir + "/**/*.pb", recursive=True)
|
|
148
|
-
if len(pb_files) == 0:
|
|
149
|
-
raise Exception('no pb files were found')
|
|
102
|
+
pb files were found')
|
|
150
103
|
|
|
151
104
|
pb_file_path = next(iter(pb_files))
|
|
152
105
|
pb_folder_path = next(iter(ntpath.split(pb_file_path)))
|
{leap_model_parser-0.1.243.dev4.dist-info → leap_model_parser-0.1.243.dev6.dist-info}/RECORD
RENAMED
|
@@ -7,7 +7,7 @@ leap_model_parser/contract/nodedata.py,sha256=1_ML0nzp3QUZ0_9mGSLhfO4_hqjYMwi0DW
|
|
|
7
7
|
leap_model_parser/contract/ui_components.json,sha256=0lsxwOLElW1E-imCcdh3zKPWgzFuQ_bApG6aHvYfTvo,410591
|
|
8
8
|
leap_model_parser/keras_json_model_import.py,sha256=h9-eb41W67goutRV5c3VkStxvntgb6EmPFdPeshhtsY,17058
|
|
9
9
|
leap_model_parser/leap_graph_editor.py,sha256=s6iVO06xM6LJ8ZjSxkr1srYxsHhGl2KnQjQoc9g4_iE,14329
|
|
10
|
-
leap_model_parser/model_parser.py,sha256=
|
|
10
|
+
leap_model_parser/model_parser.py,sha256=gzrVLHZRpMK5Q_-vsAFORKTcPraim985vjeW-Fcw_Ng,7717
|
|
11
11
|
leap_model_parser/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
leap_model_parser/utils/layerpedia/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
13
|
leap_model_parser/utils/layerpedia/layerpedia.py,sha256=1syubfXBTB630TVkgcQ-Ge7Qe9Zbr6EtZRreuqCJnQ8,9292
|
|
@@ -18,8 +18,8 @@ leap_model_parser/utils/uicomponents/generatenodedata.py,sha256=LRaPlO5jJ9pUtkvL
|
|
|
18
18
|
leap_model_parser/utils/uicomponents/tensorflowinscpection.py,sha256=ym613z9iQKPDBpr0RYD35bTABdm1L-Ez86G47BYT7qw,6775
|
|
19
19
|
leap_model_parser/utils/uicomponents/ui_components.json,sha256=0lsxwOLElW1E-imCcdh3zKPWgzFuQ_bApG6aHvYfTvo,410591
|
|
20
20
|
leap_model_parser/utils/uicomponents/ui_components_config.yaml,sha256=cRH8T-c3TAL0nfefRvt9pFsjbTWNEg38NRyHR7RpJsk,19534
|
|
21
|
-
leap_model_parser-0.1.243.
|
|
22
|
-
leap_model_parser-0.1.243.
|
|
23
|
-
leap_model_parser-0.1.243.
|
|
24
|
-
leap_model_parser-0.1.243.
|
|
25
|
-
leap_model_parser-0.1.243.
|
|
21
|
+
leap_model_parser-0.1.243.dev6.dist-info/LICENSE,sha256=qIwWjdspQeSMTtnFZBC8MuT-95L02FPvzRUdWFxrwJY,1067
|
|
22
|
+
leap_model_parser-0.1.243.dev6.dist-info/METADATA,sha256=7aRvejx_HvQ2yG3bIEzciCfg0RgMUkrNyriurjejJfs,1109
|
|
23
|
+
leap_model_parser-0.1.243.dev6.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
24
|
+
leap_model_parser-0.1.243.dev6.dist-info/entry_points.txt,sha256=ZvV6EuQt1uAqwapNg5Lo2qjJM9ZG5g2wfzZoLh_Ztyk,77
|
|
25
|
+
leap_model_parser-0.1.243.dev6.dist-info/RECORD,,
|
{leap_model_parser-0.1.243.dev4.dist-info → leap_model_parser-0.1.243.dev6.dist-info}/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|