Skip to content

Commit

Permalink
修正neck
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven committed Aug 12, 2024
1 parent 6f2a44a commit 4f2d778
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion configs/yolov4/yolov4_l_mish_1x16b-300e_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
deepen_factor=deepen_factor,
widen_factor=widen_factor,
in_channels=[256, 512, 512],
out_channels=[128, 256, 256],
out_channels=[256, 512, 1024],
num_csp_blocks=2,
norm_cfg=norm_cfg,
act_cfg=dict(type='Mish', inplace=True)),
Expand Down
25 changes: 16 additions & 9 deletions mmyolo/models/necks/yolov4_paspp.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def build_reduce_layer(self, idx: int) -> nn.Module:
if idx != len(self.in_channels) - 1:
layer = ConvModule(
make_divisible(self.in_channels[idx], self.widen_factor),
make_divisible(self.out_channels[idx], self.widen_factor),
make_divisible(self.in_channels[idx] / 2, self.widen_factor),
1,
norm_cfg=self.norm_cfg,
act_cfg=self.act_cfg)
Expand All @@ -74,7 +74,7 @@ def build_upsample_layer(self, idx, *args, **kwargs) -> nn.Module:
return nn.Sequential(
ConvModule(
make_divisible(self.in_channels[idx - 1], self.widen_factor),
make_divisible(self.out_channels[idx - 1], self.widen_factor),
make_divisible(self.in_channels[idx - 1] / 2, self.widen_factor),
kernel_size=1,
norm_cfg=self.norm_cfg,
act_cfg=self.act_cfg),
Expand All @@ -91,7 +91,7 @@ def build_top_down_layer(self, idx: int):
"""
return Yolov4CSP2Layer(
make_divisible(self.in_channels[idx - 1], self.widen_factor),
make_divisible(self.out_channels[idx - 1], self.widen_factor),
make_divisible(self.in_channels[idx - 1] / 2, self.widen_factor),
num_blocks=make_round(self.num_csp_blocks, self.deepen_factor),
add_identity=False,
norm_cfg=self.norm_cfg,
Expand All @@ -107,8 +107,8 @@ def build_downsample_layer(self, idx: int) -> nn.Module:
nn.Module: The downsample layer.
"""
return ConvModule(
make_divisible(self.in_channels[idx], self.widen_factor),
make_divisible(self.in_channels[idx], self.widen_factor),
make_divisible(self.out_channels[idx] / 2, self.widen_factor),
make_divisible(self.out_channels[idx], self.widen_factor),
kernel_size=3,
stride=2,
padding=1,
Expand All @@ -125,13 +125,20 @@ def build_bottom_up_layer(self, idx: int) -> nn.Module:
nn.Module: The bottom up layer.
"""
return Yolov4CSP2Layer(
make_divisible(self.in_channels[idx] * 2, self.widen_factor),
make_divisible(self.in_channels[idx + 1], self.widen_factor),
make_divisible(self.out_channels[idx+1], self.widen_factor),
make_divisible(self.out_channels[idx+1] / 2, self.widen_factor),
num_blocks=make_round(self.num_csp_blocks, self.deepen_factor),
add_identity=False,
norm_cfg=self.norm_cfg,
act_cfg=self.act_cfg)

def build_out_layer(self, *args, **kwargs) -> nn.Module:
def build_out_layer(self, idx, *args, **kwargs) -> nn.Module:
"""build out layer."""
return nn.Identity()
return ConvModule(
make_divisible(self.out_channels[idx]/2, self.widen_factor),
make_divisible(self.out_channels[idx], self.widen_factor),
kernel_size=3,
stride=1,
padding=1,
norm_cfg=self.norm_cfg,
act_cfg=self.act_cfg)

0 comments on commit 4f2d778

Please sign in to comment.