Following function basically returns numpy.ndarray def getimage(id): img = self.coco.loadImgs(id) I = io.imread(img['coco_url']) return I #returns 'numpy.ndarray' The getimage function being called from main: x = load.getimage(id). x = torch.load(x) Error thrown: 'numpy.ndarray' object has no attribute 'seek'. You can only torch.load from a file that is seekable. Please pre-load the data into a buffer like io.BytesIO and try to load from it instead. Continue reading...