Exemplo n.º 1
0
def test_ssd300():
    context.set_context(mode=context.GRAPH_MODE, device_target="CPU")

    model = Model(ssd300_mobilenetv2())
    model.compile()
    loc, score = model.predict(ts.ones((1, 3, 300, 300)))
    print(loc.asnumpy(), score.asnumpy())
Exemplo n.º 2
0
                        device_target=args_opt.device_target)

    # download voc dataset
    if not args_opt.dataset_path:
        args_opt.dataset_path = download_dataset('voc')

    epoch_size = args_opt.epoch_size
    batch_size = args_opt.batch_size
    voc_path = args_opt.dataset_path
    dataset_sink_mode = not args_opt.device_target == "CPU"

    if not args_opt.do_eval:  # as for train, users could use model.train
        ds_train = create_dataset(voc_path, batch_size=batch_size)
        dataset_size = ds_train.get_dataset_size()
        # build the SSD300 network
        net = ssd300_mobilenetv2(class_num=args_opt.num_classes)
        # define the loss function
        if args_opt.device_target == "GPU":
            net.to_float(ts.float16)
        net = net_with_loss(net)
        init_net_param(net)
        # define the optimizer
        lr = ssd300_lr(global_step=args_opt.pre_trained_epoch_size *
                       dataset_size,
                       lr_init=0.001,
                       lr_end=0.001 * args_opt.lr,
                       lr_max=args_opt.lr,
                       warmup_epochs=2,
                       total_epochs=args_opt.epoch_size,
                       steps_per_epoch=dataset_size)
        loss_scale = 1.0 if args_opt.device_target == "CPU" else float(
Exemplo n.º 3
0
                        device_target=args_opt.device_target)

    # download voc dataset
    if not args_opt.dataset_path:
        args_opt.dataset_path = download_dataset('voc')

    epoch_size = args_opt.epoch_size
    batch_size = args_opt.batch_size
    voc_path = args_opt.dataset_path
    dataset_sink_mode = not args_opt.device_target == "CPU"

    if not args_opt.do_eval:  # as for train, users could use model.train
        ds_train = create_dataset(voc_path, batch_size=batch_size)
        dataset_size = ds_train.get_dataset_size()
        # build the SSD300 network
        net = ssd300_mobilenetv2(class_num=args_opt.num_classes)
        # define the loss function
        if args_opt.device_target == "GPU":
            net.to_float(ts.float16)
        net = net_with_loss(net)
        init_net_param(net)
        # define the optimizer
        lr = ssd300_lr(global_step=args_opt.pre_trained_epoch_size *
                       dataset_size,
                       lr_init=0.001,
                       lr_end=0.001 * args_opt.lr,
                       lr_max=args_opt.lr,
                       warmup_epochs=2,
                       total_epochs=args_opt.epoch_size,
                       steps_per_epoch=dataset_size)
        loss_scale = 1.0 if args_opt.device_target == "CPU" else float(