예제 #1
0
    timer = Timer()

    logging.info(args)
    config = mobilenetv1_ssd_config  #config file for priors etc.
    train_transform = TrainAugmentation(config.image_size, config.image_mean,
                                        config.image_std)
    target_transform = MatchPrior(config.priors, config.center_variance,
                                  config.size_variance, 0.5)

    test_transform = TestTransform(config.image_size, config.image_mean,
                                   config.image_std)

    logging.info("Prepare training datasets.")
    train_dataset = VIDDataset(args.datasets,
                               args.cache_path,
                               transform=train_transform,
                               target_transform=target_transform,
                               batch_size=args.batch_size)
    label_file = os.path.join("models/", "vid-model-labels.txt")
    store_labels(label_file, train_dataset._classes_names)
    num_classes = len(train_dataset._classes_names)
    logging.info(f"Stored labels into file {label_file}.")
    logging.info("Train dataset size: {}".format(len(train_dataset)))
    train_loader = DataLoader(train_dataset,
                              args.batch_size,
                              num_workers=args.num_workers,
                              shuffle=True)
    # logging.info("Prepare Validation datasets.")
    # val_dataset = VIDDataset(args.datasets, args.cache_path, transform=test_transform,
    # 							 target_transform=target_transform, is_val=True)
    # logging.info(val_dataset)
if __name__ == '__main__':
    timer = Timer()

    logging.info(args)
    config = mobilenetv1_ssd_config  #config file for priors etc.
    train_transform = TrainAugmentation(config.image_size, config.image_mean,
                                        config.image_std)
    target_transform = MatchPrior(config.priors, config.center_variance,
                                  config.size_variance, 0.5)

    test_transform = TestTransform(config.image_size, config.image_mean,
                                   config.image_std)

    logging.info("Prepare training datasets.")
    train_dataset = VIDDataset(args.datasets,
                               args.cache_path,
                               transform=train_transform,
                               target_transform=target_transform)
    label_file = os.path.join("models/", "vid-model-labels.txt")
    store_labels(label_file, train_dataset._classes_names)
    num_classes = len(train_dataset._classes_names)
    logging.info(f"Stored labels into file {label_file}.")
    logging.info("Train dataset size: {}".format(len(train_dataset)))
    train_loader = DataLoader(train_dataset,
                              args.batch_size,
                              num_workers=args.num_workers,
                              shuffle=True)
    logging.info("Prepare Validation datasets.")
    val_dataset = VIDDataset(args.datasets,
                             args.cache_path,
                             transform=test_transform,
                             target_transform=target_transform,
    test_transform = TestTransform(
        config.image_size, config.image_mean, config.image_std
    )
    # elif args.feature == "vgg19" or "resnet18":
    #     train_transform = TrainAugmentation(224, config.image_mean, config.image_std)
    #     target_transform = MatchPrior(
    #         config.priors, config.center_variance, config.size_variance, 0.5
    #     )
    #     test_transform = TestTransform(224, config.image_mean, config.image_std)

    logging.info("Prepare training datasets.")
    train_dataset = VIDDataset(
        args.datasets,
        args.cache_path,
        transform=train_transform,
        target_transform=target_transform,
        batch_size=args.batch_size,
    )
    label_file = os.path.join("models/", "vid-model-labels.txt")
    store_labels(label_file, train_dataset._classes_names)
    num_classes = len(train_dataset._classes_names)
    logging.info(f"Stored labels into file {label_file}.")
    logging.info("Train dataset size: {}".format(len(train_dataset)))
    train_loader = DataLoader(
        train_dataset, args.batch_size, num_workers=args.num_workers, shuffle=True
    )
    logging.info("Prepare Validation datasets.")
    val_dataset = VIDDataset(
        args.datasets,
        args.cache_path,