You need a dataset with high resolution images as well (of course). Check the latest papers on GANs and you will find many large resolution models/examples. Kernel size can't be greater than actual input sizeĭCGAN is quite old.
RuntimeError: Calculated padded input size per channel: (2 x 2). > 420 self.padding, self.dilation, oups) ~/metal-band-logo-generator/.ai/lib/python3.7/site-packages/torch/nn/modules/conv.py in _conv_forward(self, input, weight)Ĥ18 _pair(0), self.dilation, oups)Ĥ19 return F.conv2d(input, weight, self.bias, self.stride, > 423 return self._conv_forward(input, self.weight) ~/metal-band-logo-generator/.ai/lib/python3.7/site-packages/torch/nn/modules/conv.py in forward(self, input)Ĥ22 def forward(self, input: Tensor) -> Tensor: ~/metal-band-logo-generator/.ai/lib/python3.7/site-packages/torch/nn/modules/container.py in forward(self, input) > 727 result = self.forward(*input, **kwargs) ~/metal-band-logo-generator/.ai/lib/python3.7/site-packages/torch/nn/modules/module.py in _call_impl(self, *input, **kwargs)ħ25 result = self._slow_forward(*input, **kwargs) RuntimeError Traceback (most recent call last)Ģ3 label = torch.full((b_size,), real_label, dtype=torch.float, device=device) This repository includes a model for 128x128 imagenet generation. To avoid this, I think you'll have to take a look at the improvements used here (paper: ). However, as you can also see in that thread, it is harder to get a stable game between the generator and discriminator for this larger problem. Conv2d( ndf * 16, 1, 4, stride = 1, padding = 0, bias = False), Conv2d( ndf * 8, ndf * 16, 4, stride = 2, padding = 1, bias = False), Conv2d( ndf * 4, ndf * 8, 4, stride = 2, padding = 1, bias = False), Conv2d( ndf * 2, ndf * 4, 4, stride = 2, padding = 1, bias = False), Conv2d( ndf, ndf * 2, 4, stride = 2, padding = 1, bias = False), Conv2d( nc, ndf, 4, stride = 2, padding = 1, bias = False), If you have any issues, please contact me through the contact form on this website.Self. I hope this helps or saves you a bit of time. If we set img_size to 128, all of the images will be turned into 128x128 images. Print("Saving image with dims: " + str(crop_img.shape) + "x" + str(crop_img.shape))Ĭv2.imwrite("collections/128/" + str(i) + '.jpg', crop_img)Īll we need to do is specify the path to our dataset, the image size, and the output path. If(crop_img.shape = img_size and crop_img.shape = img_size): If(crop_img.shape != img_size or crop_img.shape != img_size): R_img = cv2.resize(img, (img_size, round(img_size * a2)), interpolation = cv2.INTER_AREA) R_img = cv2.resize(img, (round(img_size * a1), img_size), interpolation = cv2.INTER_AREA)Ĭrop_img = r_img Img = cv2.imread(os.path.join(path, img_name)) Below is a small script which will do just that. Our results might look odd if the training data is stretched, so we need to create a uniform shape for our data without destroying the perspective. This is okay for some simple machine learning tasks, like an image classifier for dogs and cats, but let’s say we want to train a GAN. The resize method in OpenCV does not account for aspect ratio, and as a result our output image is simply stretched to size.