I created a custom dataset but when I test it give me error:
“obj = super().new(cls, *args, **kwds)
TypeError: object.new() takes exactly one argument (the type to instantiate)”
Below is my code:
class HRLRDataset(Dataset):
def __int__(self, root_dir, transform=None):
self.root_dir = root_dir
self.transform = transform
lr_path, hr_path = os.path.join(self.root_dir, "lr"), os.path.join(self.root_dir, "hr")
self.lr_files = sorted(glob.glob(lr_path + "/*.*"))
self.hr_files = sorted(glob.glob(hr_path + "/*.*"))
def __len__(self):
return max(len(self.lr_files), len(self.hr_files))
def __getitem__(self, index):
hr_img = Image.open(self.hr_files[index])
lr_img = Image.open(self.lr_files[index])
if self.transform:
hr_img = self.hr_transform(hr_img)
lr_img = self.lr_transform(lr_img)
return {"lr": lr_img, "hr": hr_img}