@@ -44,7 +44,7 @@ class RetinaNet(nn.Module):
4444
4545 def __init__ (
4646 self ,
47- pretrained = "coco" , # not used here for proper signature
47+ pretrained = "coco" , # not used here for proper signature
4848 encoder_name = "resnet50" ,
4949 encoder_weights = "imagenet" ,
5050 pyramid_channels = 256 ,
@@ -90,7 +90,7 @@ def make_final_convs():
9090 self .box_convs = make_final_convs ()
9191 self .box_head_conv = conv3x3 (pyramid_channels , 4 * anchors_per_location , bias = True )
9292 self .num_classes = num_classes
93- self . _initialize_weights ()
93+ self ._initialize_weights ()
9494
9595 # Name from mmdetectin for convenience
9696 def extract_features (self , x ):
@@ -126,18 +126,17 @@ def predict(self, x):
126126 """Run forward on given images and decode raw prediction into bboxes"""
127127 class_outputs , box_outputs = self .forward (x )
128128 anchors = box_utils .generate_anchors_boxes (x .shape [- 2 :])[0 ]
129- return box_utils .decode (
130- class_outputs , box_outputs , anchors , img_shape = x .shape [- 2 :]
131- )
129+ return box_utils .decode (class_outputs , box_outputs , anchors )
132130
133131 def _initialize_weights (self ):
134132 # init everything except encoder
135133 no_encoder_m = [m for n , m in self .named_modules () if not "encoder" in n ]
136134 initialize_iterator (no_encoder_m )
137- # need to init last bias so that after sigmoid it's 0.01
138- cls_bias_init = - torch .log (torch .tensor ((1 - 0.01 ) / 0.01 )) # -4.59
135+ # need to init last bias so that after sigmoid it's 0.01
136+ cls_bias_init = - torch .log (torch .tensor ((1 - 0.01 ) / 0.01 )) # -4.59
139137 nn .init .constant_ (self .cls_head_conv .bias , cls_bias_init )
140138
139+
141140# Don't really know input size for the models. 512 is just a guess
142141PRETRAIN_SETTINGS = {** DEFAULT_IMAGENET_SETTINGS , "input_size" : (512 , 512 ), "crop_pct" : 1 , "num_classes" : 80 }
143142
0 commit comments