I’m on Windows 10 using Anaconda running Python 3.5.6 and pytorch 1.0.0 (py3.5_cuda100_cudnn7_1  [cuda100]  pytorch). I’m trying to use a custom dataset with the Dataloader class and keep getting a crash due to a threading error.

image.png1294×411 11.7 KB

The error occurs when the code iterates over the dataloader using the custom dataset. The dataset loads a document from mongodb and the underlying class extracts the images stored in the db, other data and label.
class mongoDatasetLoader(torch.utils.data.Dataset):
	def __init__(self,transform):
		self._label_dtype = np.int32
		self.imageTransform = transform
		self.mongoDB = mongoAPI()
		self.ids = [elem['_id'] for elem in list(self.mongoDB.tdb.find({}, {'_id': 1}))]
		self.loadData = self.ids
		random.seed()
		
	def __len__(self):
		return len(self.loadData)
	
	def __getitem__(self, i):
		profile = self.mongoDB.restore_profile(self.loadData[i])
		img = profile.images[0]
		img = self.imageTransform(img)
		# How to make the bool conversion less horrible??
		return img, torch.from_numpy(np.array([int(profile.liked)])).type(torch.long)


Is the dataset missing some definitions required by the dataloader or is this issue a little hairier?