Skip to content

Commit 3506d46

Browse files
ppwwyyxxfacebook-github-bot
authored andcommitted
fix test_time_augmentation (facebookresearch#324)
Summary: also found that the AP (without TTA) for the largest model is computed on a different checkpoint. Pull Request resolved: fairinternal/detectron2#324 Differential Revision: D18418965 Pulled By: ppwwyyxx fbshipit-source-id: 8ede8d9f11cc52c771aefd8c5a7f73e5643aaee4
1 parent 584b24a commit 3506d46

File tree

4 files changed

+20
-6
lines changed

4 files changed

+20
-6
lines changed

MODEL_ZOO.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -858,8 +858,8 @@ A few very large models trained for a long time, for demo purposes:
858858
<tr><td align="left"><a href="configs/Misc/cascade_mask_rcnn_X_152_32x8d_FPN_IN5k_gn_dconv.yaml">Mask R-CNN X152</a></td>
859859
<td align="center">0.281</td>
860860
<td align="center">15.1</td>
861-
<td align="center">49.3</td>
862-
<td align="center">43.2</td>
861+
<td align="center">50.2</td>
862+
<td align="center">44.0</td>
863863
<td align="center"></td>
864864
<td align="center">18131413</td>
865865
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/Misc/cascade_mask_rcnn_X_152_32x8d_FPN_IN5k_gn_dconv/18131413/model_0039999_e76410.pkl">model</a>&nbsp;|&nbsp;<a href="https://dl.fbaipublicfiles.com/detectron2/Misc/cascade_mask_rcnn_X_152_32x8d_FPN_IN5k_gn_dconv/18131413/metrics.json">metrics</a></td>
@@ -868,8 +868,8 @@ A few very large models trained for a long time, for demo purposes:
868868
<tr><td align="left">above + test-time aug.</td>
869869
<td align="center"></td>
870870
<td align="center"></td>
871-
<td align="center">51.4</td>
872-
<td align="center">45.5</td>
871+
<td align="center">51.9</td>
872+
<td align="center">45.9</td>
873873
<td align="center"></td>
874874
<td align="center"></td>
875875
<td align="center"></td>

detectron2/engine/hooks.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,19 @@ class AutogradProfiler(HookBase):
233233
"""
234234
A hook which runs `torch.autograd.profiler.profile`.
235235
236+
Examples:
237+
238+
.. code-block:: python
239+
240+
hooks.AutogradProfiler(
241+
lambda trainer: trainer.iter > 10 and trainer.iter < 20, self.cfg.OUTPUT_DIR
242+
)
243+
244+
The above example will run the profiler for iteration 10~20 and dump
245+
results to ``OUTPUT_DIR``. We did not profile the first few iterations
246+
because they are typically slower than the rest.
247+
The result files can be loaded in the ``chrome://tracing`` page in chrome browser.
248+
236249
Note:
237250
When used together with NCCL on older version of GPUs,
238251
autograd profiler may cause deadlock because it unnecessarily allocates

detectron2/modeling/test_time_augmentation.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ def _inference_one_image(self, input):
194194

195195
# 1.3: select from the union of all results
196196
num_classes = self.cfg.MODEL.ROI_HEADS.NUM_CLASSES
197-
all_scores_2d = torch.zeros(num_boxes, num_classes, device=all_boxes.device)
197+
# +1 because fast_rcnn_inference expects background scores as well
198+
all_scores_2d = torch.zeros(num_boxes, num_classes + 1, device=all_boxes.device)
198199
for idx, cls, score in zip(count(), all_classes, all_scores):
199200
all_scores_2d[idx, cls] = score
200201

docs/tutorials/models.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ corresponds to information about one image.
2323

2424
The dict may contain the following keys:
2525

26-
* "image": `Tensor` in (C, H, W) format.
26+
* "image": `Tensor` in (C, H, W) format. The meaning of channels are defined by `cfg.INPUT.FORMAT`.
2727
* "instances": an `Instances` object, with the following fields:
2828
+ "gt_boxes": `Boxes` object storing N boxes, one for each instance.
2929
+ "gt_classes": `Tensor` of long type, a vector of N labels, in range [0, num_categories).

0 commit comments

Comments
 (0)