Args: in_channels (int): Input channels. num_classes (int, optional): Defaults to 2 (background and pedestrian). bn_neck (bool, optional): Whether to use BN after Linear. Defaults to True.
(self, in_channels, num_classes=2, bn_neck=True)
| 659 | """ |
| 660 | |
| 661 | def __init__(self, in_channels, num_classes=2, bn_neck=True): |
| 662 | """ |
| 663 | Args: |
| 664 | in_channels (int): Input channels. |
| 665 | num_classes (int, optional): Defaults to 2 (background and pedestrian). |
| 666 | bn_neck (bool, optional): Whether to use BN after Linear. Defaults to True. |
| 667 | """ |
| 668 | super(BBoxRegressor, self).__init__() |
| 669 | if bn_neck: |
| 670 | self.bbox_pred = nn.Sequential( |
| 671 | nn.Linear(in_channels, 4 * num_classes), nn.BatchNorm1d(4 * num_classes) |
| 672 | ) |
| 673 | init.normal_(self.bbox_pred[0].weight, std=0.01) |
| 674 | init.normal_(self.bbox_pred[1].weight, std=0.01) |
| 675 | init.constant_(self.bbox_pred[0].bias, 0) |
| 676 | init.constant_(self.bbox_pred[1].bias, 0) |
| 677 | else: |
| 678 | self.bbox_pred = nn.Linear(in_channels, 4 * num_classes) |
| 679 | init.normal_(self.bbox_pred.weight, std=0.01) |
| 680 | init.constant_(self.bbox_pred.bias, 0) |
| 681 | |
| 682 | def forward(self, x): |
| 683 | if x.ndimension() == 4: |