Cnn with training image from folder in desktop

Hi ,

i made cnn with 6 conv layers and i want to train it by images in Folder in desktop but i have this error:
RuntimeError: Found 0 files in subfolders of: /Users/lionardo/Desktop/Training/1
Supported extensions are: .jpg,.jpeg,.png,.ppm,.bmp,.pgm,.tif,.tiff,.webp.

I don,t understand why this error?

My code:
#Import packages
import torch.nn as nn
import torch
from torch.utils.data import Dataset, DataLoader

import numpy as np
from torchvision import transforms
from torch.autograd import Variable
from PIL import Image
import torchvision.transforms.functional as TF
from torchvision.models.vgg import vgg19
import torch.nn as nn
import torch.nn.functional as F
import torch
import torch.nn as nn
import torch.utils.data as Data
import torchvision # dataset
import matplotlib.pyplot as plt
import scipy
import numpy as np
import argparse
import numpy
import scipy
from pytorch_msssim import ssim, ms_ssim, SSIM, MS_SSIM
import pprint
from scipy.ndimage import correlate
from scipy.ndimage.filters import gaussian_gradient_magnitude

#reproducible
torch.manual_seed(1)

Hyper Parameters

EPOCH = 1
BATCH_SIZE = 50
LR = 0.001
def load_dataset():
data_path = ‘/Users/lionardo/Desktop/Training/PET/1’
data_path = ‘/Users/lionardo/Desktop/Training/MRI/2’
train_dataset = torchvision.datasets.ImageFolder(
root=data_path,
transform=torchvision.transforms.ToTensor()
)

train_loader = torch.utils.data.DataLoader(
    train_dataset,
    batch_size=50,
    num_workers=0,
    shuffle=True
)
return train_loader

#for batch_idx, (data, target) in enumerate(load_dataset()):

#train data

#Dataset MNIST

Number of datapoints: 60000

Root location: ./mnist/

Split: Train

#StandardTransform

#Transform: ToTensor()

#testing data

test_data = torchvision.datasets.ImageFolder(root= ‘/Users/lionardo/Desktop/Training/1’)

test_data = torchvision.datasets.ImageFolder( root= ‘/Users/lionardo/Desktop/Training/2’)

#load the data
train_loader = Data.DataLoader(dataset=train_data, batch_size=BATCH_SIZE, shuffle=True)

#define the test data#
test_x = torch.unsqueeze(test_data.test_data, dim=1).type(torch.FloatTensor)[:200]/255. #shape from (2000, 28, 28) to (2000, 1, 28, 28), value in range (0,1)

test_y = test_data.test_labels[:200]

#define the network
class CNN(nn.Module):
def init(self):
super(CNN, self).init()
#mri lf layer 1
self.conv1 = nn.Sequential( # input shape (1, 28, 28)
nn.Conv2d(
in_channels=1, # input height
out_channels=16, # n_filters
kernel_size=9, # filter size
stride=1, # filter movement/step
padding=2 #
))

    self.batch1 = nn.BatchNorm2d(16),
           #output shape (16, 28, 28)
    self.relu1 =  nn.LeakyReLU(0.2, True)    #activation
    
    #mri hf layer 1 
    self.conv2 = nn.Sequential(  # input shape (16, 28, 28)
        nn.Conv2d(
            in_channels  = 16,
            out_channels = 32, 
            kernel_size  = 9,
            stride       = 1,
            padding      = 2
         ))
    
    self.batch2 = nn.BatchNorm2d(32),      #output shape (1,28,28)
    self.relu2 = nn.LeakyReLU(0.2,True)
    
    self.conv3 = nn.Sequential(  # input shape (16, 28, 28)
        nn.Conv2d(
            in_channels  = 32,
            out_channels = 64, 
            kernel_size  = 9,
            stride       = 1,
            padding      = 2
             ))
    self.batch3 = nn.BatchNorm2d(64),      #output shape (1,28,28)
    self.relu3 = nn.LeakyReLU(0.2,True)
    
    self.conv4 = nn.Sequential(  # input shape (16, 28, 28)
        nn.Conv2d(
            in_channels  = 64,
            out_channels = 32, 
            kernel_size  = 9,
            stride       = 1,
            padding      = 2
             ))
    
    self.batch4 = nn.BatchNorm2d(32),      #output shape (1,28,28)
    self.relu4 = nn.LeakyReLU(0.2,True)
    
    self.conv5 = nn.Sequential(  # input shape (16, 28, 28)
        nn.Conv2d(
            in_channels  = 32,
            out_channels = 16, 
            kernel_size  = 9,
            stride       = 1,
            padding      = 2
        ))
    
    self.batch5 = nn.BatchNorm2d(16),      #output shape (1,28,28)
    self.relu5 = nn.LeakyReLU(0.2,True)
    
    self.conv6 = nn.Sequential(      # input shape (16, 28, 28)
        nn.Conv2d(
            in_channels  = 16,
            out_channels = 1, 
            kernel_size  = 9,
            stride       = 1,
            padding      = 2
             ))
    
    self.batch6 = nn.BatchNorm2d(1),      #output shape (1,28,28)
    self.relu6 = nn.LeakyReLU(0.2,True)
    

def forward(self, x,y):
   
    
    x1 = x.reshape(-1,1,28,28) #careful: need to change by yourself
    x1= self.conv1(x)
    x1 = self.batch1(x)
    x1 = slef.relu1(x)
    # x = x.reshape(-1,1,28,28) #careful: need to change by yourself
    x1 = self.conv2(x)
    x1 = self.batch2(x)
    x1 = slef.relu2(x)
    x1 = self.conv3(x)
    x1 = self.batch3(x)
    x1 = slef.relu3(x)
    x1 = self.conv4(x)
    x1 = self.batch4(x)
    x1 = slef.relu4(x)
    x1 = self.conv5(x)
    x1 = self.batch5(x)
    x1 = slef.relu5(x)
    x1 = self.conv6(x)
    x1 = self.batch6(x)
    x1 = slef.relu6(x)
    
    x2 = y.reshape(-1,1,28,28) #careful: need to change by yourself
    x2= self.conv1(y)
    x2 = self.batch1(y)
    x2 = slef.relu1(y)
    # x = x.reshape(-1,1,28,28) #careful: need to change by yourself
    x2 = self.conv2(y)
    x2 = self.batch2(y)
    x2 = slef.relu2(y)
    x2 = self.conv3(y)
    x2 = self.batch3(y)
    x2 = slef.relu3(y)
    x2 = self.conv4(y)
    x2 = self.batch4(y)
    x2 = slef.relu4(y)
    x2 = self.conv5(y)
    x2 = self.batch5(y)
    x2 = slef.relu5(y)
    x2 = self.conv6(y)
    x2 = self.batch6(y)
    x2 = slef.relu6(y)
    
    x = torch.cat((x1, x2), 1)
    x = torch.tanh(x)
    x = x.reshape(-1)
    #x = x.view(x.size(0), -1)   #  (batch_size, 32 * 7 * 7)
    return x

    #execute the network

reference:

https://medium.com/unit8-machine-learning-publication/computing-the-jacobian-matrix-of-a-neural-network-in-python-4f162e5db180

https://stackoverflow.com/questions/59161001/using-autograd-to-compute-jacobian-matrix-of-outputs-with-respect-to-inputs

cnn = CNN()
print(cnn)

#define the optimizers and loss functions
optimizer = torch.optim.Adam(cnn.parameters(), lr=LR) # optimize all cnn parameters
loss_func = SSIM() # the target label is not one-hotted

training

for epoch in range(EPOCH):
for step, (b_x , b_y) in enumerate(train_loader):
#b_x = b_x.reshape(-1)
# b_y= b_y.reshape(-1)
output = cnn(b_x+b_y) # cnn output
loss = loss_func(output, b_x)+ loss_func(output,b_y)#+ cross entropy loss
optimizer.zero_grad() # clear gradients for this training step
loss.backward() # backpropagation, compute gradients
optimizer.step() # apply gradients

    #upload a test image

image = Image.open(’/Users/lionardo/Desktop/MRI.png’)
#image = Image.open(‘test.jpeg’).convert(‘L’)
x1 = TF.to_tensor(image)
x1 = x1.unsqueeze(0)
x1 = x1.reshape(-1)
x1.requires_grad = True

print(x1.shape)

image = Image.open(’/Users/lionardo/Desktop/PET.png’)
#image = Image.open(‘test.jpeg’).convert(‘L’)
x2 = TF.to_tensor(image)
x2 = x2.unsqueeze(0)
x2 = x2.reshape(-1)
x2.requires_grad = True

y = cnn(x1+x2)

Try with using the full path. eg C:/Users/lionardo/Desktop/Training/