From 2f07922ec51f71d0eab08d07bab3394ab2f423e9 Mon Sep 17 00:00:00 2001 From: jsrimr Date: Mon, 14 Dec 2020 08:06:15 +0000 Subject: [PATCH] build_model -> build_mnasnet_model tf.contrib.lite -> tf.lite create tflite subdirectories if not exists --- runtime-modeling/main_tflite.py | 12 +++++++----- runtime-modeling/profiler_scripts.py | 4 +++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/runtime-modeling/main_tflite.py b/runtime-modeling/main_tflite.py index 7dd930e..41b4ff5 100644 --- a/runtime-modeling/main_tflite.py +++ b/runtime-modeling/main_tflite.py @@ -308,7 +308,7 @@ def gen_model_fn(features, labels, mode, params): if FLAGS.min_depth: override_params['min_depth'] = FLAGS.min_depth - logits, _ = models.build_model( + logits, _ = models.build_mnasnet_model( features, model_name=FLAGS.model_name, training=is_training, @@ -560,8 +560,9 @@ def export(est, export_dir, post_quantize=True): serving_input_receiver_fn=image_serving_input_fn) tf.logging.info('Starting to export TFLite.') - converter = tf.contrib.lite.TFLiteConverter.from_saved_model( - os.path.join(export_dir, subfolder), + converter = tf.lite.TFLiteConverter.from_saved_model( + # os.path.join(export_dir, str(subfolder)), + subfolder.decode(), input_arrays=['truediv'], output_arrays=['logits']) tflite_model = converter.convert() @@ -570,8 +571,9 @@ def export(est, export_dir, post_quantize=True): if post_quantize: tf.logging.info('Starting to export quantized TFLite.') - converter = tf.contrib.lite.TFLiteConverter.from_saved_model( - os.path.join(export_dir, subfolder), + converter = tf.lite.TFLiteConverter.from_saved_model( + # os.path.join(export_dir, subfolder), + subfolder.decode(), input_arrays=['truediv'], output_arrays=['logits']) converter.post_training_quantize = True diff --git a/runtime-modeling/profiler_scripts.py b/runtime-modeling/profiler_scripts.py index 799f97c..f7ea12c 100644 --- a/runtime-modeling/profiler_scripts.py +++ b/runtime-modeling/profiler_scripts.py @@ -43,13 +43,15 @@ def profiler_template(path): } return template -import sys, json +import os, sys, json if __name__ == '__main__': path = sys.argv[1] template = profiler_template(path) profiler_cfg_ = path + "profiler.json" + if not os.path.exists(os.path.dirname(profiler_cfg_)): + os.makedirs(os.path.dirname(profiler_cfg_)) with open(profiler_cfg_, 'w') as f: json.dump(template, f)