Skip to content

Commit

Permalink
Update repvgg.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobo-y authored Jan 31, 2024
1 parent c5263a5 commit 485d4a7
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion od/models/backbone/repvgg.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,23 @@ def switch_to_pretrained(self):
self.__delattr__('id_tensor')
self.pretrained = True


def switch_to_deploy(self):
if hasattr(self, 'rbr_reparam'):
return
kernel, bias = self.get_equivalent_kernel_bias()
self.rbr_reparam = nn.Conv2d(in_channels=self.rbr_dense.conv.in_channels, out_channels=self.rbr_dense.conv.out_channels,
kernel_size=self.rbr_dense.conv.kernel_size, stride=self.rbr_dense.conv.stride,
padding=self.rbr_dense.conv.padding, dilation=self.rbr_dense.conv.dilation, groups=self.rbr_dense.conv.groups, bias=True)
self.rbr_reparam.weight.data = kernel
self.rbr_reparam.bias.data = bias
for para in self.parameters():
para.detach_()
self.__delattr__('rbr_dense')
self.__delattr__('rbr_1x1')
if hasattr(self, 'rbr_identity'):
self.__delattr__('rbr_identity')
if hasattr(self, 'id_tensor'):
self.__delattr__('id_tensor')

class RepVGG(nn.Module):

Expand Down

0 comments on commit 485d4a7

Please sign in to comment.