naoto0804 / pytorch-AdaIN

Unofficial pytorch implementation of 'Arbitrary Style Transfer in Real-time with Adaptive Instance Normalization' [Huang+, ICCV2017]
MIT License
1.08k stars 208 forks source link

How to change the number of channels from 3 to 1 #55

Open avinash2022skipq opened 1 year ago

avinash2022skipq commented 1 year ago

Hello, thank you for the code. I trained the model on my on dataset of FONTS which are black and white means the channel is 1, so now where can I set the channel size also can I use same vgg encoder or I have to change the encoder according to my channel size because while training on the images I didn't get the error but while the testing on I got the error I am using the decoder after training from experiments.

(test1) D:\Coding\AdaIN_Code\AdaIN_exp1>python test.py --content_dir input/content4 --style_dir input/style4 Traceback (most recent call last): File "D:\Coding\AdaIN_Code\AdaIN_exp1\test.py", line 155, in output = style_transfer(vgg, decoder, content, style, File "D:\Coding\AdaIN_Code\AdaIN_exp1\test.py", line 28, in style_transfer content_f = vgg(content) File "C:\Users\ak874\anaconda3\envs\test1\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, *kwargs) File "C:\Users\ak874\anaconda3\envs\test1\lib\site-packages\torch\nn\modules\container.py", line 139, in forward input = module(input) File "C:\Users\ak874\anaconda3\envs\test1\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(input, **kwargs) File "C:\Users\ak874\anaconda3\envs\test1\lib\site-packages\torch\nn\modules\conv.py", line 457, in forward return self._conv_forward(input, self.weight, self.bias) File "C:\Users\ak874\anaconda3\envs\test1\lib\site-packages\torch\nn\modules\conv.py", line 453, in _conv_forward return F.conv2d(input, weight, bias, self.stride, RuntimeError: Given groups=1, weight of size [3, 3, 1, 1], expected input[1, 1, 128, 128] to have 3 channels, but got 1 channels instead