Example #1
0
def load_data():
    train_data = dataset.Market_DataLoader(imgs_path=cfg.TRAIN.imgs_path,
                                           pose_path=cfg.TRAIN.pose_path,
                                           idx_path=cfg.TRAIN.idx_path,
                                           transform=dataset.train_transform(),
                                           loader=dataset.val_loader)
    train_loader = Data.DataLoader(train_data,
                                   batch_size=cfg.TRAIN.BATCH_SIZE,
                                   shuffle=True,
                                   num_workers=cfg.TRAIN.NUM_WORKERS,
                                   drop_last=True)

    val_data = dataset.Market_DataLoader(imgs_path=cfg.TRAIN.imgs_path,
                                         pose_path=cfg.TRAIN.pose_path,
                                         idx_path=cfg.TEST.idx_path,
                                         transform=dataset.val_transform(),
                                         loader=dataset.val_loader)
    val_loader = Data.DataLoader(val_data,
                                 batch_size=cfg.TEST.BATCH_SIZE,
                                 shuffle=False,
                                 num_workers=cfg.TRAIN.NUM_WORKERS)

    train = [train_data, train_loader]
    val = [val_data, val_loader]
    return train, val
def loss_func():
    criterionGAN = torch.nn.MSELoss().cuda()
    criterionIdt = torch.nn.L1Loss().cuda()
    criterionAtt = torch.nn.CrossEntropyLoss().cuda()
    criterion = [criterionGAN, criterionIdt, criterionAtt]

    return criterion



#%%
if __name__ == '__main__':
    
    sys.stdout = logger.Logger('./log_GAN_ep2.txt')
    
    train_data = dataset.Market_DataLoader(imgs_path=cfg.TRAIN.imgs_path, pose_path=cfg.TRAIN.pose_path, idx_path=cfg.TRAIN.idx_path,
                                           transform=dataset.train_transform(), img_loader=dataset.val_loader, pose_loader=dataset.pose_loader)
    
    train_loader = Data.DataLoader(train_data, batch_size=cfg.TRAIN.BATCH_SIZE, shuffle=True, num_workers=cfg.TRAIN.NUM_WORKERS, drop_last=True)

    val_data = dataset.Market_DataLoader(imgs_path=cfg.TRAIN.imgs_path, pose_path=cfg.TRAIN.pose_path, idx_path=cfg.TEST.idx_path,
                                         transform=dataset.val_transform(), img_loader=dataset.val_loader, pose_loader=dataset.pose_loader)
    
    val_loader = Data.DataLoader(val_data, batch_size=cfg.TEST.BATCH_SIZE, shuffle=False,
                                 num_workers=cfg.TRAIN.NUM_WORKERS)

    train_file = [train_data, train_loader]
    val_file = [val_data, val_loader]
    
    
#    train_file, val_file = load_data()
    nets = load_network()