I will check the performance of PIL-SIMD. For now, I solved the problem by using imread_collection from skimage.io 1. In principle, everything works properly but I face the problem of slow DataLoader. I use such a code:
    def __getitem__(self, idx):
        idx_q = int(torch.randint(0 + self.boundary, self.length - self.boundary, (1,))) 
        idx_n = int(torch.randint(0 + self.boundary, self.length - self.boundary, (1,)))

        q = imread_collection([self.image_paths[idx_q-1], self.image_paths[idx_q], self.image_paths[idx_q+1]], conserve_memory=True)
        p = imread_collection([self.image_paths_winter[idx_q-1], self.image_paths_winter[idx_q], self.image_paths_winter[idx_q+1]], conserve_memory=True)
        n = imread_collection([self.image_paths_winter[idx_n-1], self.image_paths_winter[idx_n], self.image_paths_winter[idx_n+1]], conserve_memory=True)
        
        if self.transform:
            q = torch.stack([self.transform(img) for img in q])
            p = torch.stack([self.transform(img) for img in p])
            n = torch.stack([self.transform(img) for img in n])

        return q, p, n

So, for batch_size=4 I load 4x3x3 images which are 36 images. When I try to run all this code from getitem out of torch’s DataLoader it takes around 0.3 sec to run. But with DataLoader it takes 13 seconds which is a huge difference. Of course, num_workers help here when there are more iterations. But I don’t know where is the bottleneck. If you have any thoughts, that could be very helpful.