Open gfdskl opened 4 years ago
书上第138页中,当不提供transforms参数时,返回的data是image类型的,不能够直接使用。 修改建议: def __getitem__(self,index): img_path = self.imgs[index] label = 1 if 'dog' in img_path.split('/')[-1] else 0 pil_img = Image.open(img_path) if self.transforms: data = self.transforms(pil_img) else: array = np.asarray(pil_img) data = t.from_numpy(array) return data,label
def __getitem__(self,index): img_path = self.imgs[index] label = 1 if 'dog' in img_path.split('/')[-1] else 0 pil_img = Image.open(img_path) if self.transforms: data = self.transforms(pil_img) else: array = np.asarray(pil_img) data = t.from_numpy(array) return data,label
书上第138页中,当不提供transforms参数时,返回的data是image类型的,不能够直接使用。 修改建议:
def __getitem__(self,index): img_path = self.imgs[index] label = 1 if 'dog' in img_path.split('/')[-1] else 0 pil_img = Image.open(img_path) if self.transforms: data = self.transforms(pil_img) else: array = np.asarray(pil_img) data = t.from_numpy(array) return data,label