liznerski / fcdd

Repository for the Explainable Deep One-Class Classification paper
MIT License
225 stars 62 forks source link

Training on grayscale images #66

Closed NimaDL closed 1 year ago

NimaDL commented 1 year ago

The code only accept RGB input data for the training and when I tried to feed grayscale images to the model it failed. Any idea how to modify the code to accept grayscale images

liznerski commented 1 year ago

Hi!

For custom data?

Quick and dirty solution: Just repeat the channels for all images. For example, you could add transforms.Grayscale(num_output_channels=3), to the data pre-processing pipeline here and here.

The clean solution is defining a network architecture that works with grayscale images. Instead of 3 channels, the first layer needs to expect one channel. For our non-pretrained VGG variant, you need to change the first layer to self._create_conv2d(1, 64, 3, 1, 1),. Note that per default the custom data trainer uses the pretrained variant.

NimaDL commented 1 year ago

Thank you for your answer.