@@ -70,7 +70,7 @@ def forward(self, inputs):
70
70
outs .append (self .get_pred ())
71
71
72
72
# multi-scale test
73
- if len (outs ) > 1 :
73
+ if len (outs )> 1 :
74
74
out = self .merge_multi_scale_predictions (outs )
75
75
else :
76
76
out = outs [0 ]
@@ -87,9 +87,7 @@ def merge_multi_scale_predictions(self, outs):
87
87
keep_top_k = self .bbox_post_process .nms .keep_top_k
88
88
nms_threshold = self .bbox_post_process .nms .nms_threshold
89
89
else :
90
- raise Exception (
91
- "Multi scale test only supports CascadeRCNN, FasterRCNN and MaskRCNN for now"
92
- )
90
+ raise Exception ("Multi scale test only supports CascadeRCNN, FasterRCNN and MaskRCNN for now" )
93
91
94
92
final_boxes = []
95
93
all_scale_outs = paddle .concat ([o ['bbox' ] for o in outs ]).numpy ()
@@ -98,11 +96,9 @@ def merge_multi_scale_predictions(self, outs):
98
96
if np .count_nonzero (idxs ) == 0 :
99
97
continue
100
98
r = nms (all_scale_outs [idxs , 1 :], nms_threshold )
101
- final_boxes .append (
102
- np .concatenate ([np .full ((r .shape [0 ], 1 ), c ), r ], 1 ))
99
+ final_boxes .append (np .concatenate ([np .full ((r .shape [0 ], 1 ), c ), r ], 1 ))
103
100
out = np .concatenate (final_boxes )
104
- out = np .concatenate (sorted (
105
- out , key = lambda e : e [1 ])[- keep_top_k :]).reshape ((- 1 , 6 ))
101
+ out = np .concatenate (sorted (out , key = lambda e : e [1 ])[- keep_top_k :]).reshape ((- 1 , 6 ))
106
102
out = {
107
103
'bbox' : paddle .to_tensor (out ),
108
104
'bbox_num' : paddle .to_tensor (np .array ([out .shape [0 ], ]))
@@ -124,16 +120,3 @@ def get_loss(self, ):
124
120
125
121
def get_pred (self , ):
126
122
raise NotImplementedError ("Should implement get_pred method!" )
127
-
128
- @classmethod
129
- def convert_sync_batchnorm (cls , layer ):
130
- layer_output = layer
131
- if getattr (layer , 'norm_type' , None ) == 'sync_bn' :
132
- layer_output = nn .SyncBatchNorm .convert_sync_batchnorm (layer )
133
- else :
134
- for name , sublayer in layer .named_children ():
135
- layer_output .add_sublayer (name ,
136
- cls .convert_sync_batchnorm (sublayer ))
137
-
138
- del layer
139
- return layer_output
0 commit comments