I made this class for dataloader. it would be very helpful if you colud please check that i have made it correct way(optimized way) or not.
I have renamed every image with indeces (1 to n).jpg of my dataset.
class DATALODER(Dataset):
	def __init__(self, root_dir, transform=None):
		self.root_dir = root_dir
		self.transform = transform

	def __len__(self):
		return 9294

	def __getitem__(self, idx):
		img_name = os.path.join(self.root_dir,
		str(idx) + ".jpg")
		image = io.imread(img_name)
		gray_img = rgb2gray(image)
		lab_img = rgb2lab(image)[:,:,1:]

		sample = self.transform(sample)

		return sample


class ToTensor(object):
	def __call__(self, sample):
		gray_img, lab_img = sample
		tensor_gray = torch.tensor(gray_img, device=cuda).float()
		tensor_label = torch.tensor(lab_img.transpose((2,0,1)), device=cuda).float()

		tensor_label = tensor_label.view(1,2, tensor_gray.size()[0], tensor_gray.size()[1])
		tensor_gray = tensor_gray.view(1, 1, tensor_gray.size()[0], tensor_gray.size()[1])

		return (tensor_gray,tensor_label)