Exemplo n.º 1
0
    ]),
    evaluation_data:
    transforms.Compose([
        transforms.Scale(256),
        transforms.CenterCrop(224),
        transforms.ToTensor(),
        transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
    ]),
}
use_gpu = torch.cuda.is_available()
torch.manual_seed(args.seed)
if args.cuda:
    torch.cuda.manual_seed(args.seed)
train_loader, test_loader = get_loader(source_data,
                                       target_data,
                                       evaluation_data,
                                       data_transforms,
                                       batch_size=args.batch_size)
dataset_train = train_loader.load_data()
dataset_test = test_loader

if args.dataset == 'VISDA':
    num_class = 7
    class_list = [
        "bicycle", "bus", "car", "motorcycle", "train", "truck", "unk"
    ]
elif args.dataset in ['UCM', 'AID']:
    num_class = 6
    class_list = ["baseballdiamond", "beach", "mediumresidential", "parkinglot", \
           "sparseresidential", "unkn"]
else:
Exemplo n.º 2
0
        transforms.RandomCrop(224),
        transforms.ToTensor(),
        transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
    ]),
    evaluation_data: transforms.Compose([
        transforms.Scale((256, 256)),
        transforms.CenterCrop(224),
        transforms.ToTensor(),
        transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
    ]),
}

use_gpu = torch.cuda.is_available()
source_loader, target_loader, \
test_loader, target_folder = get_loader(source_data, target_data,
                                        evaluation_data, data_transforms,
                                        batch_size=batch_size, return_id=True,
                                        balanced=conf.data.dataloader.class_balance)
dataset_test = test_loader
n_share = conf.data.dataset.n_share
n_source_private = conf.data.dataset.n_source_private
num_class = n_share + n_source_private

G, C1 = get_model_mme(conf.model.base_model, num_class=num_class,
                      temp=conf.model.temp)
device = torch.device("cuda")
if args.cuda:
    G.cuda()
    C1.cuda()
G.to(device)
C1.to(device)
ndata = target_folder.__len__()