I’ve looked over your code, but haven’t found anything at first glance. Only thing that comes to mind is if your loader is not actually accessing an image.
Did you check if your glob.glob is actually finding a filepath? It could return empty lists. If yes, check if your img_path = self.filenames[index] actually gets a correct file name.