Skip to content

Commit

Permalink
Enables multiple outputs for conversion to tensorflow (#766)
Browse files Browse the repository at this point in the history
  • Loading branch information
SmokerX authored and rainLiuplus committed Nov 6, 2019
1 parent e6d8c75 commit c1c748e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mmdnn/conversion/tensorflow/saver.py
Expand Up @@ -6,19 +6,20 @@ def save_model(MainModel, network_filepath, weight_filepath, dump_filepath, dump
tag_list = [tf.saved_model.tag_constants.SERVING]
else:
tag_list = [tf.saved_model.tag_constants.TRAINING]
input, model = MainModel.KitModel(weight_filepath)
res = MainModel.KitModel(weight_filepath)
input = res[0]
model = res[1:]
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())

builder = tf.saved_model.builder.SavedModelBuilder(dump_filepath)

tensor_info_input = tf.saved_model.utils.build_tensor_info(input)
tensor_info_output = tf.saved_model.utils.build_tensor_info(model)

outputs = {'output{}'.format(i): tf.saved_model.utils.build_tensor_info(model[i]) for i in range(len(model))}
prediction_signature = (
tf.saved_model.signature_def_utils.build_signature_def(
inputs={'input': tensor_info_input},
outputs={'output': tensor_info_output},
outputs=outputs,
method_name=tf.saved_model.signature_constants.PREDICT_METHOD_NAME
)
)
Expand Down

0 comments on commit c1c748e

Please sign in to comment.