mirror of https://github.com/XingangPan/DragGAN
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
707 B
Python
29 lines
707 B
Python
# Copyright (c) SenseTime Research. All rights reserved.
|
|
|
|
|
|
import os
|
|
from torch.utils.data import Dataset
|
|
from PIL import Image
|
|
|
|
from utils.data_utils import make_dataset
|
|
|
|
|
|
class ImagesDataset(Dataset):
|
|
|
|
def __init__(self, source_root, source_transform=None):
|
|
self.source_paths = sorted(make_dataset(source_root))
|
|
self.source_transform = source_transform
|
|
|
|
def __len__(self):
|
|
return len(self.source_paths)
|
|
|
|
def __getitem__(self, index):
|
|
fname, from_path = self.source_paths[index]
|
|
from_im = Image.open(from_path).convert('RGB')
|
|
|
|
if self.source_transform:
|
|
from_im = self.source_transform(from_im)
|
|
|
|
return fname, from_im
|
|
|