Hello, Created custom dataset that crops faces from images.
This is my getitem function which is working great.
def getitem(self,index):
images=glob.glob(self.path1)
img_path=os.path.join(self.path1,self.df.iloc[index,2][0].split(‘/’,1)[1])
image=cv.imread(img_path,cv.IMREAD_GRAYSCALE)
y_label=torch.tensor(int(self.df.iloc[index,3]))
try:
image=cv.resize(image,(80,80))
image=torch.tensor(image)
except:
pass
Then splitting dataset into train_set, test_set and creating Dataloaders.
train_set,test_set=torch.utils.data.random_split(dataset,[49862,len(dataset) -49862])
train_loader=DataLoader(train_set,batch_size=10,shuffle=True)
test_loader=DataLoader(test_set,batch_size=10,shuffle=False)
And When i iterate through train_loader it gives me an error.
for b,(X_train,y_train) in enumerate(train_loader):
AttributeError: ‘NoneType’ object has no attribute ‘float’
But when i iterate through train_set, it works perfectly.
Any help??