Я создал файл формы .h5 для .pb, используя:
def freeze_session(session, keep_var_names=None, output_names=None, clear_devices=True):
from tensorflow.python.framework.graph_util import convert_variables_to_constants
graph = session.graph
with graph.as_default():
freeze_var_names = list(set(v.op.name for v in tf.global_variables()).difference(keep_var_names or []))
output_names = output_names or []
print(output_names)
#output_names += [v.op.name for v in tf.global_variables()]
print(output_names)
# Graph -> GraphDef ProtoBuf
input_graph_def = graph.as_graph_def()
if clear_devices:
for node in input_graph_def.node:
node.device = ""
#output_graph_def= convert_variables_to_constants(session,input_graph_def,output_node_names.split(","))
frozen_graph = convert_variables_to_constants(session, input_graph_def,
output_names, freeze_var_names)
#print(frozen_graph.input)
#print(output_graph_def)
return frozen_graph
frozen_graph = freeze_session(K.get_session(),
output_names=[out.op.name for out in model.outputs])
tf.train.write_graph(frozen_graph, "/content/drive/My Drive/model", "final_model.pb", as_text=False)
при преобразовании .dlc с использованием SNPE-1.31.0 Я получаю эту ошибку:
2019-11-04 14:36:18,000 - 175 - WARNING - Option: '--dlc' is DEPRECATED and will be removed in upcoming release. Please use '--output_path', '-o'
2019-11-04 14:36:18,000 - 175 - WARNING - Option: '--graph' is DEPRECATED and will be removed in upcoming release. Please use '--input_path', '-i'
2019-11-04 14:36:18.001569: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2019-11-04 14:36:25.114553: W tensorflow/core/framework/op_kernel.cc:1202] OP_REQUIRES failed at function_ops.cc:80 : Internal: Retval[1522] has already been set.
2019-11-04 14:36:25.114674: W tensorflow/core/framework/op_kernel.cc:1202] OP_REQUIRES failed at function_ops.cc:80 : Internal: Retval[1528] has already been set.
2019-11-04 14:36:25.114742: W tensorflow/core/framework/op_kernel.cc:1202] OP_REQUIRES failed at function_ops.cc:80 : Internal: Retval[1527] has already been set.
2019-11-04 14:36:25.114823: W tensorflow/core/framework/op_kernel.cc:1202] OP_REQUIRES failed at function_ops.cc:80 : Internal: Retval[1523] has already been set.
2019-11-04 14:36:25.114886: W tensorflow/core/framework/op_kernel.cc:1202] OP_REQUIRES failed at function_ops.cc:80 : Internal: Retval[1524] has already been set.
2019-11-04 14:36:25.114990: W tensorflow/core/framework/op_kernel.cc:1202] OP_REQUIRES failed at function_ops.cc:80 : Internal: Retval[1553] has already been set.
2019-11-04 14:36:25.115067: W tensorflow/core/framework/op_kernel.cc:1202] OP_REQUIRES failed at function_ops.cc:80 : Internal: Retval[1550] has already been set.
2019-11-04 14:36:25.115145: W tensorflow/core/framework/op_kernel.cc:1202] OP_REQUIRES failed at function_ops.cc:80 : Internal: Retval[1556] has already been set.
2019-11-04 14:36:25.179434: W tensorflow/core/framework/op_kernel.cc:1202] OP_REQUIRES failed at function_ops.cc:80 : Internal: Retval[1551] has already been set.
2019-11-04 14:36:25.675460: W tensorflow/core/framework/op_kernel.cc:1202] OP_REQUIRES failed at function_ops.cc:80 : Internal: Retval[1554] has already been set.
2019-11-04 14:36:25.676226: W tensorflow/core/framework/op_kernel.cc:1202] OP_REQUIRES failed at function_ops.cc:80 : Internal: Retval[1530] has already been set.
2019-11-04 14:36:25.676299: W tensorflow/core/framework/op_kernel.cc:1202] OP_REQUIRES failed at function_ops.cc:80 : Internal: Retval[1529] has already been set.
2019-11-04 14:36:25,681 - 411 - WARNING - ERROR_TF_FALLBACK_TO_ONDEMAND_EVALUATION: Unable to resolve operation output shapes in single pass. Using on-demand evaluation!
2019-11-04 14:36:25,799 - 170 - INFO - INFO_ALL_BUILDING_NETWORK:
Building Network
2019-11-04 14:36:25,799 - 170 - INFO - INFO_TF_BUILDING_INPUT_LAYER: Building layer (INPUT) with node: input_1_2, shape [1, 224, 224, 3]
**2019-11-04 14:37:23,803 - 165 - ERROR - Conversion failed: Cannot find bboxes or scores**
**Configuration for training model:**
Keras: 2.2.4
Tensorflow 1.19.0
Python 3.6
:::output format : .H5
**Configuration for .h5 to .pb (keras to tensorflow) :**
Keras: 2.2.4
Tensorflow: 1.16.0
Python: 2.7
**Configuration for .pb to .dlc :**
Command for conversion:
***snpe-tensorflow-to-dlc --graph /home/chandan/Documents/snpe/models/out_model1.pb --input_dim input_1 1,224,224,3 --out_node filtered_detections/map/TensorArrayStack/TensorArrayGatherV3 --out_node filtered_detections/map/TensorArrayStack_1/TensorArrayGatherV3 --out_node filtered_detections/map/TensorArrayStack_2/TensorArrayGatherV3 --dlc /home/chandan/Documents/snpe/models/out_model1.dlc --allow_unconsumed_nodes***
Using SNPE: Snapdragon Neural Processing Engine SDK
SNPE. snpe-1.31.0.522
Python: 2.7
Tensorflow: 1.16.0
Keras: 2.2.4
**- > ERROR - Conversion failed: Cannot find bboxes or scores**