On a test, I made it work with a PIL image and the test works. Just finding the type as followed:
print(imagepre.type) 

and got:
Traceback (most recent call last):
  File "c:\Users\bala006\OneDrive - St John's Anglican College\Desktop\Personal\Dorime\CatsDogs\cats_dogs.py", line 51, in <module>   
    print(imagepre.type)
  File "C:\Users\bala006\Miniconda3.8\lib\site-packages\PIL\Image.py", line 541, in __getattr__
    raise AttributeError(name)
AttributeError: type

When training with this code:

class NN (nn.Module):
    def __init__(self, input_size, output_size):
        super(NN, self).__init__()
        self.flatten = nn.Flatten()
        self.LinearStack = nn.Sequential(
            nn.Linear(input_size, 300),
            nn.ReLU(),
            nn.Linear(300, 300),
            nn.ReLU(),
            nn.Linear(300, 256),
            nn.ReLU(),
            nn.Linear(256, 256),
            nn.ReLU(),
            nn.Linear(256, 150),
            nn.ReLU(),
            nn.Linear(150,100),
            nn.ReLU(),
            nn.Linear(100,75),
            nn.ReLU(),
            nn.Linear(75, output_size),
            nn.ReLU()
        )
    def forward (self,out):
        logits = self.LinearStack(out)
        return logits

model = NN(150528,1)
y_label, imagepre = dataset.__getitem__(1)
print (y_label)
image1 = transforms.ToTensor()(imagepre).unsqueeze_(0)
image2 = image1.reshape(1, 150528)
image112 = image2.float() 
tunak = model(image112)
print(tunak)



loss_func = nn.CrossEntropyLoss()
optimiser = optim.SGD(model.parameters(), lr = 0.001)
epochs = 2

def run (loss_fn, dataloader, model):
    size = dataset.__len__()
    for imagepre in enumerate(dataloader):
        image = transforms.ToTensor()
        imageprepre = image.reshape(1, 150528)
        imagework = imageprepre.float() 
        Pred = model(imagework)
        print (Pred)

        # Loss
        loss = loss_fn(Pred, y_label)

        # Backprop
        optimiser.zero_grad()
        loss.backward()
        optimiser.step()
        
        print (loss)

for t in range(epochs):
    print ("Epoch #######################")

    run(loss_func, dataloader, model)

print ("Done")

I get this error:
TypeError: default_collate: batch must contain tensors, numpy arrays, numbers, dicts or lists; found <class 'PIL.JpegImagePlugin.JpegImageFile'>

Hopefully you don’t feel like I’m dumping my errors on you…
I’m pretty new and after a couple of tutorials, I’m trying this for my first time and everything else is pretty good. I’ve come against this though.