Skip to content

Commit 0568102

Browse files
committed
formatting
1 parent 8222993 commit 0568102

File tree

20 files changed

+473
-411
lines changed

20 files changed

+473
-411
lines changed

pytorch_tools/detection_models/efficientdet.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,14 @@ def predict(self, x):
161161
"""
162162
class_outputs, box_outputs = self.forward(x)
163163
anchors = box_utils.generate_anchors_boxes(x.shape[-2:])[0]
164-
return box_utils.decode(
165-
class_outputs, box_outputs, anchors, #img_shape=x.shape[-2:]
166-
)
164+
return box_utils.decode(class_outputs, box_outputs, anchors)
167165

168166
def _initialize_weights(self):
169167
# init everything except encoder
170168
no_encoder_m = [m for n, m in self.named_modules() if not "encoder" in n]
171169
initialize_iterator(no_encoder_m)
172-
# need to init last bias so that after sigmoid it's 0.01
173-
cls_bias_init = -torch.log(torch.tensor((1 - 0.01) / 0.01)) # -4.59
170+
# need to init last bias so that after sigmoid it's 0.01
171+
cls_bias_init = -torch.log(torch.tensor((1 - 0.01) / 0.01)) # -4.59
174172
nn.init.constant_(self.cls_head_convs[-1][1].bias, cls_bias_init)
175173

176174

pytorch_tools/detection_models/retinanet.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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
142141
PRETRAIN_SETTINGS = {**DEFAULT_IMAGENET_SETTINGS, "input_size": (512, 512), "crop_pct": 1, "num_classes": 80}
143142

pytorch_tools/models/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@
5151
from .bit_resnet import bit_m_101x1
5252
from .bit_resnet import bit_m_101x3
5353
from .bit_resnet import bit_m_152x2
54-
from .bit_resnet import bit_m_152x4
54+
from .bit_resnet import bit_m_152x4

0 commit comments

Comments
 (0)