@@ -126,6 +126,7 @@ def fast_rcnn_inference_single_image(
126126class FastRCNNOutputs (object ):
127127 """
128128 A class that stores information about outputs of a Fast R-CNN head.
129+ It provides methods that are used to decode the outputs of a Fast R-CNN head.
129130 """
130131
131132 def __init__ (
@@ -259,19 +260,6 @@ def smooth_l1_loss(self):
259260 loss_box_reg = loss_box_reg / self .gt_classes .numel ()
260261 return loss_box_reg
261262
262- def losses (self ):
263- """
264- Compute the default losses for box head in Fast(er) R-CNN,
265- with softmax cross entropy loss and smooth L1 loss.
266-
267- Returns:
268- A dict of losses (scalar tensors) containing keys "loss_cls" and "loss_box_reg".
269- """
270- return {
271- "loss_cls" : self .softmax_cross_entropy_loss (),
272- "loss_box_reg" : self .smooth_l1_loss (),
273- }
274-
275263 def _predict_boxes (self ):
276264 """
277265 Returns:
@@ -288,6 +276,24 @@ def _predict_boxes(self):
288276 )
289277 return boxes .view (num_pred , K * B )
290278
279+ """
280+ A subclass is expected to have the following methods because
281+ they are used to query information about the head predictions.0
282+ """
283+
284+ def losses (self ):
285+ """
286+ Compute the default losses for box head in Fast(er) R-CNN,
287+ with softmax cross entropy loss and smooth L1 loss.
288+
289+ Returns:
290+ A dict of losses (scalar tensors) containing keys "loss_cls" and "loss_box_reg".
291+ """
292+ return {
293+ "loss_cls" : self .softmax_cross_entropy_loss (),
294+ "loss_box_reg" : self .smooth_l1_loss (),
295+ }
296+
291297 def predict_boxes (self ):
292298 """
293299 Returns:
0 commit comments