EDSR-PyTorch
EDSR-PyTorch copied to clipboard
can we use gray data (1 channel) rather than RGB 3 channels data
How can we use it to deal with gray or 1 channel data ? How many places I need to modified? Thanks !
Nobody is interesting in this question ? or it is too simple to not want to answer ?
BTW: does anybody help me to change the code to 1 channel ? thanks !
class MeanShift(nn.Conv2d):
def init(
self, rgb_range,
rgb_mean=(0.4488, 0.4371, 0.4040), rgb_std=(1.0, 1.0, 1.0), sign=-1):
super(MeanShift, self).__init__(3, 3, kernel_size=1)
std = torch.Tensor(rgb_std)
self.weight.data = torch.eye(3).view(3, 3, 1, 1) / std.view(3, 1, 1, 1)
self.bias.data = sign * rgb_range * torch.Tensor(rgb_mean) / std
for p in self.parameters():
p.requires_grad = False
I trained my model using gray data by
- set option --n_colors to 1
- change getitem in class SRData: pair = self.get_patch(lr, hr) pair = common.set_channel(*pair, n_channels=self.args.n_colors) to lr, hr = common.set_channel(lr, hr, n_channels=self.args.n_colors) pair = self.get_patch(lr, hr) (if you don't change step 2, you will get a demention error in get_patch)
We also need to modify or remove the MeanShift class in common.py.
I have removed it for now for my low-spec proof-of-concept project, but it should be easy enough to transform the function to work for 1 channel.