Sure, so the dataset object creation is the issue here:
dataset = dset.ImageFolder(root=dataroot,
                           transform=transforms.Compose([
                               transforms.Resize(image_size),
                               transforms.CenterCrop(image_size),
                               transforms.ToTensor(),
                               transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)),
                           ]))

Specifically, we’re interested in those transforms. Each datapoint starts off as a PIL image. The transforms suggest that each datapoint will:

Get resized
Cropped
Turned into a tensor
Normalized. Here the first tuple denotes the mean for each channel and the second tuple denotes the std for each channel.

We’ll need to do 2 things here. We need to add a transformation for grayscale and because we’ll only have one channel, we’ll go ahead and adjust that normalization step as well.
We’ll end up with something like this:
dataset = dset.ImageFolder(root=dataroot,
                           transform=transforms.Compose([
                               transforms.Resize(image_size),
                               transforms.CenterCrop(image_size),
                               transforms.Grayscale(num_output_channels=1),
                               transforms.ToTensor(),
                               transforms.Normalize(0.5, 0.5),
                           ]))

This dataset will now return tensors of channel size 1.