Skip to content
This repository was archived by the owner on Nov 21, 2023. It is now read-only.

Commit 2a21855

Browse files
authored
Merge branch 'master' into patch-1
2 parents a972763 + 9387594 commit 2a21855

File tree

21 files changed

+299
-92
lines changed

21 files changed

+299
-92
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ target_link_libraries(caffe2_detectron_custom_ops caffe2_library)
3838
install(TARGETS caffe2_detectron_custom_ops DESTINATION lib)
3939

4040
# Install custom GPU ops lib, if gpu is present.
41-
if (${CAFFE2_FOUND_CUDA})
41+
if (CAFFE2_USE_CUDA OR CAFFE2_FOUND_CUDA)
4242
# Additional -I prefix is required for CMake versions before commit (< 3.7):
4343
# https://github.com/Kitware/CMake/commit/7ded655f7ba82ea72a82d0555449f2df5ef38594
4444
list(APPEND CUDA_INCLUDE_DIRS -I${CAFFE2_INCLUDE_DIRS})

INSTALL.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Set up Python modules:
6969
cd $DETECTRON && make
7070
```
7171

72-
Check that Detectron tests pass (e.g. for [`SpatialNarrowAsOp test`](tests/test_spatial_narrow_as_op.py)):
72+
Check that Detectron tests pass (e.g. for [`SpatialNarrowAsOp test`](detectron/tests/test_spatial_narrow_as_op.py)):
7373

7474
```
7575
python2 $DETECTRON/detectron/tests/test_spatial_narrow_as_op.py
@@ -115,7 +115,7 @@ cd $DETECTRON/docker
115115
docker build -t detectron:c2-cuda9-cudnn7 .
116116
```
117117

118-
Run the image (e.g. for [`BatchPermutationOp test`](tests/test_batch_permutation_op.py)):
118+
Run the image (e.g. for [`BatchPermutationOp test`](detectron/tests/test_batch_permutation_op.py)):
119119

120120
```
121121
nvidia-docker run --rm -it detectron:c2-cuda9-cudnn7 python2 detectron/tests/test_batch_permutation_op.py
@@ -129,7 +129,7 @@ In case of Caffe2 installation problems, please read the troubleshooting section
129129

130130
Caffe2 comes with performance [`profiling`](https://github.com/caffe2/caffe2/tree/master/caffe2/contrib/prof)
131131
support which you may find useful for benchmarking or debugging your operators
132-
(see [`BatchPermutationOp test`](tests/test_batch_permutation_op.py) for example usage).
132+
(see [`BatchPermutationOp test`](detectron/tests/test_batch_permutation_op.py) for example usage).
133133
Profiling support is not built by default and you can enable it by setting
134134
the `-DUSE_PROF=ON` flag when running Caffe2 CMake.
135135

cmake/Summary.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ function (detectron_print_config_summary)
1111
message(STATUS " CXX flags : ${CMAKE_CXX_FLAGS}")
1212
message(STATUS " Caffe2 version : ${CAFFE2_VERSION}")
1313
message(STATUS " Caffe2 include path : ${CAFFE2_INCLUDE_DIRS}")
14-
message(STATUS " Caffe2 found CUDA : ${CAFFE2_FOUND_CUDA}")
15-
if (${CAFFE2_FOUND_CUDA})
14+
if (CAFFE2_USE_CUDA OR CAFFE2_FOUND_CUDA)
15+
message(STATUS " Caffe2 found CUDA : True")
1616
message(STATUS " CUDA version : ${CUDA_VERSION}")
1717
message(STATUS " CuDNN version : ${CUDNN_VERSION}")
18+
else()
19+
message(STATUS " Caffe2 found CUDA : False")
1820
endif()
1921
endfunction()

configs/04_2018_gn_baselines/scratch_e2e_mask_rcnn_R-101-FPN_3x_gn.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ MRCNN:
3737
CONV_INIT: MSRAFill # default GaussianFill
3838
TRAIN:
3939
# WEIGHTS: N/A
40+
FREEZE_AT: 0
4041
DATASETS: ('coco_2014_train', 'coco_2014_valminusminival')
4142
SCALES: (800,)
4243
MAX_SIZE: 1333

configs/04_2018_gn_baselines/scratch_e2e_mask_rcnn_R-50-FPN_3x_gn.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ MRCNN:
3737
CONV_INIT: MSRAFill # default GaussianFill
3838
TRAIN:
3939
# WEIGHTS: N/A
40+
FREEZE_AT: 0
4041
DATASETS: ('coco_2014_train', 'coco_2014_valminusminival')
4142
SCALES: (800,)
4243
MAX_SIZE: 1333

detectron/core/config.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@
189189
# output directory
190190
__C.TRAIN.AUTO_RESUME = True
191191

192+
# Training will copy TRAIN.WEIGHTS and treat it as a candidate checkpoint
193+
__C.TRAIN.COPY_WEIGHTS = False
194+
195+
# Add StopGrad at a specified stage so the bottom layers are frozen
196+
__C.TRAIN.FREEZE_AT = 2
197+
192198

193199
# ---------------------------------------------------------------------------- #
194200
# Data loader options (see detectron/roi_data/loader.py for more info)
@@ -776,7 +782,7 @@
776782

777783

778784
# ---------------------------------------------------------------------------- #
779-
# Keyoint Mask R-CNN options ("KRCNN" = Mask R-CNN with Keypoint support)
785+
# Keypoint Mask R-CNN options ("KRCNN" = Mask R-CNN with Keypoint support)
780786
# ---------------------------------------------------------------------------- #
781787
__C.KRCNN = AttrDict()
782788

@@ -966,6 +972,9 @@
966972
# Absolute and relative tolerance to use when comparing to EXPECTED_RESULTS
967973
__C.EXPECTED_RESULTS_RTOL = 0.1
968974
__C.EXPECTED_RESULTS_ATOL = 0.005
975+
# When the expected value specifies a mean and standard deviation, we check
976+
# that the actual value is within mean +/- SIGMA_TOL * std
977+
__C.EXPECTED_RESULTS_SIGMA_TOL = 4
969978
# Set to send email in case of an EXPECTED_RESULTS failure
970979
__C.EXPECTED_RESULTS_EMAIL = b''
971980

@@ -988,7 +997,7 @@
988997
# If an option is removed from the code and you don't want to break existing
989998
# yaml configs, you can add the full config key as a string to the set below.
990999
# ---------------------------------------------------------------------------- #
991-
_DEPCRECATED_KEYS = set(
1000+
_DEPRECATED_KEYS = set(
9921001
{
9931002
'FINAL_MSG',
9941003
'MODEL.DILATION',
@@ -1189,7 +1198,7 @@ def _merge_a_into_b(a, b, stack=None):
11891198

11901199

11911200
def _key_is_deprecated(full_key):
1192-
if full_key in _DEPCRECATED_KEYS:
1201+
if full_key in _DEPRECATED_KEYS:
11931202
logger.warn(
11941203
'Deprecated config key (ignoring): {}'.format(full_key)
11951204
)

detectron/datasets/data/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ VOC<year>
5151
| |_ ...
5252
| |_ <im-N-name>.jpg
5353
|_ annotations
54-
| |_ voc_<year>_trainval.json
54+
| |_ voc_<year>_train.json
55+
| |_ voc_<year>_val.json
5556
| |_ ...
5657
|_ VOCdevkit<year>
5758
```

detectron/datasets/dataset_catalog.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,19 @@
162162
_ANN_FN:
163163
_DATA_DIR + '/coco/annotations/image_info_test-dev2015.json'
164164
},
165-
'voc_2007_trainval': {
165+
'voc_2007_train': {
166166
_IM_DIR:
167167
_DATA_DIR + '/VOC2007/JPEGImages',
168168
_ANN_FN:
169-
_DATA_DIR + '/VOC2007/annotations/voc_2007_trainval.json',
169+
_DATA_DIR + '/VOC2007/annotations/voc_2007_train.json',
170+
_DEVKIT_DIR:
171+
_DATA_DIR + '/VOC2007/VOCdevkit2007'
172+
},
173+
'voc_2007_val': {
174+
_IM_DIR:
175+
_DATA_DIR + '/VOC2007/JPEGImages',
176+
_ANN_FN:
177+
_DATA_DIR + '/VOC2007/annotations/voc_2007_val.json',
170178
_DEVKIT_DIR:
171179
_DATA_DIR + '/VOC2007/VOCdevkit2007'
172180
},
@@ -178,11 +186,19 @@
178186
_DEVKIT_DIR:
179187
_DATA_DIR + '/VOC2007/VOCdevkit2007'
180188
},
181-
'voc_2012_trainval': {
189+
'voc_2012_train': {
190+
_IM_DIR:
191+
_DATA_DIR + '/VOC2012/JPEGImages',
192+
_ANN_FN:
193+
_DATA_DIR + '/VOC2012/annotations/voc_2012_train.json',
194+
_DEVKIT_DIR:
195+
_DATA_DIR + '/VOC2012/VOCdevkit2012'
196+
},
197+
'voc_2012_val': {
182198
_IM_DIR:
183199
_DATA_DIR + '/VOC2012/JPEGImages',
184200
_ANN_FN:
185-
_DATA_DIR + '/VOC2012/annotations/voc_2012_trainval.json',
201+
_DATA_DIR + '/VOC2012/annotations/voc_2012_val.json',
186202
_DEVKIT_DIR:
187203
_DATA_DIR + '/VOC2012/VOCdevkit2012'
188204
}

detectron/datasets/json_dataset.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
from detectron.utils.timer import Timer
4444
import detectron.datasets.dataset_catalog as dataset_catalog
4545
import detectron.utils.boxes as box_utils
46+
import detectron.utils.segms as segm_utils
4647

4748
logger = logging.getLogger(__name__)
4849

@@ -167,8 +168,8 @@ def _add_gt_annotations(self, entry):
167168
width = entry['width']
168169
height = entry['height']
169170
for obj in objs:
170-
# crowd regions are RLE encoded and stored as dicts
171-
if isinstance(obj['segmentation'], list):
171+
# crowd regions are RLE encoded
172+
if segm_utils.is_poly(obj['segmentation']):
172173
# Valid polygons have >= 3 points, so require >= 6 coordinates
173174
obj['segmentation'] = [
174175
p for p in obj['segmentation'] if len(p) >= 6

detectron/datasets/task_evaluation.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ def check_expected_results(results, atol=0.005, rtol=0.1):
195195
Expected results should take the form of a list of expectations, each
196196
specified by four elements: [dataset, task, metric, expected value]. For
197197
example: [['coco_2014_minival', 'box_proposal', 'AR@1000', 0.387], ...].
198+
199+
The expected value may also be formatted as a list [mean, std] providing
200+
an empirical mean and standard deviation from which a valid range is computed
201+
using cfg.EXPECTED_RESULTS_SIGMA_TOL. For example:
202+
[['coco_2014_minival', 'box_proposal', 'AR@1000', [0.387, 0.001]], ...]
198203
"""
199204
# cfg contains a reference set of results that we want to check against
200205
if len(cfg.EXPECTED_RESULTS) == 0:
@@ -206,13 +211,28 @@ def check_expected_results(results, atol=0.005, rtol=0.1):
206211
assert metric in results[dataset][task], \
207212
'Metric {} not in results'.format(metric)
208213
actual_val = results[dataset][task][metric]
209-
err = abs(actual_val - expected_val)
210-
tol = atol + rtol * abs(expected_val)
211-
msg = (
212-
'{} > {} > {} sanity check (actual vs. expected): '
213-
'{:.3f} vs. {:.3f}, err={:.3f}, tol={:.3f}'
214-
).format(dataset, task, metric, actual_val, expected_val, err, tol)
215-
if err > tol:
214+
ok = False
215+
if isinstance(expected_val, list):
216+
assert len(expected_val) == 2, (
217+
'Expected result must be in (mean, std) format'
218+
)
219+
mean, std = expected_val
220+
lo = mean - cfg.EXPECTED_RESULTS_SIGMA_TOL * std
221+
hi = mean + cfg.EXPECTED_RESULTS_SIGMA_TOL * std
222+
ok = (lo < actual_val) and (actual_val < hi)
223+
msg = (
224+
'{} > {} > {} sanity check (actual vs. expected): '
225+
'{:.3f} vs. mean={:.4f}, std={:.4}, range=({:.4f}, {:.4f})'
226+
).format(dataset, task, metric, actual_val, mean, std, lo, hi)
227+
else:
228+
err = abs(actual_val - expected_val)
229+
tol = atol + rtol * abs(expected_val)
230+
ok = (err > tol)
231+
msg = (
232+
'{} > {} > {} sanity check (actual vs. expected): '
233+
'{:.3f} vs. {:.3f}, err={:.3f}, tol={:.3f}'
234+
).format(dataset, task, metric, actual_val, expected_val, err, tol)
235+
if not ok:
216236
msg = 'FAIL: ' + msg
217237
logger.error(msg)
218238
if cfg.EXPECTED_RESULTS_EMAIL != '':

0 commit comments

Comments
 (0)