Hi, I have some images in a folder. I made my CustomDataSet
get these images.
def __init__(self, main_dir, label_full, transform):
#Reading path and doing some operations
#sorting images based on the name
self.all_imgs = sorted(os.listdir(main_dir), key= lambda x : int(x.split("_")[0]))
def __getitem__(self, idx):
train_label_price = torch.tensor((self.labels[idx]))
img_loc = os.path.join(self.main_dir, self.all_imgs[idx])
image = Image.open(img_loc).convert("RGB")
tensor_image = self.transform(image)
return (tensor_image.type(torch.double), train_label_price.type(torch.double))
When I am running my data_loader()
method I am getting an error
def data_loader():
# Some path and transformation ...
train_loader = DataLoader(train_data_tensor, batch_size= 10, num_workers= 0, shuffle= False)
train_data_loader_iter = iter(train_loader)
images, labels = train_data_loader_iter.next()
print(labels) // Nothing is printing
The error I am getting
Traceback (most recent call last):
File "/home/akib/.local/lib/python3.8/site-packages/pandas/core/indexes/range.py", line 355, in get_loc
return self._range.index(new_key)
ValueError: 1 is not in range
Could you tell me, why I am getting this error and why my CustomDataSet
is not working?