コード例 #1
0
def main():
    """
    Main function to spawn the train and test process.
    """
    args = parse_args()
    cfg = load_config(args)

    # Perform multi-clip testing.
    if cfg.TEST.ENABLE:
        if cfg.NUM_GPUS > 1:
            torch.multiprocessing.spawn(
                mpu.run,
                nprocs=cfg.NUM_GPUS,
                args=(
                    cfg.NUM_GPUS,
                    test,
                    args.init_method,
                    cfg.SHARD_ID,
                    cfg.NUM_SHARDS,
                    cfg.DIST_BACKEND,
                    cfg,
                ),
                daemon=False,
            )
        else:
            test(cfg=cfg)
コード例 #2
0
def main():
    """
    Main function to spawn the train and test process.
    """
    args = parse_args()
    cfg = load_config(args)
    print('=' * 20)
    # print(cfg)
    print('Num of GPUs: ', cfg.NUM_GPUS)
    print(cfg.TRAIN)
    print(cfg.TEST)
    print('output dir is: ', cfg.OUTPUT_DIR)

    # Perform training.
    if cfg.TRAIN.ENABLE:
        print("begin to trian the model... ")
        if cfg.NUM_GPUS > 1:
            print('gpu is over 1')
            torch.multiprocessing.spawn(
                mpu.run,
                nprocs=cfg.NUM_GPUS,
                args=(
                    cfg.NUM_GPUS,
                    train,
                    args.init_method,
                    cfg.SHARD_ID,
                    cfg.NUM_SHARDS,
                    cfg.DIST_BACKEND,
                    cfg,
                ),
                daemon=False,
            )
        else:
            train(cfg=cfg)

    # Perform multi-clip testing.
    if cfg.TEST.ENABLE:
        print("begin to test the model... ")
        if cfg.NUM_GPUS > 1:
            torch.multiprocessing.spawn(
                mpu.run,
                nprocs=cfg.NUM_GPUS,
                args=(
                    cfg.NUM_GPUS,
                    test,
                    args.init_method,
                    cfg.SHARD_ID,
                    cfg.NUM_SHARDS,
                    cfg.DIST_BACKEND,
                    cfg,
                ),
                daemon=False,
            )
        else:
            test(cfg=cfg)
コード例 #3
0
                        'loss_rcnn_box': loss_rcnn_box
                    }
                    logger.add_scalars("logs_s_{}/losses".format(args.session),
                                       info,
                                       (epoch - 1) * iters_per_epoch + step)

                loss_temp = 0
                start = time.time()

        if (args.val_interval and (epoch + 1) % args.val_interval == 0)\
          and (args.dataset_val is not None):
            # validate the current model
            args_val = copy.deepcopy(args)
            args_val.imdbval_name = args.dataset_val

            mAP = test(args_val, model=fasterRCNN)

            if mAP > best_model_mAP:
                # save the model as the current best
                print("New best model: mAP={0:.4f}, {1} epochs".format(
                    mAP, epoch + 1))
                best_model_mAP = mAP
                best_model_save_name = os.path.join(
                    output_dir, 'best_model_{0}.pth'.format(args.session))
                save_checkpoint(
                    {
                        'session':
                        args.session,
                        'epoch':
                        epoch + 1,
                        'model':
コード例 #4
0
import main
import test_net

#main.run()

#file_name = "_generation-001-specimen-000"
file_name = "_generation-007-specimen-000"
test_net.test(file_name)