def main(): args = parse_args() cfg, model_name = _trim(get_config(args.config, show=False), args) print(f"Building model({model_name})...") model = build_model(cfg) assert osp.isfile( args.pretrained_params ), f"pretrained params ({args.pretrained_params} is not a file path.)" if not os.path.isdir(args.output_path): os.makedirs(args.output_path) print(f"Loading params from ({args.pretrained_params})...") params = paddle.load(args.pretrained_params) model.set_dict(params) model.eval() model = to_static(model, input_spec=[ paddle.static.InputSpec(shape=[ None, args.num_seg, 3, args.img_size, args.img_size ], dtype='float32'), ]) paddle.jit.save(model, osp.join(args.output_path, model_name)) print( f"model ({model_name}) has been already saved in ({args.output_path}).")
def main(): args = parse_args() cfg, model_name = _trim(get_config(args.config, show=False)) print(f"Building model({model_name})...") model = build_model(cfg) params_info = paddle.summary(model, (1, 8, 3, 224, 224)) print(params_info)
def main(): args = parse_args() cfg = get_config(args.config, overrides=args.override) dataset = build_dataset((cfg.DATASET.test, cfg.PIPELINE.test)) _, world_size = get_dist_info() parallel = world_size != 1 if parallel: paddle.distributed.init_parallel_env() model = build_model(cfg.MODEL) test_model(model, dataset, cfg, args.weights, world_size)
def main(): args = parse_args() cfg, model_name = _trim(get_config(args.config, show=False), args) print(f"Building model({model_name})...") model = build_model(cfg) img_size = args.img_size num_seg = args.num_seg #NOTE: only support tsm now, will refine soon params_info = paddle.summary(model, (1, num_seg, 3, img_size, img_size)) print(params_info) if args.FLOPs: flops_info = paddle.flops(model, [1, num_seg, 3, img_size, img_size], print_detail=True) print(flops_info)
def main(): args = parse_args() cfg, model_name = trim_config(get_config(args.config, show=False)) print(f"Building model({model_name})...") model = build_model(cfg.MODEL) assert osp.isfile( args.pretrained_params ), f"pretrained params ({args.pretrained_params} is not a file path.)" if not os.path.isdir(args.output_path): os.makedirs(args.output_path) print(f"Loading params from ({args.pretrained_params})...") params = paddle.load(args.pretrained_params) model.set_dict(params) model.eval() input_spec = get_input_spec(cfg.INFERENCE, model_name) model = to_static(model, input_spec=input_spec) paddle.jit.save(model, osp.join(args.output_path, model_name)) print( f"model ({model_name}) has been already saved in ({args.output_path}).")