Something weird with ImageFolder

I am using Imagefolder for classification task. My dataset is

animal_train
|-cat
     |-11.png
     |-12.png
|-dog
    |-21.png
    |-22.png
...
animal_val
|-cat
     |-11s.png
     |-12s.png
|-dog
    |-21s.png
    |-22s.png

I used code


transform = transforms.Compose(
    [transforms.RandomHorizontalFlip(),
    transforms.Resize(224),
    transforms.RandomCrop(112),        
    transforms.ToTensor(),
    transforms.Normalize(mean=(0.5,0.5,0.5),std=(0.5,0.5,0.5))])

train_loader = torch.utils.data.DataLoader(ImageFolder('./animal_train', transform=transform), 
                                                batch_size=16, shuffle=True, num_workers=4)
val_loader = torch.utils.data.DataLoader(ImageFolder('./animal_val', transform=transform), 
                                                batch_size=4, shuffle=False, num_workers=4)

I got very high accuracy for training but validation still zero. What is happening in my code?

If you are dealing with two classes, the random accuracy should be around 0.5 instead of a perfect 0 (flipping the predictions would yield a perfect score of 1.0).

Could you post the code to calculate the validation predictions and accuracy so that we could have a look?