コード例 #1
0
print_args(args)

source_root = os.path.join(args.data_root, args.source)
source_label = os.path.join(args.data_root, args.source + "_list.txt")
target_root = os.path.join(args.data_root, args.target)
target_label = os.path.join(args.data_root, args.target + "6_list.txt")

train_transform = transforms.Compose([
    transforms.Scale((256, 256)),
    transforms.CenterCrop((224, 224)),
    transforms.RandomHorizontalFlip(),
    transforms.ToTensor(),
    transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
])

source_set = VisDAImage(source_root, source_label, train_transform)
target_set = VisDAImage(target_root, target_label, train_transform)

assert len(source_set) == 152397
assert len(target_set) == 28978

source_loader = torch.utils.data.DataLoader(source_set,
                                            batch_size=args.batch_size,
                                            shuffle=args.shuffle,
                                            num_workers=args.num_workers)
target_loader = torch.utils.data.DataLoader(target_set,
                                            batch_size=args.batch_size,
                                            shuffle=args.shuffle,
                                            num_workers=args.num_workers)

if args.model == 'resnet101':
コード例 #2
0
result = open(
    os.path.join(args.result,
                 "Visda_IAFN_" + args.post + '.' + args.repeat + "_score.txt"),
    "a")

t_root = os.path.join(args.data_root, args.target)
t_label = os.path.join(args.data_root, args.target + "6_list.txt")

data_transform = transforms.Compose([
    transforms.Scale((256, 256)),
    transforms.CenterCrop((224, 224)),
    transforms.ToTensor(),
    transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
])

t_set = VisDAImage(t_root, t_label, data_transform)
assert len(t_set) == 28978
t_loader = torch.utils.data.DataLoader(t_set,
                                       batch_size=args.batch_size,
                                       shuffle=args.shuffle,
                                       num_workers=args.num_workers)

netG = ResBase50().cuda()
netF = ResClassifier(class_num=args.class_num).cuda()
netG.eval()
netF.eval()

for epoch in range(args.epoch / 2, args.epoch + 1):
    if epoch % 10 != 0:
        continue