Root='train_set'
`train_data = ImageFolder(root=Root,transform=ToTensor())`

root='test_set'
test_data = ImageFolder(root=root,transform=ToTensor())


To check the shape I used
cv2.imread(path).shape
I also tried
from torchvision.transforms import Grayscale
train_data = ImageFolder(root=Root,transform=[ToTensor(),Grayscale()])

It shows,
TypeError                                 Traceback (most recent call last)
<ipython-input-197-7279b8172617> in <module>
      1 iter=0
      2 for epoch in range(num_epochs):
----> 3     for img, labels in train_loader:
      4         img=Variable(img)
      5         labels=Variable(labels)

~\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py in __next__(self)
    262         if self.num_workers == 0:  # same-process loading
    263             indices = next(self.sample_iter)  # may raise StopIteration
--> 264             batch = self.collate_fn([self.dataset[i] for i in indices])
    265             if self.pin_memory:
    266                 batch = pin_memory_batch(batch)

~\Anaconda3\lib\site-packages\torch\utils\data\dataloader.py in <listcomp>(.0)
    262         if self.num_workers == 0:  # same-process loading
    263             indices = next(self.sample_iter)  # may raise StopIteration
--> 264             batch = self.collate_fn([self.dataset[i] for i in indices])
    265             if self.pin_memory:
    266                 batch = pin_memory_batch(batch)

~\Anaconda3\lib\site-packages\torchvision\datasets\folder.py in __getitem__(self, index)
    101         sample = self.loader(path)
    102         if self.transform is not None:
--> 103             sample = self.transform(sample)
    104         if self.target_transform is not None:
    105             target = self.target_transform(target)

TypeError: 'list' object is not callable