useless dataset code

class ImgDataset: """Image dataset. Reads JPG""" def __init__(self, root): """ Args: root_dir (string): Directory with all the images. transform (callable, optional): Optional transform to be applied on a sample. """ imgs = os.listdir(root) self.imgs = [os.path.join(root, img) for img in imgs] self.to_tensor = transforms.ToTensor() def __len__(self): return len(self.imgs) def __getitem__(self, idx): img_name = self.imgs[idx] image = Image.open(img_name) image = self.to_tensor(image) min_val = image.min() max_val = image.max() image = (image-min_val) / (max_val - min_val) normalizer = transforms.Normalize((0.5, ), (0.5,)) return normalizer(image).to(device)
Could be wrong. PIL module seems to convert all pixel values between 0 and 1.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.