@@ -44,7 +44,7 @@ class RetinaNet(nn.Module):
44
44
45
45
def __init__ (
46
46
self ,
47
- pretrained = "coco" , # not used here for proper signature
47
+ pretrained = "coco" , # not used here for proper signature
48
48
encoder_name = "resnet50" ,
49
49
encoder_weights = "imagenet" ,
50
50
pyramid_channels = 256 ,
@@ -90,7 +90,7 @@ def make_final_convs():
90
90
self .box_convs = make_final_convs ()
91
91
self .box_head_conv = conv3x3 (pyramid_channels , 4 * anchors_per_location , bias = True )
92
92
self .num_classes = num_classes
93
- self . _initialize_weights ()
93
+ self ._initialize_weights ()
94
94
95
95
# Name from mmdetectin for convenience
96
96
def extract_features (self , x ):
@@ -126,18 +126,17 @@ def predict(self, x):
126
126
"""Run forward on given images and decode raw prediction into bboxes"""
127
127
class_outputs , box_outputs = self .forward (x )
128
128
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 )
132
130
133
131
def _initialize_weights (self ):
134
132
# init everything except encoder
135
133
no_encoder_m = [m for n , m in self .named_modules () if not "encoder" in n ]
136
134
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
139
137
nn .init .constant_ (self .cls_head_conv .bias , cls_bias_init )
140
138
139
+
141
140
# Don't really know input size for the models. 512 is just a guess
142
141
PRETRAIN_SETTINGS = {** DEFAULT_IMAGENET_SETTINGS , "input_size" : (512 , 512 ), "crop_pct" : 1 , "num_classes" : 80 }
143
142
0 commit comments