예제 #1
0
    freeze_backbone = params.freeze_backbone
    ##################################################################
    pretrained_dataset = "miniImageNet"

    if params.test_dataset == "ISIC":
        print("Loading ISIC")
        datamgr = ISIC_few_shot.SetDataManager2(image_size,
                                                n_eposide=iter_num,
                                                n_query=15,
                                                **few_shot_params)
        novel_loader = datamgr.get_data_loader(num_aug=params.gen_examples)

    elif params.test_dataset == "EuroSAT":
        print("Loading EuroSAT")
        datamgr = EuroSAT_few_shot.SetDataManager2(image_size,
                                                   n_eposide=iter_num,
                                                   n_query=15,
                                                   **few_shot_params)
        novel_loader = datamgr.get_data_loader(num_aug=params.gen_examples)

    elif params.test_dataset == "CropDisease":
        print("Loading CropDisease")
        datamgr = CropDisease_few_shot.SetDataManager2(image_size,
                                                       n_eposide=iter_num,
                                                       n_query=15,
                                                       **few_shot_params)
        novel_loader = datamgr.get_data_loader(num_aug=params.gen_examples)

    elif params.test_dataset == "ChestX":
        print("Loading ChestX")
        datamgr = Chest_few_shot.SetDataManager2(image_size,
                                                 n_eposide=iter_num,
예제 #2
0
        test_few_shot_params = dict(n_way=params.test_n_way,
                                    n_support=params.n_shot)

        #if params.dataset == "miniImageNet":
        base_datamgr = miniImageNet_few_shot.SetDataManager(
            image_size, n_query=n_query, **train_few_shot_params)
        base_loader = base_datamgr.get_data_loader(aug=params.train_aug)

        # use unlabeled data from these novel domains for adversarial domain adaptation
        # TODO: since the data is unlabeled, we need to modify data manager / data loader
        if params.dataset == "ChestX":
            target_datamgr = Chest_few_shot.SetDataManager(
                image_size, n_query=n_query, **train_few_shot_params)

        elif params.dataset == "EuroSAT":
            target_datamgr = EuroSAT_few_shot.SetDataManager(
                image_size, n_query=n_query, **train_few_shot_params)

        elif params.dataset == "ISIC2018":
            target_datamgr = ISIC_few_shot.SetDataManager(
                image_size, n_query=n_query, **train_few_shot_params)

        elif params.dataset == "CropDiseases":
            target_datamgr = CropDisease_few_show.SetDataManager(
                image_size, n_query=n_query, **train_few_shot_params)

        else:
            raise ValueError('Unknown dataset')

        target_loader = target_datamgr.get_data_loader(novel_file,
                                                       aug=params.train_aug)
예제 #3
0
    else:
        modelfile   = get_best_file(checkpoint_dir)

    if params.save_iter != -1:
        outfile = os.path.join( checkpoint_dir.replace("checkpoints","features"), params.dataset + "_" + str(params.save_iter)+ ".hdf5") 
    else:
        outfile = os.path.join( checkpoint_dir.replace("checkpoints","features"), params.dataset + ".hdf5") 


    if params.dataset in ["ISIC"]:
        datamgr         = ISIC_few_shot.SimpleDataManager(image_size, batch_size = 64)
        data_loader     = datamgr.get_data_loader(aug = False )

    elif params.dataset in ["EuroSAT"]:

        datamgr         = EuroSAT_few_shot.SimpleDataManager(image_size, batch_size = 64)
        data_loader     = datamgr.get_data_loader(aug = False )

    elif params.dataset in ["CropDisease"]:
        datamgr         = CropDisease_few_shot.SimpleDataManager(image_size, batch_size = 64)
        data_loader     = datamgr.get_data_loader(aug = False )

    elif params.dataset in ["ChestX"]:
        datamgr         = Chest_few_shot.SimpleDataManager(image_size, batch_size = 64)
        data_loader     = datamgr.get_data_loader(aug = False )


    model = model_dict[params.model]()
    
    model = model.cuda()
    tmp = torch.load(modelfile)
예제 #4
0
            image_size, n_query=n_query, mode="val", **test_few_shot_params)
        val_loader = val_datamgr.get_data_loader(aug=False)

        #=========== ISIC or EuroSAT ========
        few_shot_params = dict(n_way=params.test_n_way,
                               n_support=params.n_shot)
        if params.method == 'mytpnadaptisic':
            print("init mytpnadaptisic")
            datamgr = ISIC_few_shot.SetDataManager(image_size,
                                                   n_eposide=600,
                                                   n_query=n_query,
                                                   **few_shot_params)
        elif params.method == 'mytpnadapteurosat':
            print("init mytpnadapteurosat")
            datamgr = EuroSAT_few_shot.SetDataManager(image_size,
                                                      n_eposide=600,
                                                      n_query=n_query,
                                                      **few_shot_params)
        else:
            raise ValueError('Unknown method')
        novel_loader = datamgr.get_data_loader(aug=False)
        #=====================================

        #======= load pretrained model and ckpt =======
        model = MyTPN_Adapt(model_dict[params.model], **train_few_shot_params)

        pretrained_dataset = 'miniImageNet'
        checkpoint_dir = '%s/checkpoints/%s/%s_%s' % (
            configs.save_dir, pretrained_dataset, params.model,
            params.method[:5])
        if params.train_aug:
            checkpoint_dir += '_aug'