Comments (4)
@CaptainEven change the in channel of the network to 1, and other misc
from srgan.
Hi, i changed input channels from 3 to 1 in Generator and Discriminator but an error occured like this: File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\container.py", line 67, in forward
input = module(input)
File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 325, in call
result = self.forward(*input, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\conv.py", line 277, in forward
self.padding, self.dilation, self.groups)
File "C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\functional.py", line 90, in conv2d
return f(input, weight, bias)
RuntimeError: Given groups=1, weight[64, 3, 3, 3], so expected input[8, 1, 88, 88] to have 3 channels, but got 1 channels instead
got any idea or suggestion?
from srgan.
@CaptainEven Because you only change that, you should also change other misc, not just only there, you should change the image preprocessing code, visualization code, some save image code and PSNR computation code, etc.
from srgan.
In data_utils.py simply add .convert('RGB') to convert a grayscale image to RGB and add three channels. It is a built-in function in PIL.
class TrainDatasetFromFolder(Dataset):
def init(self, dataset_dir, crop_size, upscale_factor):
super(TrainDatasetFromFolder, self).init()
self.image_filenames = [join(dataset_dir, x) for x in listdir(dataset_dir) if is_image_file(x)]
crop_size = calculate_valid_crop_size(crop_size, upscale_factor)
self.hr_transform = train_hr_transform(crop_size)
self.lr_transform = train_lr_transform(crop_size, upscale_factor)
def __getitem__(self, index):
hr_image = self.hr_transform(Image.open(self.image_filenames[index]).convert('RGB'))
lr_image = self.lr_transform(hr_image)
return lr_image, hr_image
def __len__(self):
return len(self.image_filenames)
class ValDatasetFromFolder(Dataset):
def init(self, dataset_dir, upscale_factor):
super(ValDatasetFromFolder, self).init()
self.upscale_factor = upscale_factor
self.image_filenames = [join(dataset_dir, x) for x in listdir(dataset_dir) if is_image_file(x)]
def __getitem__(self, index):
hr_image = Image.open(self.image_filenames[index]).convert('RGB')
w, h = hr_image.size
crop_size = calculate_valid_crop_size(min(w, h), self.upscale_factor)
lr_scale = Resize(crop_size // self.upscale_factor, interpolation=Image.BICUBIC)
hr_scale = Resize(crop_size, interpolation=Image.BICUBIC)
hr_image = CenterCrop(crop_size)(hr_image)
lr_image = lr_scale(hr_image)
hr_restore_img = hr_scale(lr_image)
return ToTensor()(lr_image), ToTensor()(hr_restore_img), ToTensor()(hr_image)
from srgan.
Related Issues (20)
- learning rate HOT 1
- about maximize D(x)-1-D(G(z)) HOT 1
- Pre-trained model weights HOT 1
- loss function HOT 1
- Asking about data_utils.py file HOT 1
- epochs folder HOT 1
- Transform methods HOT 3
- test_image.py not running HOT 1
- Data set HOT 1
- Which folder do I need to put the pictures in? HOT 1
- Cannot download model/data HOT 2
- Is there an additional loss function(TV loss)? HOT 2
- When extracting features with the VGG, at what layer level do we stop on the VGG? HOT 1
- problem HOT 3
- Help HOT 1
- Please tell me how to use gray images to train the net ? HOT 1
- do we have pre-trained models? want to run the test.py, HOT 1
- Loss Curve question
- 怎么根据继续上一次断掉的epoch继续训练呢 HOT 1
- pretrained weights not provided HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from srgan.