Skip to content

Commit

Permalink
fix test_time_augmentation (#324)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ppwwyyxx authored and facebook-github-bot committed Nov 10, 2019
1 parent 584b24a commit 3506d46
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
8 changes: 4 additions & 4 deletions MODEL_ZOO.md
Original file line number Diff line number Diff line change
Expand Up @@ -858,8 +858,8 @@ A few very large models trained for a long time, for demo purposes:
<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>
<td align="center">0.281</td>
<td align="center">15.1</td>
<td align="center">49.3</td>
<td align="center">43.2</td>
<td align="center">50.2</td>
<td align="center">44.0</td>
<td align="center"></td>
<td align="center">18131413</td>
<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>
Expand All @@ -868,8 +868,8 @@ A few very large models trained for a long time, for demo purposes:
<tr><td align="left">above + test-time aug.</td>
<td align="center"></td>
<td align="center"></td>
<td align="center">51.4</td>
<td align="center">45.5</td>
<td align="center">51.9</td>
<td align="center">45.9</td>
<td align="center"></td>
<td align="center"></td>
<td align="center"></td>
Expand Down
13 changes: 13 additions & 0 deletions detectron2/engine/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,19 @@ class AutogradProfiler(HookBase):
"""
A hook which runs `torch.autograd.profiler.profile`.
Examples:
.. code-block:: python
hooks.AutogradProfiler(
lambda trainer: trainer.iter > 10 and trainer.iter < 20, self.cfg.OUTPUT_DIR
)
The above example will run the profiler for iteration 10~20 and dump
results to ``OUTPUT_DIR``. We did not profile the first few iterations
because they are typically slower than the rest.
The result files can be loaded in the ``chrome://tracing`` page in chrome browser.
Note:
When used together with NCCL on older version of GPUs,
autograd profiler may cause deadlock because it unnecessarily allocates
Expand Down
3 changes: 2 additions & 1 deletion detectron2/modeling/test_time_augmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ def _inference_one_image(self, input):

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

Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/models.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ corresponds to information about one image.

The dict may contain the following keys:

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

0 comments on commit 3506d46

Please sign in to comment.