def log_verbose(folder_path, name_prefix=""): verbose_filename = name_prefix + 'verbose' gitdiff_filename = name_prefix + 'gitdiff' f = tf_open_file_in_path(folder_path, verbose_filename, "w") f.write(" ".join(sys.argv) + '\n') f.write(get_flags() + '\n') write_git_revision(f) f.close() f = tf_open_file_in_path(folder_path, gitdiff_filename, "wb") write_gitdiff(f) f.close()
def print_parse(unused_args): model_path = FLAGS.search_model_json_path parse_search_dir = FLAGS.parse_search_dir model_args, _ = get_model_args_and_gparams(model_path, None) tf.logging.info(model_args) stages_args = parse_netarch.parse_stages_args(parse_search_dir, base_model_args=model_args) model_args.stages_args = stages_args parse_dir = FLAGS.parse_search_dir f = tf_open_file_in_path(parse_dir, FLAGS.parse_json_name + '.json', 'w') json.dump(model_args, f, indent=4, ensure_ascii=False) tf.logging.info(model_args)
def main(unused_argv): save_json_name = FLAGS.save_json_name orig_img_size = FLAGS.input_image_size model_args = io_utils.load_json_as_attrdict(FLAGS.model_json_path) img_size = math_utils.round_to_multiple_of( orig_img_size * FLAGS.resol_coefficient, FLAGS.img_divisor) params_dict = {key: getattr(FLAGS, key) for key in ['filters_divisor']} global_params = GlobalParams(**params_dict) model_args = compound_scale(model_args, global_params, FLAGS.width_coefficient, FLAGS.depth_coefficient, orig_img_size, FLAGS.depth_list) model_args.img_size = img_size f = io_utils.tf_open_file_in_path(FLAGS.save_dir, save_json_name, 'w') json.dump(model_args, f, indent=4, ensure_ascii=False)
def get_model_args_and_gparams(model_json_path, override_params): """ Gets model_args from json file. Supports both tensorflow-style stages_args and more human-readable style. """ model_json = json.load(tf_open_file_in_path("", model_json_path, "r"), object_pairs_hook=AttrDict) model_args = AttrDict(model_json) decoder = BlockArgsDecoder() model_args.stages_args = decoder.decode_to_stages_args( model_args.stages_args) gparams_dict = parse_gparams_from_model_args(model_args) global_params = GlobalParams(**gparams_dict) if override_params: global_params = global_params._replace(**override_params) tf.logging.info('global_params= %s', global_params) tf.logging.info('stages_args= %s', model_args.stages_args) return model_args, global_params
def save_model_args(model_args, model_dir, filename='scaled_model_args.json'): f = tf_open_file_in_path(model_dir, filename, 'w') json.dump(model_args, f, indent=4, ensure_ascii=False)