def init_modules(self): """ some modules """ self.feature_extractor = OFTNetFeatureExtractor( self.feature_extractor_config) feats_reduce_1 = nn.Conv2d(128, self.feat_size, 1, 1, 0) feats_reduce_2 = nn.Conv2d(256, self.feat_size, 1, 1, 0) feats_reduce_3 = nn.Conv2d(512, self.feat_size, 1, 1, 0) self.feats_reduces = nn.ModuleList( [feats_reduce_1, feats_reduce_2, feats_reduce_3]) self.feat_collapse = nn.Conv2d(8, 1, 1, 1, 0) self.output_head = nn.Conv2d(256 * 4, self.output_channels, 1, 1, 0) # loss self.reg_loss = nn.L1Loss(reduce=False) # self.reg_loss = nn.SmoothL1Loss(reduce=False) # if self.use_focal_loss: # self.conf_loss = FocalLoss( # self.n_classes, alpha=0.2, gamma=2, auto_alpha=False) # else: # self.conf_loss = nn.CrossEntropyLoss(reduce=False) self.conf_loss = nn.L1Loss(reduce=False) self.angle_loss = MultiBinLoss(num_bins=self.num_bins)
def init_modules(self): self.det_model = PRNet(ModelCFG) # dims loss self.dims_loss = nn.SmoothL1Loss(reduce=False) # multibin loss self.multibin_loss = MultiBinLoss(self.num_bins)
def init_modules(self): self.feature_extractor = ResNetFeatureExtractor( self.feature_extractor_config) self.rpn_model = RPNModel(self.rpn_config) if self.pooling_mode == 'align': self.rcnn_pooling = RoIAlignAvg(self.pooling_size, self.pooling_size, 1.0 / 16.0) elif self.pooling_mode == 'ps': self.rcnn_pooling = PSRoIPool(7, 7, 1.0 / 16, 7, self.n_classes) elif self.pooling_mode == 'psalign': raise NotImplementedError('have not implemented yet!') elif self.pooling_mode == 'deformable_psalign': raise NotImplementedError('have not implemented yet!') # self.rcnn_cls_pred = nn.Linear(2048, self.n_classes) self.rcnn_cls_pred = nn.Conv2d(2048, self.n_classes, 3, 1, 1) if self.reduce: in_channels = 2048 else: in_channels = 2048 * 4 * 4 if self.class_agnostic: self.rcnn_bbox_pred = nn.Linear(in_channels, 4) else: self.rcnn_bbox_pred = nn.Linear(in_channels, 4 * self.n_classes) # loss module if self.use_focal_loss: self.rcnn_cls_loss = FocalLoss(2) else: self.rcnn_cls_loss = functools.partial(F.cross_entropy, reduce=False) self.rcnn_bbox_loss = nn.modules.SmoothL1Loss(reduce=False) # some 3d statistic # some 2d points projected from 3d # self.rcnn_3d_preds_new = nn.Linear(in_channels, 3 + 4 * self.num_bins) self.rcnn_3d_loss = MultiBinLoss(num_bins=self.num_bins) # dims self.rcnn_dims_pred = nn.Sequential( *[nn.Linear(in_channels, 256), nn.ReLU(), nn.Linear(256, 3)]) # angle self.rcnn_angle_pred = nn.Sequential(*[ nn.Linear(in_channels, 256), nn.ReLU(), nn.Linear(256, self.num_bins * 2) ]) # angle conf self.rcnn_angle_conf_pred = nn.Sequential(*[ nn.Linear(in_channels, 256), nn.ReLU(), nn.Linear(256, self.num_bins * 2) ])
def init_modules(self): """ some modules """ self.feature_extractor = OFTNetFeatureExtractor( self.feature_extractor_config) feats_reduce_1 = nn.Conv2d(128, self.feat_size, 1, 1, 0) feats_reduce_2 = nn.Conv2d(256, self.feat_size, 1, 1, 0) feats_reduce_3 = nn.Conv2d(512, self.feat_size, 1, 1, 0) self.feats_reduces = nn.ModuleList( [feats_reduce_1, feats_reduce_2, feats_reduce_3]) self.feat_collapse = nn.Conv2d(8, 1, 1, 1, 0) self.rcnn_output_head = nn.Conv2d(1152, self.rcnn_output_channels, 1, 1, 0) self.rpn_output_head = nn.Conv2d(256 * 4, self.rpn_output_channels, 1, 1, 0) # loss self.reg_loss = nn.L1Loss(reduce=False) # self.reg_loss = nn.SmoothL1Loss(reduce=False) # if self.use_focal_loss: # self.conf_loss = FocalLoss( # self.n_classes, alpha=0.2, gamma=2, auto_alpha=False) # else: # self.conf_loss = nn.CrossEntropyLoss(reduce=False) self.conf_loss = nn.L1Loss(reduce=False) self.angle_loss = MultiBinLoss(num_bins=self.num_bins) # fusion layer # self.upconv1 = nn.ConvTranspose2d(self.feat_size, self.feat_size, 2, 2, # 0) self.fusion1 = nn.Conv2d(2 * self.feat_size, self.feat_size, 3, 1, 1) self.fusion1_bn = nn.BatchNorm2d(self.feat_size) self.relu1 = nn.ReLU() self.upconv2 = nn.ConvTranspose2d(self.feat_size, self.feat_size, 2, 2, 0) self.upconv2_bn = nn.BatchNorm2d(self.feat_size) self.upconv2_relu = nn.ReLU() self.relu2 = nn.ReLU() self.fusion2 = nn.Conv2d(2 * self.feat_size, self.feat_size, 3, 1, 1) self.fusion2_bn = nn.BatchNorm2d(self.feat_size) self.upconv3 = nn.ConvTranspose2d(self.feat_size, self.feat_size, 2, 2, 0) self.upconv3_bn = nn.BatchNorm2d(self.feat_size) self.upconv3_relu = nn.ReLU() # self.fusion3 = nn.Conv2d(self.feat_size, self.feat_size, 3, 1, 1) # self.relu3 = nn.ReLU() self.rcnn_pooling = RoIAlignAvg(self.pooling_size, self.pooling_size, 1.0 / 8.0)
def init_modules(self): self.feature_extractor = ResNetFeatureExtractor( self.feature_extractor_config) self.rpn_model = RPNModel(self.rpn_config) if self.pooling_mode == 'align': self.rcnn_pooling = ROIAlign((self.pooling_size, self.pooling_size), 1.0 / 16.0, 2) elif self.pooling_mode == 'ps': self.rcnn_pooling = PSRoIPool(7, 7, 1.0 / 16, 7, self.n_classes) elif self.pooling_mode == 'psalign': raise NotImplementedError('have not implemented yet!') elif self.pooling_mode == 'deformable_psalign': raise NotImplementedError('have not implemented yet!') # self.rcnn_cls_pred = nn.Conv2d(2048, self.n_classes, 3, 1, 1) self.rcnn_cls_preds = nn.Linear(2048, self.n_classes) if self.reduce: in_channels = 2048 else: in_channels = 2048 * 4 * 4 if self.class_agnostic: self.rcnn_bbox_preds = nn.Linear(in_channels, 4) else: self.rcnn_bbox_preds = nn.Linear(in_channels, 4 * self.n_classes) # loss module if self.use_focal_loss: self.rcnn_cls_loss = FocalLoss(self.n_classes) else: self.rcnn_cls_loss = functools.partial( F.cross_entropy, reduce=False) self.rcnn_bbox_loss = nn.modules.SmoothL1Loss(reduce=False) # self.rcnn_3d_pred = nn.Linear(c, 3 + 4 + 11 + 2 + 1) if self.class_agnostic_3d: self.rcnn_3d_pred = nn.Linear(in_channels, 3 + 4 * self.num_bins) else: self.rcnn_3d_pred = nn.Linear( in_channels, 3 * self.n_classes + 4 * self.num_bins) # self.rcnn_3d_loss = OrientationLoss(split_loss=True) self.rcnn_3d_loss = MultiBinLoss(num_bins=self.num_bins)