VSCode Jupyter Kernel crashes when running transforms.toTensor()

I am trying to prepare the dataloader for fine tuning a pretrained classification model. The path to training images are added to a variable called ‘data_paths’. I am not able to resolve a “Kernel crashed” error in my jupyter notebook. I believe its happening when I call the ‘transforms.ToTensor’ method on the images. Below is a sample code which throws the error for me. It works if I comment out the ToTensor transformation

'trans = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor()
])

img = Image.open(data_paths[5])
demo_img = trans(img)’

I’m looking for some suggestions on fixing the issue. I am using Python 3.10.12 and I have installed the latest pytorch and torchvision, but the issue hasn’t resolved