Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Correct RDN number of channels #1332

Merged
merged 1 commit into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions mmedit/models/editors/rdn/rdn_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ class RDNNet(BaseModule):
'RDN-pytorch/blob/master/models.py'
Copyright (c) 2021, JaeYun Yeo, under MIT License.

Most of the implementation follows the implementation in:
'https://github.com/sanghyun-son/EDSR-PyTorch.git'
'EDSR-PyTorch/blob/master/src/model/rdn.py'
Copyright (c) 2017, sanghyun-son, under MIT license.

Args:
in_channels (int): Channel number of inputs.
out_channels (int): Channel number of outputs.
Expand Down Expand Up @@ -51,16 +56,15 @@ def __init__(self,
mid_channels, mid_channels, kernel_size=3, padding=3 // 2)

# residual dense blocks
self.rdbs = nn.ModuleList(
[RDB(self.mid_channels, self.channel_growth, self.num_layers)])
for _ in range(self.num_blocks - 1):
self.rdbs = nn.ModuleList()
for _ in range(self.num_blocks):
self.rdbs.append(
RDB(self.channel_growth, self.channel_growth, self.num_layers))
RDB(self.mid_channels, self.channel_growth, self.num_layers))

# global feature fusion
self.gff = nn.Sequential(
nn.Conv2d(
self.channel_growth * self.num_blocks,
self.mid_channels * self.num_blocks,
self.mid_channels,
kernel_size=1),
nn.Conv2d(
Expand Down Expand Up @@ -165,7 +169,7 @@ def __init__(self, in_channels, channel_growth, num_layers):
# local feature fusion
self.lff = nn.Conv2d(
in_channels + channel_growth * num_layers,
channel_growth,
in_channels,
kernel_size=1)

def forward(self, x):
Expand Down
1 change: 1 addition & 0 deletions tests/test_models/test_editors/test_rdn/test_rdn_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def test_rdn():
in_channels=3,
out_channels=3,
mid_channels=64,
channel_growth=32,
num_blocks=16,
upscale_factor=scale)

Expand Down