| import os |
|
|
| def get_dataset_info(args, split): |
| if args.EVAL_DATASET == 'pascal': |
| |
| data_dir = '../../Datasets/PF-dataset-PASCAL' |
| categories = sorted(os.listdir(os.path.join(data_dir, 'Annotations'))) |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| elif args.EVAL_DATASET == 'spair': |
| |
| data_dir = '../../Datasets/SPair-71k' |
| categories = sorted(os.listdir(os.path.join(data_dir, 'ImageAnnotation'))) |
|
|
| return data_dir, categories, split |
|
|
|
|
|
|
| |
| from PIL import Image |
| from torch.utils.data import Dataset |
|
|
| class VLDataset(Dataset): |
| """A simple dataset to wrap a list of images and prompts for the DataLoader.""" |
| def __init__(self, images, prompts): |
| self.images = images |
| self.prompts = prompts |
|
|
| def __len__(self): |
| return len(self.images) |
|
|
| def __getitem__(self, idx): |
| |
| return self.images[idx], self.prompts[idx] |
| |
|
|
| class VLDatasetPaired(Dataset): |
| """A simple dataset to wrap a list of images and prompts for the DataLoader.""" |
| def __init__(self, source_imgs, target_imgs, prompts): |
| self.source_imgs = source_imgs |
| self.target_imgs = target_imgs |
| self.prompts = prompts |
|
|
| def __len__(self): |
| return len(self.source_imgs) |
|
|
| def __getitem__(self, idx): |
| |
| return self.source_imgs[idx], self.target_imgs[idx], self.prompts[idx] |