Commit
•
fcd8cdd
1
Parent(s):
f979c69
Upload 1389 files
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- detectron2/.circleci/config.yml +271 -0
- detectron2/.circleci/import-tests.sh +16 -0
- detectron2/.clang-format +85 -0
- detectron2/.flake8 +15 -0
- detectron2/.github/CODE_OF_CONDUCT.md +5 -0
- detectron2/.github/CONTRIBUTING.md +68 -0
- detectron2/.github/Detectron2-Logo-Horz.svg +1 -0
- detectron2/.github/ISSUE_TEMPLATE.md +5 -0
- detectron2/.github/ISSUE_TEMPLATE/bugs.md +38 -0
- detectron2/.github/ISSUE_TEMPLATE/config.yml +17 -0
- detectron2/.github/ISSUE_TEMPLATE/documentation.md +14 -0
- detectron2/.github/ISSUE_TEMPLATE/feature-request.md +31 -0
- detectron2/.github/ISSUE_TEMPLATE/unexpected-problems-bugs.md +44 -0
- detectron2/.github/pull_request_template.md +10 -0
- detectron2/.github/workflows/check-template.yml +86 -0
- detectron2/.github/workflows/levenshtein.js +44 -0
- detectron2/.github/workflows/needs-reply.yml +98 -0
- detectron2/.github/workflows/remove-needs-reply.yml +25 -0
- detectron2/.github/workflows/workflow.yml +81 -0
- detectron2/.gitignore +53 -0
- detectron2/GETTING_STARTED.md +79 -0
- detectron2/INSTALL.md +261 -0
- detectron2/LICENSE +202 -0
- detectron2/MODEL_ZOO.md +1052 -0
- detectron2/README.md +68 -0
- detectron2/__init__.py +10 -0
- detectron2/__pycache__/__init__.cpython-310.pyc +0 -0
- detectron2/__pycache__/__init__.cpython-311.pyc +0 -0
- detectron2/checkpoint/__init__.py +10 -0
- detectron2/checkpoint/__pycache__/__init__.cpython-310.pyc +0 -0
- detectron2/checkpoint/__pycache__/__init__.cpython-311.pyc +0 -0
- detectron2/checkpoint/__pycache__/c2_model_loading.cpython-310.pyc +0 -0
- detectron2/checkpoint/__pycache__/c2_model_loading.cpython-311.pyc +0 -0
- detectron2/checkpoint/__pycache__/catalog.cpython-310.pyc +0 -0
- detectron2/checkpoint/__pycache__/catalog.cpython-311.pyc +0 -0
- detectron2/checkpoint/__pycache__/detection_checkpoint.cpython-310.pyc +0 -0
- detectron2/checkpoint/__pycache__/detection_checkpoint.cpython-311.pyc +0 -0
- detectron2/checkpoint/c2_model_loading.py +412 -0
- detectron2/checkpoint/catalog.py +115 -0
- detectron2/checkpoint/detection_checkpoint.py +143 -0
- detectron2/config/__init__.py +24 -0
- detectron2/config/__pycache__/__init__.cpython-310.pyc +0 -0
- detectron2/config/__pycache__/__init__.cpython-311.pyc +0 -0
- detectron2/config/__pycache__/compat.cpython-310.pyc +0 -0
- detectron2/config/__pycache__/compat.cpython-311.pyc +0 -0
- detectron2/config/__pycache__/config.cpython-310.pyc +0 -0
- detectron2/config/__pycache__/config.cpython-311.pyc +0 -0
- detectron2/config/__pycache__/defaults.cpython-310.pyc +0 -0
- detectron2/config/__pycache__/defaults.cpython-311.pyc +0 -0
- detectron2/config/__pycache__/instantiate.cpython-310.pyc +0 -0
detectron2/.circleci/config.yml
ADDED
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: 2.1
|
2 |
+
|
3 |
+
# -------------------------------------------------------------------------------------
|
4 |
+
# Environments to run the jobs in
|
5 |
+
# -------------------------------------------------------------------------------------
|
6 |
+
cpu: &cpu
|
7 |
+
machine:
|
8 |
+
image: ubuntu-2004:202107-02
|
9 |
+
resource_class: medium
|
10 |
+
|
11 |
+
gpu: &gpu
|
12 |
+
machine:
|
13 |
+
# NOTE: use a cuda version that's supported by all our pytorch versions
|
14 |
+
image: ubuntu-1604-cuda-11.1:202012-01
|
15 |
+
resource_class: gpu.nvidia.small
|
16 |
+
|
17 |
+
windows-cpu: &windows_cpu
|
18 |
+
machine:
|
19 |
+
resource_class: windows.medium
|
20 |
+
image: windows-server-2019-vs2019:stable
|
21 |
+
shell: powershell.exe
|
22 |
+
|
23 |
+
# windows-gpu: &windows_gpu
|
24 |
+
# machine:
|
25 |
+
# resource_class: windows.gpu.nvidia.medium
|
26 |
+
# image: windows-server-2019-nvidia:stable
|
27 |
+
|
28 |
+
version_parameters: &version_parameters
|
29 |
+
parameters:
|
30 |
+
pytorch_version:
|
31 |
+
type: string
|
32 |
+
torchvision_version:
|
33 |
+
type: string
|
34 |
+
pytorch_index:
|
35 |
+
type: string
|
36 |
+
# use test wheels index to have access to RC wheels
|
37 |
+
# https://download.pytorch.org/whl/test/torch_test.html
|
38 |
+
default: "https://download.pytorch.org/whl/torch_stable.html"
|
39 |
+
python_version: # NOTE: only affect linux
|
40 |
+
type: string
|
41 |
+
default: '3.8.6'
|
42 |
+
|
43 |
+
environment:
|
44 |
+
PYTORCH_VERSION: << parameters.pytorch_version >>
|
45 |
+
TORCHVISION_VERSION: << parameters.torchvision_version >>
|
46 |
+
PYTORCH_INDEX: << parameters.pytorch_index >>
|
47 |
+
PYTHON_VERSION: << parameters.python_version>>
|
48 |
+
# point datasets to ~/.torch so it's cached in CI
|
49 |
+
DETECTRON2_DATASETS: ~/.torch/datasets
|
50 |
+
|
51 |
+
# -------------------------------------------------------------------------------------
|
52 |
+
# Re-usable commands
|
53 |
+
# -------------------------------------------------------------------------------------
|
54 |
+
# install_nvidia_driver: &install_nvidia_driver
|
55 |
+
# - run:
|
56 |
+
# name: Install nvidia driver
|
57 |
+
# working_directory: ~/
|
58 |
+
# command: |
|
59 |
+
# wget -q 'https://s3.amazonaws.com/ossci-linux/nvidia_driver/NVIDIA-Linux-x86_64-430.40.run'
|
60 |
+
# sudo /bin/bash ./NVIDIA-Linux-x86_64-430.40.run -s --no-drm
|
61 |
+
# nvidia-smi
|
62 |
+
|
63 |
+
add_ssh_keys: &add_ssh_keys
|
64 |
+
# https://circleci.com/docs/2.0/add-ssh-key/
|
65 |
+
- add_ssh_keys:
|
66 |
+
fingerprints:
|
67 |
+
- "e4:13:f2:22:d4:49:e8:e4:57:5a:ac:20:2f:3f:1f:ca"
|
68 |
+
|
69 |
+
install_python: &install_python
|
70 |
+
- run:
|
71 |
+
name: Install Python
|
72 |
+
working_directory: ~/
|
73 |
+
command: |
|
74 |
+
# upgrade pyenv
|
75 |
+
cd /opt/circleci/.pyenv/plugins/python-build/../.. && git pull && cd -
|
76 |
+
pyenv install -s $PYTHON_VERSION
|
77 |
+
pyenv global $PYTHON_VERSION
|
78 |
+
python --version
|
79 |
+
which python
|
80 |
+
pip install --upgrade pip
|
81 |
+
|
82 |
+
setup_venv: &setup_venv
|
83 |
+
- run:
|
84 |
+
name: Setup Virtual Env
|
85 |
+
working_directory: ~/
|
86 |
+
command: |
|
87 |
+
python -m venv ~/venv
|
88 |
+
echo ". ~/venv/bin/activate" >> $BASH_ENV
|
89 |
+
. ~/venv/bin/activate
|
90 |
+
python --version
|
91 |
+
which python
|
92 |
+
which pip
|
93 |
+
pip install --upgrade pip
|
94 |
+
|
95 |
+
setup_venv_win: &setup_venv_win
|
96 |
+
- run:
|
97 |
+
name: Setup Virtual Env for Windows
|
98 |
+
command: |
|
99 |
+
pip install virtualenv
|
100 |
+
python -m virtualenv env
|
101 |
+
.\env\Scripts\activate
|
102 |
+
python --version
|
103 |
+
which python
|
104 |
+
which pip
|
105 |
+
|
106 |
+
install_linux_dep: &install_linux_dep
|
107 |
+
- run:
|
108 |
+
name: Install Dependencies
|
109 |
+
command: |
|
110 |
+
# disable crash coredump, so unittests fail fast
|
111 |
+
sudo systemctl stop apport.service
|
112 |
+
# install from github to get latest; install iopath first since fvcore depends on it
|
113 |
+
pip install --progress-bar off -U 'git+https://github.com/facebookresearch/iopath'
|
114 |
+
pip install --progress-bar off -U 'git+https://github.com/facebookresearch/fvcore'
|
115 |
+
# Don't use pytest-xdist: cuda tests are unstable under multi-process workers.
|
116 |
+
# Don't use opencv 4.7.0.68: https://github.com/opencv/opencv-python/issues/765
|
117 |
+
pip install --progress-bar off ninja opencv-python-headless!=4.7.0.68 pytest tensorboard pycocotools onnx
|
118 |
+
pip install --progress-bar off torch==$PYTORCH_VERSION -f $PYTORCH_INDEX
|
119 |
+
if [[ "$TORCHVISION_VERSION" == "master" ]]; then
|
120 |
+
pip install git+https://github.com/pytorch/vision.git
|
121 |
+
else
|
122 |
+
pip install --progress-bar off torchvision==$TORCHVISION_VERSION -f $PYTORCH_INDEX
|
123 |
+
fi
|
124 |
+
|
125 |
+
python -c 'import torch; print("CUDA:", torch.cuda.is_available())'
|
126 |
+
gcc --version
|
127 |
+
|
128 |
+
install_detectron2: &install_detectron2
|
129 |
+
- run:
|
130 |
+
name: Install Detectron2
|
131 |
+
command: |
|
132 |
+
# Remove first, in case it's in the CI cache
|
133 |
+
pip uninstall -y detectron2
|
134 |
+
|
135 |
+
pip install --progress-bar off -e .[all]
|
136 |
+
python -m detectron2.utils.collect_env
|
137 |
+
./datasets/prepare_for_tests.sh
|
138 |
+
|
139 |
+
run_unittests: &run_unittests
|
140 |
+
- run:
|
141 |
+
name: Run Unit Tests
|
142 |
+
command: |
|
143 |
+
pytest -sv --durations=15 tests # parallel causes some random failures
|
144 |
+
|
145 |
+
uninstall_tests: &uninstall_tests
|
146 |
+
- run:
|
147 |
+
name: Run Tests After Uninstalling
|
148 |
+
command: |
|
149 |
+
pip uninstall -y detectron2
|
150 |
+
# Remove built binaries
|
151 |
+
rm -rf build/ detectron2/*.so
|
152 |
+
# Tests that code is importable without installation
|
153 |
+
PYTHONPATH=. ./.circleci/import-tests.sh
|
154 |
+
|
155 |
+
|
156 |
+
# -------------------------------------------------------------------------------------
|
157 |
+
# Jobs to run
|
158 |
+
# -------------------------------------------------------------------------------------
|
159 |
+
jobs:
|
160 |
+
linux_cpu_tests:
|
161 |
+
<<: *cpu
|
162 |
+
<<: *version_parameters
|
163 |
+
|
164 |
+
working_directory: ~/detectron2
|
165 |
+
|
166 |
+
steps:
|
167 |
+
- checkout
|
168 |
+
|
169 |
+
# Cache the venv directory that contains python, dependencies, and checkpoints
|
170 |
+
# Refresh the key when dependencies should be updated (e.g. when pytorch releases)
|
171 |
+
- restore_cache:
|
172 |
+
keys:
|
173 |
+
- cache-{{ arch }}-<< parameters.pytorch_version >>-{{ .Branch }}-20210827
|
174 |
+
|
175 |
+
- <<: *install_python
|
176 |
+
- <<: *install_linux_dep
|
177 |
+
- <<: *install_detectron2
|
178 |
+
- <<: *run_unittests
|
179 |
+
- <<: *uninstall_tests
|
180 |
+
|
181 |
+
- save_cache:
|
182 |
+
paths:
|
183 |
+
- /opt/circleci/.pyenv
|
184 |
+
- ~/.torch
|
185 |
+
key: cache-{{ arch }}-<< parameters.pytorch_version >>-{{ .Branch }}-20210827
|
186 |
+
|
187 |
+
|
188 |
+
linux_gpu_tests:
|
189 |
+
<<: *gpu
|
190 |
+
<<: *version_parameters
|
191 |
+
|
192 |
+
working_directory: ~/detectron2
|
193 |
+
|
194 |
+
steps:
|
195 |
+
- checkout
|
196 |
+
|
197 |
+
- restore_cache:
|
198 |
+
keys:
|
199 |
+
- cache-{{ arch }}-<< parameters.pytorch_version >>-{{ .Branch }}-20210827
|
200 |
+
|
201 |
+
- <<: *install_python
|
202 |
+
- <<: *install_linux_dep
|
203 |
+
- <<: *install_detectron2
|
204 |
+
- <<: *run_unittests
|
205 |
+
- <<: *uninstall_tests
|
206 |
+
|
207 |
+
- save_cache:
|
208 |
+
paths:
|
209 |
+
- /opt/circleci/.pyenv
|
210 |
+
- ~/.torch
|
211 |
+
key: cache-{{ arch }}-<< parameters.pytorch_version >>-{{ .Branch }}-20210827
|
212 |
+
|
213 |
+
windows_cpu_build:
|
214 |
+
<<: *windows_cpu
|
215 |
+
<<: *version_parameters
|
216 |
+
steps:
|
217 |
+
- <<: *add_ssh_keys
|
218 |
+
- checkout
|
219 |
+
- <<: *setup_venv_win
|
220 |
+
|
221 |
+
# Cache the env directory that contains dependencies
|
222 |
+
- restore_cache:
|
223 |
+
keys:
|
224 |
+
- cache-{{ arch }}-<< parameters.pytorch_version >>-{{ .Branch }}-20210404
|
225 |
+
|
226 |
+
- run:
|
227 |
+
name: Install Dependencies
|
228 |
+
command: |
|
229 |
+
pip install certifi --ignore-installed # required on windows to workaround some cert issue
|
230 |
+
pip install numpy cython # required on windows before pycocotools
|
231 |
+
pip install opencv-python-headless pytest-xdist pycocotools tensorboard onnx
|
232 |
+
pip install -U git+https://github.com/facebookresearch/iopath
|
233 |
+
pip install -U git+https://github.com/facebookresearch/fvcore
|
234 |
+
pip install torch==$env:PYTORCH_VERSION torchvision==$env:TORCHVISION_VERSION -f $env:PYTORCH_INDEX
|
235 |
+
|
236 |
+
- save_cache:
|
237 |
+
paths:
|
238 |
+
- env
|
239 |
+
key: cache-{{ arch }}-<< parameters.pytorch_version >>-{{ .Branch }}-20210404
|
240 |
+
|
241 |
+
- <<: *install_detectron2
|
242 |
+
# TODO: unittest fails for now
|
243 |
+
|
244 |
+
workflows:
|
245 |
+
version: 2
|
246 |
+
regular_test:
|
247 |
+
jobs:
|
248 |
+
- linux_cpu_tests:
|
249 |
+
name: linux_cpu_tests_pytorch1.10
|
250 |
+
pytorch_version: '1.10.0+cpu'
|
251 |
+
torchvision_version: '0.11.1+cpu'
|
252 |
+
- linux_gpu_tests:
|
253 |
+
name: linux_gpu_tests_pytorch1.8
|
254 |
+
pytorch_version: '1.8.1+cu111'
|
255 |
+
torchvision_version: '0.9.1+cu111'
|
256 |
+
- linux_gpu_tests:
|
257 |
+
name: linux_gpu_tests_pytorch1.9
|
258 |
+
pytorch_version: '1.9+cu111'
|
259 |
+
torchvision_version: '0.10+cu111'
|
260 |
+
- linux_gpu_tests:
|
261 |
+
name: linux_gpu_tests_pytorch1.10
|
262 |
+
pytorch_version: '1.10+cu111'
|
263 |
+
torchvision_version: '0.11.1+cu111'
|
264 |
+
- linux_gpu_tests:
|
265 |
+
name: linux_gpu_tests_pytorch1.10_python39
|
266 |
+
pytorch_version: '1.10+cu111'
|
267 |
+
torchvision_version: '0.11.1+cu111'
|
268 |
+
python_version: '3.9.6'
|
269 |
+
- windows_cpu_build:
|
270 |
+
pytorch_version: '1.10+cpu'
|
271 |
+
torchvision_version: '0.11.1+cpu'
|
detectron2/.circleci/import-tests.sh
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/bin/bash -e
|
2 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
3 |
+
|
4 |
+
# Test that import works without building detectron2.
|
5 |
+
|
6 |
+
# Check that _C is not importable
|
7 |
+
python -c "from detectron2 import _C" > /dev/null 2>&1 && {
|
8 |
+
echo "This test should be run without building detectron2."
|
9 |
+
exit 1
|
10 |
+
}
|
11 |
+
|
12 |
+
# Check that other modules are still importable, even when _C is not importable
|
13 |
+
python -c "from detectron2 import modeling"
|
14 |
+
python -c "from detectron2 import modeling, data"
|
15 |
+
python -c "from detectron2 import evaluation, export, checkpoint"
|
16 |
+
python -c "from detectron2 import utils, engine"
|
detectron2/.clang-format
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
AccessModifierOffset: -1
|
2 |
+
AlignAfterOpenBracket: AlwaysBreak
|
3 |
+
AlignConsecutiveAssignments: false
|
4 |
+
AlignConsecutiveDeclarations: false
|
5 |
+
AlignEscapedNewlinesLeft: true
|
6 |
+
AlignOperands: false
|
7 |
+
AlignTrailingComments: false
|
8 |
+
AllowAllParametersOfDeclarationOnNextLine: false
|
9 |
+
AllowShortBlocksOnASingleLine: false
|
10 |
+
AllowShortCaseLabelsOnASingleLine: false
|
11 |
+
AllowShortFunctionsOnASingleLine: Empty
|
12 |
+
AllowShortIfStatementsOnASingleLine: false
|
13 |
+
AllowShortLoopsOnASingleLine: false
|
14 |
+
AlwaysBreakAfterReturnType: None
|
15 |
+
AlwaysBreakBeforeMultilineStrings: true
|
16 |
+
AlwaysBreakTemplateDeclarations: true
|
17 |
+
BinPackArguments: false
|
18 |
+
BinPackParameters: false
|
19 |
+
BraceWrapping:
|
20 |
+
AfterClass: false
|
21 |
+
AfterControlStatement: false
|
22 |
+
AfterEnum: false
|
23 |
+
AfterFunction: false
|
24 |
+
AfterNamespace: false
|
25 |
+
AfterObjCDeclaration: false
|
26 |
+
AfterStruct: false
|
27 |
+
AfterUnion: false
|
28 |
+
BeforeCatch: false
|
29 |
+
BeforeElse: false
|
30 |
+
IndentBraces: false
|
31 |
+
BreakBeforeBinaryOperators: None
|
32 |
+
BreakBeforeBraces: Attach
|
33 |
+
BreakBeforeTernaryOperators: true
|
34 |
+
BreakConstructorInitializersBeforeComma: false
|
35 |
+
BreakAfterJavaFieldAnnotations: false
|
36 |
+
BreakStringLiterals: false
|
37 |
+
ColumnLimit: 80
|
38 |
+
CommentPragmas: '^ IWYU pragma:'
|
39 |
+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
|
40 |
+
ConstructorInitializerIndentWidth: 4
|
41 |
+
ContinuationIndentWidth: 4
|
42 |
+
Cpp11BracedListStyle: true
|
43 |
+
DerivePointerAlignment: false
|
44 |
+
DisableFormat: false
|
45 |
+
ForEachMacros: [ FOR_EACH, FOR_EACH_R, FOR_EACH_RANGE, ]
|
46 |
+
IncludeCategories:
|
47 |
+
- Regex: '^<.*\.h(pp)?>'
|
48 |
+
Priority: 1
|
49 |
+
- Regex: '^<.*'
|
50 |
+
Priority: 2
|
51 |
+
- Regex: '.*'
|
52 |
+
Priority: 3
|
53 |
+
IndentCaseLabels: true
|
54 |
+
IndentWidth: 2
|
55 |
+
IndentWrappedFunctionNames: false
|
56 |
+
KeepEmptyLinesAtTheStartOfBlocks: false
|
57 |
+
MacroBlockBegin: ''
|
58 |
+
MacroBlockEnd: ''
|
59 |
+
MaxEmptyLinesToKeep: 1
|
60 |
+
NamespaceIndentation: None
|
61 |
+
ObjCBlockIndentWidth: 2
|
62 |
+
ObjCSpaceAfterProperty: false
|
63 |
+
ObjCSpaceBeforeProtocolList: false
|
64 |
+
PenaltyBreakBeforeFirstCallParameter: 1
|
65 |
+
PenaltyBreakComment: 300
|
66 |
+
PenaltyBreakFirstLessLess: 120
|
67 |
+
PenaltyBreakString: 1000
|
68 |
+
PenaltyExcessCharacter: 1000000
|
69 |
+
PenaltyReturnTypeOnItsOwnLine: 200
|
70 |
+
PointerAlignment: Left
|
71 |
+
ReflowComments: true
|
72 |
+
SortIncludes: true
|
73 |
+
SpaceAfterCStyleCast: false
|
74 |
+
SpaceBeforeAssignmentOperators: true
|
75 |
+
SpaceBeforeParens: ControlStatements
|
76 |
+
SpaceInEmptyParentheses: false
|
77 |
+
SpacesBeforeTrailingComments: 1
|
78 |
+
SpacesInAngles: false
|
79 |
+
SpacesInContainerLiterals: true
|
80 |
+
SpacesInCStyleCastParentheses: false
|
81 |
+
SpacesInParentheses: false
|
82 |
+
SpacesInSquareBrackets: false
|
83 |
+
Standard: Cpp11
|
84 |
+
TabWidth: 8
|
85 |
+
UseTab: Never
|
detectron2/.flake8
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# This is an example .flake8 config, used when developing *Black* itself.
|
2 |
+
# Keep in sync with setup.cfg which is used for source packages.
|
3 |
+
|
4 |
+
[flake8]
|
5 |
+
ignore = W503, E203, E221, C901, C408, E741, C407, B017, F811, C101, EXE001, EXE002
|
6 |
+
max-line-length = 100
|
7 |
+
max-complexity = 18
|
8 |
+
select = B,C,E,F,W,T4,B9
|
9 |
+
exclude = build
|
10 |
+
per-file-ignores =
|
11 |
+
**/__init__.py:F401,F403,E402
|
12 |
+
**/configs/**.py:F401,E402
|
13 |
+
configs/**.py:F401,E402
|
14 |
+
**/tests/config/**.py:F401,E402
|
15 |
+
tests/config/**.py:F401,E402
|
detectron2/.github/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Code of Conduct
|
2 |
+
|
3 |
+
Facebook has adopted a Code of Conduct that we expect project participants to adhere to.
|
4 |
+
Please read the [full text](https://code.fb.com/codeofconduct/)
|
5 |
+
so that you can understand what actions will and will not be tolerated.
|
detectron2/.github/CONTRIBUTING.md
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Contributing to detectron2
|
2 |
+
|
3 |
+
## Issues
|
4 |
+
We use GitHub issues to track public bugs and questions.
|
5 |
+
Please make sure to follow one of the
|
6 |
+
[issue templates](https://github.com/facebookresearch/detectron2/issues/new/choose)
|
7 |
+
when reporting any issues.
|
8 |
+
|
9 |
+
Facebook has a [bounty program](https://www.facebook.com/whitehat/) for the safe
|
10 |
+
disclosure of security bugs. In those cases, please go through the process
|
11 |
+
outlined on that page and do not file a public issue.
|
12 |
+
|
13 |
+
## Pull Requests
|
14 |
+
We actively welcome pull requests.
|
15 |
+
|
16 |
+
However, if you're adding any significant features (e.g. > 50 lines), please
|
17 |
+
make sure to discuss with maintainers about your motivation and proposals in an issue
|
18 |
+
before sending a PR. This is to save your time so you don't spend time on a PR that we'll not accept.
|
19 |
+
|
20 |
+
We do not always accept new features, and we take the following
|
21 |
+
factors into consideration:
|
22 |
+
|
23 |
+
1. Whether the same feature can be achieved without modifying detectron2.
|
24 |
+
Detectron2 is designed so that you can implement many extensions from the outside, e.g.
|
25 |
+
those in [projects](https://github.com/facebookresearch/detectron2/tree/master/projects).
|
26 |
+
* If some part of detectron2 is not extensible enough, you can also bring up a more general issue to
|
27 |
+
improve it. Such feature request may be useful to more users.
|
28 |
+
2. Whether the feature is potentially useful to a large audience (e.g. an impactful detection paper, a popular dataset,
|
29 |
+
a significant speedup, a widely useful utility),
|
30 |
+
or only to a small portion of users (e.g., a less-known paper, an improvement not in the object
|
31 |
+
detection field, a trick that's not very popular in the community, code to handle a non-standard type of data)
|
32 |
+
* Adoption of additional models, datasets, new task are by default not added to detectron2 before they
|
33 |
+
receive significant popularity in the community.
|
34 |
+
We sometimes accept such features in `projects/`, or as a link in `projects/README.md`.
|
35 |
+
3. Whether the proposed solution has a good design / interface. This can be discussed in the issue prior to PRs, or
|
36 |
+
in the form of a draft PR.
|
37 |
+
4. Whether the proposed solution adds extra mental/practical overhead to users who don't
|
38 |
+
need such feature.
|
39 |
+
5. Whether the proposed solution breaks existing APIs.
|
40 |
+
|
41 |
+
To add a feature to an existing function/class `Func`, there are always two approaches:
|
42 |
+
(1) add new arguments to `Func`; (2) write a new `Func_with_new_feature`.
|
43 |
+
To meet the above criteria, we often prefer approach (2), because:
|
44 |
+
|
45 |
+
1. It does not involve modifying or potentially breaking existing code.
|
46 |
+
2. It does not add overhead to users who do not need the new feature.
|
47 |
+
3. Adding new arguments to a function/class is not scalable w.r.t. all the possible new research ideas in the future.
|
48 |
+
|
49 |
+
When sending a PR, please do:
|
50 |
+
|
51 |
+
1. If a PR contains multiple orthogonal changes, split it to several PRs.
|
52 |
+
2. If you've added code that should be tested, add tests.
|
53 |
+
3. For PRs that need experiments (e.g. adding a new model or new methods),
|
54 |
+
you don't need to update model zoo, but do provide experiment results in the description of the PR.
|
55 |
+
4. If APIs are changed, update the documentation.
|
56 |
+
5. We use the [Google style docstrings](https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html) in python.
|
57 |
+
6. Make sure your code lints with `./dev/linter.sh`.
|
58 |
+
|
59 |
+
|
60 |
+
## Contributor License Agreement ("CLA")
|
61 |
+
In order to accept your pull request, we need you to submit a CLA. You only need
|
62 |
+
to do this once to work on any of Facebook's open source projects.
|
63 |
+
|
64 |
+
Complete your CLA here: <https://code.facebook.com/cla>
|
65 |
+
|
66 |
+
## License
|
67 |
+
By contributing to detectron2, you agree that your contributions will be licensed
|
68 |
+
under the LICENSE file in the root directory of this source tree.
|
detectron2/.github/Detectron2-Logo-Horz.svg
ADDED
|
detectron2/.github/ISSUE_TEMPLATE.md
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
Please select an issue template from
|
3 |
+
https://github.com/facebookresearch/detectron2/issues/new/choose .
|
4 |
+
|
5 |
+
Otherwise your issue will be closed.
|
detectron2/.github/ISSUE_TEMPLATE/bugs.md
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
name: "🐛 Bugs"
|
3 |
+
about: Report bugs in detectron2
|
4 |
+
title: Please read & provide the following
|
5 |
+
|
6 |
+
---
|
7 |
+
|
8 |
+
## Instructions To Reproduce the 🐛 Bug:
|
9 |
+
1. Full runnable code or full changes you made:
|
10 |
+
```
|
11 |
+
If making changes to the project itself, please use output of the following command:
|
12 |
+
git rev-parse HEAD; git diff
|
13 |
+
|
14 |
+
<put code or diff here>
|
15 |
+
```
|
16 |
+
2. What exact command you run:
|
17 |
+
3. __Full logs__ or other relevant observations:
|
18 |
+
```
|
19 |
+
<put logs here>
|
20 |
+
```
|
21 |
+
4. please simplify the steps as much as possible so they do not require additional resources to
|
22 |
+
run, such as a private dataset.
|
23 |
+
|
24 |
+
## Expected behavior:
|
25 |
+
|
26 |
+
If there are no obvious error in "full logs" provided above,
|
27 |
+
please tell us the expected behavior.
|
28 |
+
|
29 |
+
## Environment:
|
30 |
+
|
31 |
+
Provide your environment information using the following command:
|
32 |
+
```
|
33 |
+
wget -nc -q https://github.com/facebookresearch/detectron2/raw/main/detectron2/utils/collect_env.py && python collect_env.py
|
34 |
+
```
|
35 |
+
|
36 |
+
If your issue looks like an installation issue / environment issue,
|
37 |
+
please first try to solve it yourself with the instructions in
|
38 |
+
https://detectron2.readthedocs.io/tutorials/install.html#common-installation-issues
|
detectron2/.github/ISSUE_TEMPLATE/config.yml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# require an issue template to be chosen
|
2 |
+
blank_issues_enabled: false
|
3 |
+
|
4 |
+
contact_links:
|
5 |
+
- name: How-To / All Other Questions
|
6 |
+
url: https://github.com/facebookresearch/detectron2/discussions
|
7 |
+
about: Use "github discussions" for community support on general questions that don't belong to the above issue categories
|
8 |
+
- name: Detectron2 Documentation
|
9 |
+
url: https://detectron2.readthedocs.io/index.html
|
10 |
+
about: Check if your question is answered in tutorials or API docs
|
11 |
+
|
12 |
+
# Unexpected behaviors & bugs are split to two templates.
|
13 |
+
# When they are one template, users think "it's not a bug" and don't choose the template.
|
14 |
+
#
|
15 |
+
# But the file name is still "unexpected-problems-bugs.md" so that old references
|
16 |
+
# to this issue template still works.
|
17 |
+
# It's ok since this template should be a superset of "bugs.md" (unexpected behaviors is a superset of bugs)
|
detectron2/.github/ISSUE_TEMPLATE/documentation.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
name: "\U0001F4DA Documentation Issue"
|
3 |
+
about: Report a problem about existing documentation, comments, website or tutorials.
|
4 |
+
labels: documentation
|
5 |
+
|
6 |
+
---
|
7 |
+
|
8 |
+
## 📚 Documentation Issue
|
9 |
+
|
10 |
+
This issue category is for problems about existing documentation, not for asking how-to questions.
|
11 |
+
|
12 |
+
* Provide a link to an existing documentation/comment/tutorial:
|
13 |
+
|
14 |
+
* How should the above documentation/comment/tutorial improve:
|
detectron2/.github/ISSUE_TEMPLATE/feature-request.md
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
name: "\U0001F680Feature Request"
|
3 |
+
about: Suggest an improvement or new feature
|
4 |
+
labels: enhancement
|
5 |
+
|
6 |
+
---
|
7 |
+
|
8 |
+
## 🚀 Feature
|
9 |
+
A clear and concise description of the feature proposal.
|
10 |
+
|
11 |
+
## Motivation & Examples
|
12 |
+
|
13 |
+
Tell us why the feature is useful.
|
14 |
+
|
15 |
+
Describe what the feature would look like, if it is implemented.
|
16 |
+
Best demonstrated using **code examples** in addition to words.
|
17 |
+
|
18 |
+
## Note
|
19 |
+
|
20 |
+
We only consider adding new features if they are relevant to many users.
|
21 |
+
|
22 |
+
If you request implementation of research papers -- we only consider papers that have enough significance and prevalance in the object detection field.
|
23 |
+
|
24 |
+
We do not take requests for most projects in the `projects/` directory, because they are research code release that is mainly for other researchers to reproduce results.
|
25 |
+
|
26 |
+
"Make X faster/accurate" is not a valid feature request. "Implement a concrete feature that can make X faster/accurate" can be a valid feature request.
|
27 |
+
|
28 |
+
Instead of adding features inside detectron2,
|
29 |
+
you can implement many features by [extending detectron2](https://detectron2.readthedocs.io/tutorials/extend.html).
|
30 |
+
The [projects/](https://github.com/facebookresearch/detectron2/tree/main/projects/) directory contains many of such examples.
|
31 |
+
|
detectron2/.github/ISSUE_TEMPLATE/unexpected-problems-bugs.md
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
name: "😩 Unexpected behaviors"
|
3 |
+
about: Report unexpected behaviors when using detectron2
|
4 |
+
title: Please read & provide the following
|
5 |
+
|
6 |
+
---
|
7 |
+
|
8 |
+
If you do not know the root cause of the problem, please post according to this template:
|
9 |
+
|
10 |
+
## Instructions To Reproduce the Issue:
|
11 |
+
|
12 |
+
Check https://stackoverflow.com/help/minimal-reproducible-example for how to ask good questions.
|
13 |
+
Simplify the steps to reproduce the issue using suggestions from the above link, and provide them below:
|
14 |
+
|
15 |
+
1. Full runnable code or full changes you made:
|
16 |
+
```
|
17 |
+
If making changes to the project itself, please use output of the following command:
|
18 |
+
git rev-parse HEAD; git diff
|
19 |
+
|
20 |
+
<put code or diff here>
|
21 |
+
```
|
22 |
+
2. What exact command you run:
|
23 |
+
3. __Full logs__ or other relevant observations:
|
24 |
+
```
|
25 |
+
<put logs here>
|
26 |
+
```
|
27 |
+
|
28 |
+
## Expected behavior:
|
29 |
+
|
30 |
+
If there are no obvious crash in "full logs" provided above,
|
31 |
+
please tell us the expected behavior.
|
32 |
+
|
33 |
+
If you expect a model to converge / work better, we do not help with such issues, unless
|
34 |
+
a model fails to reproduce the results in detectron2 model zoo, or proves existence of bugs.
|
35 |
+
|
36 |
+
## Environment:
|
37 |
+
|
38 |
+
Paste the output of the following command:
|
39 |
+
```
|
40 |
+
wget -nc -nv https://github.com/facebookresearch/detectron2/raw/main/detectron2/utils/collect_env.py && python collect_env.py
|
41 |
+
```
|
42 |
+
|
43 |
+
If your issue looks like an installation issue / environment issue,
|
44 |
+
please first check common issues in https://detectron2.readthedocs.io/tutorials/install.html#common-installation-issues
|
detectron2/.github/pull_request_template.md
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Thanks for your contribution!
|
2 |
+
|
3 |
+
If you're sending a large PR (e.g., >100 lines),
|
4 |
+
please open an issue first about the feature / bug, and indicate how you want to contribute.
|
5 |
+
|
6 |
+
We do not always accept features.
|
7 |
+
See https://detectron2.readthedocs.io/notes/contributing.html#pull-requests about how we handle PRs.
|
8 |
+
|
9 |
+
Before submitting a PR, please run `dev/linter.sh` to lint the code.
|
10 |
+
|
detectron2/.github/workflows/check-template.yml
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Check issue template
|
2 |
+
|
3 |
+
on:
|
4 |
+
issues:
|
5 |
+
types: [opened]
|
6 |
+
|
7 |
+
jobs:
|
8 |
+
check-template:
|
9 |
+
runs-on: ubuntu-latest
|
10 |
+
# comment this out when testing with https://github.com/nektos/act
|
11 |
+
if: ${{ github.repository_owner == 'facebookresearch' }}
|
12 |
+
steps:
|
13 |
+
- uses: actions/checkout@v2
|
14 |
+
- uses: actions/github-script@v3
|
15 |
+
with:
|
16 |
+
github-token: ${{secrets.GITHUB_TOKEN}}
|
17 |
+
script: |
|
18 |
+
// Arguments available:
|
19 |
+
// - github: A pre-authenticated octokit/rest.js client
|
20 |
+
// - context: An object containing the context of the workflow run
|
21 |
+
// - core: A reference to the @actions/core package
|
22 |
+
// - io: A reference to the @actions/io package
|
23 |
+
const fs = require('fs');
|
24 |
+
const editDistance = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/levenshtein.js`).getEditDistance
|
25 |
+
issue = await github.issues.get({
|
26 |
+
owner: context.issue.owner,
|
27 |
+
repo: context.issue.repo,
|
28 |
+
issue_number: context.issue.number,
|
29 |
+
});
|
30 |
+
const hasLabel = issue.data.labels.length > 0;
|
31 |
+
if (hasLabel || issue.state === "closed") {
|
32 |
+
// don't require template on them
|
33 |
+
core.debug("Issue " + issue.data.title + " was skipped.");
|
34 |
+
return;
|
35 |
+
}
|
36 |
+
|
37 |
+
sameAsTemplate = function(filename, body) {
|
38 |
+
let tmpl = fs.readFileSync(`.github/ISSUE_TEMPLATE/${filename}`, 'utf8');
|
39 |
+
tmpl = tmpl.toLowerCase().split("---").slice(2).join("").trim();
|
40 |
+
tmpl = tmpl.replace(/(\r\n|\n|\r)/gm, "");
|
41 |
+
let bodyr = body.replace(/(\r\n|\n|\r)/gm, "");
|
42 |
+
let dist = editDistance(tmpl, bodyr);
|
43 |
+
return dist < 8;
|
44 |
+
};
|
45 |
+
|
46 |
+
checkFail = async function(msg) {
|
47 |
+
core.info("Processing '" + issue.data.title + "' with message: " + msg);
|
48 |
+
await github.issues.addLabels({
|
49 |
+
owner: context.issue.owner,
|
50 |
+
repo: context.issue.repo,
|
51 |
+
issue_number: context.issue.number,
|
52 |
+
labels: ["needs-more-info"],
|
53 |
+
});
|
54 |
+
await github.issues.createComment({
|
55 |
+
owner: context.issue.owner,
|
56 |
+
repo: context.issue.repo,
|
57 |
+
issue_number: context.issue.number,
|
58 |
+
body: msg,
|
59 |
+
});
|
60 |
+
};
|
61 |
+
|
62 |
+
const body = issue.data.body.toLowerCase().trim();
|
63 |
+
|
64 |
+
if (sameAsTemplate("bugs.md", body) || sameAsTemplate("unexpected-problems-bugs.md", body)) {
|
65 |
+
await checkFail(`
|
66 |
+
We found that not enough information is provided about this issue.
|
67 |
+
Please provide details following the [issue template](https://github.com/facebookresearch/detectron2/issues/new/choose).`)
|
68 |
+
return;
|
69 |
+
}
|
70 |
+
|
71 |
+
const hasInstructions = body.indexOf("reproduce") != -1;
|
72 |
+
const hasEnvironment = (body.indexOf("environment") != -1) || (body.indexOf("colab") != -1) || (body.indexOf("docker") != -1);
|
73 |
+
if (hasInstructions && hasEnvironment) {
|
74 |
+
core.debug("Issue " + issue.data.title + " follows template.");
|
75 |
+
return;
|
76 |
+
}
|
77 |
+
|
78 |
+
let message = "You've chosen to report an unexpected problem or bug. Unless you already know the root cause of it, please include details about it by filling the [issue template](https://github.com/facebookresearch/detectron2/issues/new/choose).\n";
|
79 |
+
message += "The following information is missing: ";
|
80 |
+
if (!hasInstructions) {
|
81 |
+
message += "\"Instructions To Reproduce the Issue and __Full__ Logs\"; ";
|
82 |
+
}
|
83 |
+
if (!hasEnvironment) {
|
84 |
+
message += "\"Your Environment\"; ";
|
85 |
+
}
|
86 |
+
await checkFail(message);
|
detectron2/.github/workflows/levenshtein.js
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
Copyright (c) 2011 Andrei Mackenzie
|
3 |
+
|
4 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5 |
+
|
6 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
7 |
+
|
8 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
9 |
+
*/
|
10 |
+
|
11 |
+
// Compute the edit distance between the two given strings
|
12 |
+
exports.getEditDistance = function(a, b){
|
13 |
+
if(a.length == 0) return b.length;
|
14 |
+
if(b.length == 0) return a.length;
|
15 |
+
|
16 |
+
var matrix = [];
|
17 |
+
|
18 |
+
// increment along the first column of each row
|
19 |
+
var i;
|
20 |
+
for(i = 0; i <= b.length; i++){
|
21 |
+
matrix[i] = [i];
|
22 |
+
}
|
23 |
+
|
24 |
+
// increment each column in the first row
|
25 |
+
var j;
|
26 |
+
for(j = 0; j <= a.length; j++){
|
27 |
+
matrix[0][j] = j;
|
28 |
+
}
|
29 |
+
|
30 |
+
// Fill in the rest of the matrix
|
31 |
+
for(i = 1; i <= b.length; i++){
|
32 |
+
for(j = 1; j <= a.length; j++){
|
33 |
+
if(b.charAt(i-1) == a.charAt(j-1)){
|
34 |
+
matrix[i][j] = matrix[i-1][j-1];
|
35 |
+
} else {
|
36 |
+
matrix[i][j] = Math.min(matrix[i-1][j-1] + 1, // substitution
|
37 |
+
Math.min(matrix[i][j-1] + 1, // insertion
|
38 |
+
matrix[i-1][j] + 1)); // deletion
|
39 |
+
}
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
return matrix[b.length][a.length];
|
44 |
+
};
|
detectron2/.github/workflows/needs-reply.yml
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Close/Lock issues after inactivity
|
2 |
+
|
3 |
+
on:
|
4 |
+
schedule:
|
5 |
+
- cron: "0 0 * * *"
|
6 |
+
|
7 |
+
jobs:
|
8 |
+
close-issues-needs-more-info:
|
9 |
+
runs-on: ubuntu-latest
|
10 |
+
if: ${{ github.repository_owner == 'facebookresearch' }}
|
11 |
+
steps:
|
12 |
+
- name: Close old issues that need reply
|
13 |
+
uses: actions/github-script@v3
|
14 |
+
with:
|
15 |
+
github-token: ${{secrets.GITHUB_TOKEN}}
|
16 |
+
# Modified from https://github.com/dwieeb/needs-reply
|
17 |
+
script: |
|
18 |
+
// Arguments available:
|
19 |
+
// - github: A pre-authenticated octokit/rest.js client
|
20 |
+
// - context: An object containing the context of the workflow run
|
21 |
+
// - core: A reference to the @actions/core package
|
22 |
+
// - io: A reference to the @actions/io package
|
23 |
+
const kLabelToCheck = "needs-more-info";
|
24 |
+
const kInvalidLabel = "invalid/unrelated";
|
25 |
+
const kDaysBeforeClose = 7;
|
26 |
+
const kMessage = "Requested information was not provided in 7 days, so we're closing this issue.\n\nPlease open new issue if information becomes available. Otherwise, use [github discussions](https://github.com/facebookresearch/detectron2/discussions) for free-form discussions."
|
27 |
+
|
28 |
+
issues = await github.issues.listForRepo({
|
29 |
+
owner: context.repo.owner,
|
30 |
+
repo: context.repo.repo,
|
31 |
+
state: 'open',
|
32 |
+
labels: kLabelToCheck,
|
33 |
+
sort: 'updated',
|
34 |
+
direction: 'asc',
|
35 |
+
per_page: 30,
|
36 |
+
page: 1,
|
37 |
+
});
|
38 |
+
issues = issues.data;
|
39 |
+
if (issues.length === 0) {
|
40 |
+
core.info('No more issues found to process. Exiting.');
|
41 |
+
return;
|
42 |
+
}
|
43 |
+
for (const issue of issues) {
|
44 |
+
if (!!issue.pull_request)
|
45 |
+
continue;
|
46 |
+
core.info(`Processing issue #${issue.number}`);
|
47 |
+
|
48 |
+
let updatedAt = new Date(issue.updated_at).getTime();
|
49 |
+
const numComments = issue.comments;
|
50 |
+
const comments = await github.issues.listComments({
|
51 |
+
owner: context.repo.owner,
|
52 |
+
repo: context.repo.repo,
|
53 |
+
issue_number: issue.number,
|
54 |
+
per_page: 30,
|
55 |
+
page: Math.floor((numComments - 1) / 30) + 1, // the last page
|
56 |
+
});
|
57 |
+
const lastComments = comments.data
|
58 |
+
.map(l => new Date(l.created_at).getTime())
|
59 |
+
.sort();
|
60 |
+
if (lastComments.length > 0) {
|
61 |
+
updatedAt = lastComments[lastComments.length - 1];
|
62 |
+
}
|
63 |
+
|
64 |
+
const now = new Date().getTime();
|
65 |
+
const daysSinceUpdated = (now - updatedAt) / 1000 / 60 / 60 / 24;
|
66 |
+
|
67 |
+
if (daysSinceUpdated < kDaysBeforeClose) {
|
68 |
+
core.info(`Skipping #${issue.number} because it has been updated in the last ${daysSinceUpdated} days`);
|
69 |
+
continue;
|
70 |
+
}
|
71 |
+
core.info(`Closing #${issue.number} because it has not been updated in the last ${daysSinceUpdated} days`);
|
72 |
+
await github.issues.createComment({
|
73 |
+
owner: context.repo.owner,
|
74 |
+
repo: context.repo.repo,
|
75 |
+
issue_number: issue.number,
|
76 |
+
body: kMessage,
|
77 |
+
});
|
78 |
+
const newLabels = numComments <= 2 ? [kInvalidLabel, kLabelToCheck] : issue.labels;
|
79 |
+
await github.issues.update({
|
80 |
+
owner: context.repo.owner,
|
81 |
+
repo: context.repo.repo,
|
82 |
+
issue_number: issue.number,
|
83 |
+
labels: newLabels,
|
84 |
+
state: 'closed',
|
85 |
+
});
|
86 |
+
}
|
87 |
+
|
88 |
+
lock-issues-after-closed:
|
89 |
+
runs-on: ubuntu-latest
|
90 |
+
if: ${{ github.repository_owner == 'facebookresearch' }}
|
91 |
+
steps:
|
92 |
+
- name: Lock closed issues that have no activity for a while
|
93 |
+
uses: dessant/lock-threads@v2
|
94 |
+
with:
|
95 |
+
github-token: ${{ github.token }}
|
96 |
+
issue-lock-inactive-days: '300'
|
97 |
+
process-only: 'issues'
|
98 |
+
issue-exclude-labels: 'enhancement,bug,documentation'
|
detectron2/.github/workflows/remove-needs-reply.yml
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Remove needs-more-info label
|
2 |
+
|
3 |
+
on:
|
4 |
+
issue_comment:
|
5 |
+
types: [created]
|
6 |
+
issues:
|
7 |
+
types: [edited]
|
8 |
+
|
9 |
+
jobs:
|
10 |
+
remove-needs-more-info-label:
|
11 |
+
runs-on: ubuntu-latest
|
12 |
+
# 1. issue_comment events could include PR comment, filter them out
|
13 |
+
# 2. Only trigger action if event was produced by the original author
|
14 |
+
if: ${{ !github.event.issue.pull_request && github.event.sender.login == github.event.issue.user.login }}
|
15 |
+
steps:
|
16 |
+
- name: Remove needs-more-info label
|
17 |
+
uses: octokit/request-action@v2.x
|
18 |
+
continue-on-error: true
|
19 |
+
with:
|
20 |
+
route: DELETE /repos/:repository/issues/:issue/labels/:label
|
21 |
+
repository: ${{ github.repository }}
|
22 |
+
issue: ${{ github.event.issue.number }}
|
23 |
+
label: needs-more-info
|
24 |
+
env:
|
25 |
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
detectron2/.github/workflows/workflow.yml
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: CI
|
2 |
+
on: [push, pull_request]
|
3 |
+
|
4 |
+
# Run linter with github actions for quick feedbacks.
|
5 |
+
# Run macos tests with github actions. Linux (CPU & GPU) tests currently runs on CircleCI
|
6 |
+
jobs:
|
7 |
+
linter:
|
8 |
+
runs-on: ubuntu-latest
|
9 |
+
# run on PRs, or commits to facebookresearch (not internal)
|
10 |
+
if: ${{ github.repository_owner == 'facebookresearch' || github.event_name == 'pull_request' }}
|
11 |
+
steps:
|
12 |
+
- uses: actions/checkout@v2
|
13 |
+
- name: Set up Python 3.9
|
14 |
+
uses: actions/setup-python@v2
|
15 |
+
with:
|
16 |
+
python-version: 3.9
|
17 |
+
- name: Install dependencies
|
18 |
+
# flake8-bugbear flake8-comprehensions are useful but not available internally
|
19 |
+
run: |
|
20 |
+
python -m pip install --upgrade pip
|
21 |
+
python -m pip install flake8==3.8.1 isort==4.3.21
|
22 |
+
python -m pip install black==22.3.0
|
23 |
+
flake8 --version
|
24 |
+
- name: Lint
|
25 |
+
run: |
|
26 |
+
echo "Running isort"
|
27 |
+
isort -c -sp .
|
28 |
+
echo "Running black"
|
29 |
+
black -l 100 --check .
|
30 |
+
echo "Running flake8"
|
31 |
+
flake8 .
|
32 |
+
|
33 |
+
macos_tests:
|
34 |
+
runs-on: macos-latest
|
35 |
+
# run on PRs, or commits to facebookresearch (not internal)
|
36 |
+
if: ${{ github.repository_owner == 'facebookresearch' || github.event_name == 'pull_request' }}
|
37 |
+
strategy:
|
38 |
+
fail-fast: false
|
39 |
+
matrix:
|
40 |
+
torch: ["1.8", "1.9", "1.10"]
|
41 |
+
include:
|
42 |
+
- torch: "1.8"
|
43 |
+
torchvision: 0.9
|
44 |
+
- torch: "1.9"
|
45 |
+
torchvision: "0.10"
|
46 |
+
- torch: "1.10"
|
47 |
+
torchvision: "0.11.1"
|
48 |
+
env:
|
49 |
+
# point datasets to ~/.torch so it's cached by CI
|
50 |
+
DETECTRON2_DATASETS: ~/.torch/datasets
|
51 |
+
steps:
|
52 |
+
- name: Checkout
|
53 |
+
uses: actions/checkout@v2
|
54 |
+
- name: Set up Python 3.8
|
55 |
+
uses: actions/setup-python@v2
|
56 |
+
with:
|
57 |
+
python-version: 3.8
|
58 |
+
- name: Cache dependencies
|
59 |
+
uses: actions/cache@v2
|
60 |
+
with:
|
61 |
+
path: |
|
62 |
+
${{ env.pythonLocation }}/lib/python3.8/site-packages
|
63 |
+
~/.torch
|
64 |
+
key: ${{ runner.os }}-torch${{ matrix.torch }}-${{ hashFiles('setup.py') }}-20220119
|
65 |
+
|
66 |
+
- name: Install dependencies
|
67 |
+
run: |
|
68 |
+
python -m pip install -U pip
|
69 |
+
python -m pip install ninja opencv-python-headless onnx pytest-xdist
|
70 |
+
python -m pip install torch==${{matrix.torch}} torchvision==${{matrix.torchvision}} -f https://download.pytorch.org/whl/torch_stable.html
|
71 |
+
# install from github to get latest; install iopath first since fvcore depends on it
|
72 |
+
python -m pip install -U 'git+https://github.com/facebookresearch/iopath'
|
73 |
+
python -m pip install -U 'git+https://github.com/facebookresearch/fvcore'
|
74 |
+
|
75 |
+
- name: Build and install
|
76 |
+
run: |
|
77 |
+
CC=clang CXX=clang++ python -m pip install -e .[all]
|
78 |
+
python -m detectron2.utils.collect_env
|
79 |
+
./datasets/prepare_for_tests.sh
|
80 |
+
- name: Run unittests
|
81 |
+
run: python -m pytest -n 4 --durations=15 -sv tests/
|
detectron2/.gitignore
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# output dir
|
2 |
+
output
|
3 |
+
instant_test_output
|
4 |
+
inference_test_output
|
5 |
+
|
6 |
+
|
7 |
+
*.png
|
8 |
+
*.json
|
9 |
+
*.diff
|
10 |
+
*.jpg
|
11 |
+
!/projects/DensePose/doc/images/*.jpg
|
12 |
+
|
13 |
+
# compilation and distribution
|
14 |
+
__pycache__
|
15 |
+
_ext
|
16 |
+
*.pyc
|
17 |
+
*.pyd
|
18 |
+
*.so
|
19 |
+
*.dll
|
20 |
+
*.egg-info/
|
21 |
+
build/
|
22 |
+
dist/
|
23 |
+
wheels/
|
24 |
+
|
25 |
+
# pytorch/python/numpy formats
|
26 |
+
*.pth
|
27 |
+
*.pkl
|
28 |
+
*.npy
|
29 |
+
*.ts
|
30 |
+
model_ts*.txt
|
31 |
+
|
32 |
+
# ipython/jupyter notebooks
|
33 |
+
*.ipynb
|
34 |
+
**/.ipynb_checkpoints/
|
35 |
+
|
36 |
+
# Editor temporaries
|
37 |
+
*.swn
|
38 |
+
*.swo
|
39 |
+
*.swp
|
40 |
+
*~
|
41 |
+
|
42 |
+
# editor settings
|
43 |
+
.idea
|
44 |
+
.vscode
|
45 |
+
_darcs
|
46 |
+
|
47 |
+
# project dirs
|
48 |
+
/detectron2/model_zoo/configs
|
49 |
+
/datasets/*
|
50 |
+
!/datasets/*.*
|
51 |
+
/projects/*/datasets
|
52 |
+
/models
|
53 |
+
/snippet
|
detectron2/GETTING_STARTED.md
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## Getting Started with Detectron2
|
2 |
+
|
3 |
+
This document provides a brief intro of the usage of builtin command-line tools in detectron2.
|
4 |
+
|
5 |
+
For a tutorial that involves actual coding with the API,
|
6 |
+
see our [Colab Notebook](https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5)
|
7 |
+
which covers how to run inference with an
|
8 |
+
existing model, and how to train a builtin model on a custom dataset.
|
9 |
+
|
10 |
+
|
11 |
+
### Inference Demo with Pre-trained Models
|
12 |
+
|
13 |
+
1. Pick a model and its config file from
|
14 |
+
[model zoo](MODEL_ZOO.md),
|
15 |
+
for example, `mask_rcnn_R_50_FPN_3x.yaml`.
|
16 |
+
2. We provide `demo.py` that is able to demo builtin configs. Run it with:
|
17 |
+
```
|
18 |
+
cd demo/
|
19 |
+
python demo.py --config-file ../configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml \
|
20 |
+
--input input1.jpg input2.jpg \
|
21 |
+
[--other-options]
|
22 |
+
--opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl
|
23 |
+
```
|
24 |
+
The configs are made for training, therefore we need to specify `MODEL.WEIGHTS` to a model from model zoo for evaluation.
|
25 |
+
This command will run the inference and show visualizations in an OpenCV window.
|
26 |
+
|
27 |
+
For details of the command line arguments, see `demo.py -h` or look at its source code
|
28 |
+
to understand its behavior. Some common arguments are:
|
29 |
+
* To run __on your webcam__, replace `--input files` with `--webcam`.
|
30 |
+
* To run __on a video__, replace `--input files` with `--video-input video.mp4`.
|
31 |
+
* To run __on cpu__, add `MODEL.DEVICE cpu` after `--opts`.
|
32 |
+
* To save outputs to a directory (for images) or a file (for webcam or video), use `--output`.
|
33 |
+
|
34 |
+
|
35 |
+
### Training & Evaluation in Command Line
|
36 |
+
|
37 |
+
We provide two scripts in "tools/plain_train_net.py" and "tools/train_net.py",
|
38 |
+
that are made to train all the configs provided in detectron2. You may want to
|
39 |
+
use it as a reference to write your own training script.
|
40 |
+
|
41 |
+
Compared to "train_net.py", "plain_train_net.py" supports fewer default
|
42 |
+
features. It also includes fewer abstraction, therefore is easier to add custom
|
43 |
+
logic.
|
44 |
+
|
45 |
+
To train a model with "train_net.py", first
|
46 |
+
setup the corresponding datasets following
|
47 |
+
[datasets/README.md](./datasets/README.md),
|
48 |
+
then run:
|
49 |
+
```
|
50 |
+
cd tools/
|
51 |
+
./train_net.py --num-gpus 8 \
|
52 |
+
--config-file ../configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml
|
53 |
+
```
|
54 |
+
|
55 |
+
The configs are made for 8-GPU training.
|
56 |
+
To train on 1 GPU, you may need to [change some parameters](https://arxiv.org/abs/1706.02677), e.g.:
|
57 |
+
```
|
58 |
+
./train_net.py \
|
59 |
+
--config-file ../configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml \
|
60 |
+
--num-gpus 1 SOLVER.IMS_PER_BATCH 2 SOLVER.BASE_LR 0.0025
|
61 |
+
```
|
62 |
+
|
63 |
+
To evaluate a model's performance, use
|
64 |
+
```
|
65 |
+
./train_net.py \
|
66 |
+
--config-file ../configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml \
|
67 |
+
--eval-only MODEL.WEIGHTS /path/to/checkpoint_file
|
68 |
+
```
|
69 |
+
For more options, see `./train_net.py -h`.
|
70 |
+
|
71 |
+
### Use Detectron2 APIs in Your Code
|
72 |
+
|
73 |
+
See our [Colab Notebook](https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5)
|
74 |
+
to learn how to use detectron2 APIs to:
|
75 |
+
1. run inference with an existing model
|
76 |
+
2. train a builtin model on a custom dataset
|
77 |
+
|
78 |
+
See [detectron2/projects](https://github.com/facebookresearch/detectron2/tree/main/projects)
|
79 |
+
for more ways to build your project on detectron2.
|
detectron2/INSTALL.md
ADDED
@@ -0,0 +1,261 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## Installation
|
2 |
+
|
3 |
+
### Requirements
|
4 |
+
- Linux or macOS with Python ≥ 3.7
|
5 |
+
- PyTorch ≥ 1.8 and [torchvision](https://github.com/pytorch/vision/) that matches the PyTorch installation.
|
6 |
+
Install them together at [pytorch.org](https://pytorch.org) to make sure of this
|
7 |
+
- OpenCV is optional but needed by demo and visualization
|
8 |
+
|
9 |
+
|
10 |
+
### Build Detectron2 from Source
|
11 |
+
|
12 |
+
gcc & g++ ≥ 5.4 are required. [ninja](https://ninja-build.org/) is optional but recommended for faster build.
|
13 |
+
After having them, run:
|
14 |
+
```
|
15 |
+
python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
|
16 |
+
# (add --user if you don't have permission)
|
17 |
+
|
18 |
+
# Or, to install it from a local clone:
|
19 |
+
git clone https://github.com/facebookresearch/detectron2.git
|
20 |
+
python -m pip install -e detectron2
|
21 |
+
|
22 |
+
# On macOS, you may need to prepend the above commands with a few environment variables:
|
23 |
+
CC=clang CXX=clang++ ARCHFLAGS="-arch x86_64" python -m pip install ...
|
24 |
+
```
|
25 |
+
|
26 |
+
To __rebuild__ detectron2 that's built from a local clone, use `rm -rf build/ **/*.so` to clean the
|
27 |
+
old build first. You often need to rebuild detectron2 after reinstalling PyTorch.
|
28 |
+
|
29 |
+
### Install Pre-Built Detectron2 (Linux only)
|
30 |
+
|
31 |
+
Choose from this table to install [v0.6 (Oct 2021)](https://github.com/facebookresearch/detectron2/releases):
|
32 |
+
|
33 |
+
<table class="docutils"><tbody><th width="80"> CUDA </th><th valign="bottom" align="left" width="100">torch 1.10</th><th valign="bottom" align="left" width="100">torch 1.9</th><th valign="bottom" align="left" width="100">torch 1.8</th> <tr><td align="left">11.3</td><td align="left"><details><summary> install </summary><pre><code>python -m pip install detectron2 -f \
|
34 |
+
https://dl.fbaipublicfiles.com/detectron2/wheels/cu113/torch1.10/index.html
|
35 |
+
</code></pre> </details> </td> <td align="left"> </td> <td align="left"> </td> </tr> <tr><td align="left">11.1</td><td align="left"><details><summary> install </summary><pre><code>python -m pip install detectron2 -f \
|
36 |
+
https://dl.fbaipublicfiles.com/detectron2/wheels/cu111/torch1.10/index.html
|
37 |
+
</code></pre> </details> </td> <td align="left"><details><summary> install </summary><pre><code>python -m pip install detectron2 -f \
|
38 |
+
https://dl.fbaipublicfiles.com/detectron2/wheels/cu111/torch1.9/index.html
|
39 |
+
</code></pre> </details> </td> <td align="left"><details><summary> install </summary><pre><code>python -m pip install detectron2 -f \
|
40 |
+
https://dl.fbaipublicfiles.com/detectron2/wheels/cu111/torch1.8/index.html
|
41 |
+
</code></pre> </details> </td> </tr> <tr><td align="left">10.2</td><td align="left"><details><summary> install </summary><pre><code>python -m pip install detectron2 -f \
|
42 |
+
https://dl.fbaipublicfiles.com/detectron2/wheels/cu102/torch1.10/index.html
|
43 |
+
</code></pre> </details> </td> <td align="left"><details><summary> install </summary><pre><code>python -m pip install detectron2 -f \
|
44 |
+
https://dl.fbaipublicfiles.com/detectron2/wheels/cu102/torch1.9/index.html
|
45 |
+
</code></pre> </details> </td> <td align="left"><details><summary> install </summary><pre><code>python -m pip install detectron2 -f \
|
46 |
+
https://dl.fbaipublicfiles.com/detectron2/wheels/cu102/torch1.8/index.html
|
47 |
+
</code></pre> </details> </td> </tr> <tr><td align="left">10.1</td><td align="left"> </td> <td align="left"> </td> <td align="left"><details><summary> install </summary><pre><code>python -m pip install detectron2 -f \
|
48 |
+
https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/torch1.8/index.html
|
49 |
+
</code></pre> </details> </td> </tr> <tr><td align="left">cpu</td><td align="left"><details><summary> install </summary><pre><code>python -m pip install detectron2 -f \
|
50 |
+
https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch1.10/index.html
|
51 |
+
</code></pre> </details> </td> <td align="left"><details><summary> install </summary><pre><code>python -m pip install detectron2 -f \
|
52 |
+
https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch1.9/index.html
|
53 |
+
</code></pre> </details> </td> <td align="left"><details><summary> install </summary><pre><code>python -m pip install detectron2 -f \
|
54 |
+
https://dl.fbaipublicfiles.com/detectron2/wheels/cpu/torch1.8/index.html
|
55 |
+
</code></pre> </details> </td> </tr></tbody></table>
|
56 |
+
|
57 |
+
Note that:
|
58 |
+
1. The pre-built packages have to be used with corresponding version of CUDA and the official package of PyTorch.
|
59 |
+
Otherwise, please build detectron2 from source.
|
60 |
+
2. New packages are released every few months. Therefore, packages may not contain latest features in the main
|
61 |
+
branch and may not be compatible with the main branch of a research project that uses detectron2
|
62 |
+
(e.g. those in [projects](projects)).
|
63 |
+
|
64 |
+
### Common Installation Issues
|
65 |
+
|
66 |
+
Click each issue for its solutions:
|
67 |
+
|
68 |
+
<details>
|
69 |
+
<summary>
|
70 |
+
Undefined symbols that looks like "TH..","at::Tensor...","torch..."
|
71 |
+
</summary>
|
72 |
+
<br/>
|
73 |
+
|
74 |
+
This usually happens when detectron2 or torchvision is not
|
75 |
+
compiled with the version of PyTorch you're running.
|
76 |
+
|
77 |
+
If the error comes from a pre-built torchvision, uninstall torchvision and pytorch and reinstall them
|
78 |
+
following [pytorch.org](http://pytorch.org). So the versions will match.
|
79 |
+
|
80 |
+
If the error comes from a pre-built detectron2, check [release notes](https://github.com/facebookresearch/detectron2/releases),
|
81 |
+
uninstall and reinstall the correct pre-built detectron2 that matches pytorch version.
|
82 |
+
|
83 |
+
If the error comes from detectron2 or torchvision that you built manually from source,
|
84 |
+
remove files you built (`build/`, `**/*.so`) and rebuild it so it can pick up the version of pytorch currently in your environment.
|
85 |
+
|
86 |
+
If the above instructions do not resolve this problem, please provide an environment (e.g. a dockerfile) that can reproduce the issue.
|
87 |
+
</details>
|
88 |
+
|
89 |
+
<details>
|
90 |
+
<summary>
|
91 |
+
Missing torch dynamic libraries, OR segmentation fault immediately when using detectron2.
|
92 |
+
</summary>
|
93 |
+
This usually happens when detectron2 or torchvision is not
|
94 |
+
compiled with the version of PyTorch you're running. See the previous common issue for the solution.
|
95 |
+
</details>
|
96 |
+
|
97 |
+
<details>
|
98 |
+
<summary>
|
99 |
+
Undefined C++ symbols (e.g. "GLIBCXX..") or C++ symbols not found.
|
100 |
+
</summary>
|
101 |
+
<br/>
|
102 |
+
Usually it's because the library is compiled with a newer C++ compiler but run with an old C++ runtime.
|
103 |
+
|
104 |
+
This often happens with old anaconda.
|
105 |
+
It may help to run `conda update libgcc` to upgrade its runtime.
|
106 |
+
|
107 |
+
The fundamental solution is to avoid the mismatch, either by compiling using older version of C++
|
108 |
+
compiler, or run the code with proper C++ runtime.
|
109 |
+
To run the code with a specific C++ runtime, you can use environment variable `LD_PRELOAD=/path/to/libstdc++.so`.
|
110 |
+
|
111 |
+
</details>
|
112 |
+
|
113 |
+
<details>
|
114 |
+
<summary>
|
115 |
+
"nvcc not found" or "Not compiled with GPU support" or "Detectron2 CUDA Compiler: not available".
|
116 |
+
</summary>
|
117 |
+
<br/>
|
118 |
+
CUDA is not found when building detectron2.
|
119 |
+
You should make sure
|
120 |
+
|
121 |
+
```
|
122 |
+
python -c 'import torch; from torch.utils.cpp_extension import CUDA_HOME; print(torch.cuda.is_available(), CUDA_HOME)'
|
123 |
+
```
|
124 |
+
|
125 |
+
print `(True, a directory with cuda)` at the time you build detectron2.
|
126 |
+
|
127 |
+
Most models can run inference (but not training) without GPU support. To use CPUs, set `MODEL.DEVICE='cpu'` in the config.
|
128 |
+
</details>
|
129 |
+
|
130 |
+
<details>
|
131 |
+
<summary>
|
132 |
+
"invalid device function" or "no kernel image is available for execution".
|
133 |
+
</summary>
|
134 |
+
<br/>
|
135 |
+
Two possibilities:
|
136 |
+
|
137 |
+
* You build detectron2 with one version of CUDA but run it with a different version.
|
138 |
+
|
139 |
+
To check whether it is the case,
|
140 |
+
use `python -m detectron2.utils.collect_env` to find out inconsistent CUDA versions.
|
141 |
+
In the output of this command, you should expect "Detectron2 CUDA Compiler", "CUDA_HOME", "PyTorch built with - CUDA"
|
142 |
+
to contain cuda libraries of the same version.
|
143 |
+
|
144 |
+
When they are inconsistent,
|
145 |
+
you need to either install a different build of PyTorch (or build by yourself)
|
146 |
+
to match your local CUDA installation, or install a different version of CUDA to match PyTorch.
|
147 |
+
|
148 |
+
* PyTorch/torchvision/Detectron2 is not built for the correct GPU SM architecture (aka. compute capability).
|
149 |
+
|
150 |
+
The architecture included by PyTorch/detectron2/torchvision is available in the "architecture flags" in
|
151 |
+
`python -m detectron2.utils.collect_env`. It must include
|
152 |
+
the architecture of your GPU, which can be found at [developer.nvidia.com/cuda-gpus](https://developer.nvidia.com/cuda-gpus).
|
153 |
+
|
154 |
+
If you're using pre-built PyTorch/detectron2/torchvision, they have included support for most popular GPUs already.
|
155 |
+
If not supported, you need to build them from source.
|
156 |
+
|
157 |
+
When building detectron2/torchvision from source, they detect the GPU device and build for only the device.
|
158 |
+
This means the compiled code may not work on a different GPU device.
|
159 |
+
To recompile them for the correct architecture, remove all installed/compiled files,
|
160 |
+
and rebuild them with the `TORCH_CUDA_ARCH_LIST` environment variable set properly.
|
161 |
+
For example, `export TORCH_CUDA_ARCH_LIST="6.0;7.0"` makes it compile for both P100s and V100s.
|
162 |
+
</details>
|
163 |
+
|
164 |
+
<details>
|
165 |
+
<summary>
|
166 |
+
Undefined CUDA symbols; Cannot open libcudart.so
|
167 |
+
</summary>
|
168 |
+
<br/>
|
169 |
+
The version of NVCC you use to build detectron2 or torchvision does
|
170 |
+
not match the version of CUDA you are running with.
|
171 |
+
This often happens when using anaconda's CUDA runtime.
|
172 |
+
|
173 |
+
Use `python -m detectron2.utils.collect_env` to find out inconsistent CUDA versions.
|
174 |
+
In the output of this command, you should expect "Detectron2 CUDA Compiler", "CUDA_HOME", "PyTorch built with - CUDA"
|
175 |
+
to contain cuda libraries of the same version.
|
176 |
+
|
177 |
+
When they are inconsistent,
|
178 |
+
you need to either install a different build of PyTorch (or build by yourself)
|
179 |
+
to match your local CUDA installation, or install a different version of CUDA to match PyTorch.
|
180 |
+
</details>
|
181 |
+
|
182 |
+
|
183 |
+
<details>
|
184 |
+
<summary>
|
185 |
+
C++ compilation errors from NVCC / NVRTC, or "Unsupported gpu architecture"
|
186 |
+
</summary>
|
187 |
+
<br/>
|
188 |
+
A few possibilities:
|
189 |
+
|
190 |
+
1. Local CUDA/NVCC version has to match the CUDA version of your PyTorch. Both can be found in `python collect_env.py`
|
191 |
+
(download from [here](./detectron2/utils/collect_env.py)).
|
192 |
+
When they are inconsistent, you need to either install a different build of PyTorch (or build by yourself)
|
193 |
+
to match your local CUDA installation, or install a different version of CUDA to match PyTorch.
|
194 |
+
|
195 |
+
2. Local CUDA/NVCC version shall support the SM architecture (a.k.a. compute capability) of your GPU.
|
196 |
+
The capability of your GPU can be found at [developer.nvidia.com/cuda-gpus](https://developer.nvidia.com/cuda-gpus).
|
197 |
+
The capability supported by NVCC is listed at [here](https://gist.github.com/ax3l/9489132).
|
198 |
+
If your NVCC version is too old, this can be workaround by setting environment variable
|
199 |
+
`TORCH_CUDA_ARCH_LIST` to a lower, supported capability.
|
200 |
+
|
201 |
+
3. The combination of NVCC and GCC you use is incompatible. You need to change one of their versions.
|
202 |
+
See [here](https://gist.github.com/ax3l/9489132) for some valid combinations.
|
203 |
+
Notably, CUDA<=10.1.105 doesn't support GCC>7.3.
|
204 |
+
|
205 |
+
The CUDA/GCC version used by PyTorch can be found by `print(torch.__config__.show())`.
|
206 |
+
|
207 |
+
</details>
|
208 |
+
|
209 |
+
|
210 |
+
<details>
|
211 |
+
<summary>
|
212 |
+
"ImportError: cannot import name '_C'".
|
213 |
+
</summary>
|
214 |
+
<br/>
|
215 |
+
Please build and install detectron2 following the instructions above.
|
216 |
+
|
217 |
+
Or, if you are running code from detectron2's root directory, `cd` to a different one.
|
218 |
+
Otherwise you may not import the code that you installed.
|
219 |
+
</details>
|
220 |
+
|
221 |
+
|
222 |
+
<details>
|
223 |
+
<summary>
|
224 |
+
Any issue on windows.
|
225 |
+
</summary>
|
226 |
+
<br/>
|
227 |
+
|
228 |
+
Detectron2 is continuously built on windows with [CircleCI](https://app.circleci.com/pipelines/github/facebookresearch/detectron2?branch=main).
|
229 |
+
However we do not provide official support for it.
|
230 |
+
PRs that improves code compatibility on windows are welcome.
|
231 |
+
</details>
|
232 |
+
|
233 |
+
<details>
|
234 |
+
<summary>
|
235 |
+
ONNX conversion segfault after some "TraceWarning".
|
236 |
+
</summary>
|
237 |
+
<br/>
|
238 |
+
The ONNX package is compiled with a too old compiler.
|
239 |
+
|
240 |
+
Please build and install ONNX from its source code using a compiler
|
241 |
+
whose version is closer to what's used by PyTorch (available in `torch.__config__.show()`).
|
242 |
+
</details>
|
243 |
+
|
244 |
+
|
245 |
+
<details>
|
246 |
+
<summary>
|
247 |
+
"library not found for -lstdc++" on older version of MacOS
|
248 |
+
</summary>
|
249 |
+
<br/>
|
250 |
+
|
251 |
+
See [this stackoverflow answer](https://stackoverflow.com/questions/56083725/macos-build-issues-lstdc-not-found-while-building-python-package).
|
252 |
+
|
253 |
+
</details>
|
254 |
+
|
255 |
+
|
256 |
+
### Installation inside specific environments:
|
257 |
+
|
258 |
+
* __Colab__: see our [Colab Tutorial](https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5)
|
259 |
+
which has step-by-step instructions.
|
260 |
+
|
261 |
+
* __Docker__: The official [Dockerfile](docker) installs detectron2 with a few simple commands.
|
detectron2/LICENSE
ADDED
@@ -0,0 +1,202 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Apache License
|
2 |
+
Version 2.0, January 2004
|
3 |
+
http://www.apache.org/licenses/
|
4 |
+
|
5 |
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
6 |
+
|
7 |
+
1. Definitions.
|
8 |
+
|
9 |
+
"License" shall mean the terms and conditions for use, reproduction,
|
10 |
+
and distribution as defined by Sections 1 through 9 of this document.
|
11 |
+
|
12 |
+
"Licensor" shall mean the copyright owner or entity authorized by
|
13 |
+
the copyright owner that is granting the License.
|
14 |
+
|
15 |
+
"Legal Entity" shall mean the union of the acting entity and all
|
16 |
+
other entities that control, are controlled by, or are under common
|
17 |
+
control with that entity. For the purposes of this definition,
|
18 |
+
"control" means (i) the power, direct or indirect, to cause the
|
19 |
+
direction or management of such entity, whether by contract or
|
20 |
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
21 |
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
22 |
+
|
23 |
+
"You" (or "Your") shall mean an individual or Legal Entity
|
24 |
+
exercising permissions granted by this License.
|
25 |
+
|
26 |
+
"Source" form shall mean the preferred form for making modifications,
|
27 |
+
including but not limited to software source code, documentation
|
28 |
+
source, and configuration files.
|
29 |
+
|
30 |
+
"Object" form shall mean any form resulting from mechanical
|
31 |
+
transformation or translation of a Source form, including but
|
32 |
+
not limited to compiled object code, generated documentation,
|
33 |
+
and conversions to other media types.
|
34 |
+
|
35 |
+
"Work" shall mean the work of authorship, whether in Source or
|
36 |
+
Object form, made available under the License, as indicated by a
|
37 |
+
copyright notice that is included in or attached to the work
|
38 |
+
(an example is provided in the Appendix below).
|
39 |
+
|
40 |
+
"Derivative Works" shall mean any work, whether in Source or Object
|
41 |
+
form, that is based on (or derived from) the Work and for which the
|
42 |
+
editorial revisions, annotations, elaborations, or other modifications
|
43 |
+
represent, as a whole, an original work of authorship. For the purposes
|
44 |
+
of this License, Derivative Works shall not include works that remain
|
45 |
+
separable from, or merely link (or bind by name) to the interfaces of,
|
46 |
+
the Work and Derivative Works thereof.
|
47 |
+
|
48 |
+
"Contribution" shall mean any work of authorship, including
|
49 |
+
the original version of the Work and any modifications or additions
|
50 |
+
to that Work or Derivative Works thereof, that is intentionally
|
51 |
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
52 |
+
or by an individual or Legal Entity authorized to submit on behalf of
|
53 |
+
the copyright owner. For the purposes of this definition, "submitted"
|
54 |
+
means any form of electronic, verbal, or written communication sent
|
55 |
+
to the Licensor or its representatives, including but not limited to
|
56 |
+
communication on electronic mailing lists, source code control systems,
|
57 |
+
and issue tracking systems that are managed by, or on behalf of, the
|
58 |
+
Licensor for the purpose of discussing and improving the Work, but
|
59 |
+
excluding communication that is conspicuously marked or otherwise
|
60 |
+
designated in writing by the copyright owner as "Not a Contribution."
|
61 |
+
|
62 |
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
63 |
+
on behalf of whom a Contribution has been received by Licensor and
|
64 |
+
subsequently incorporated within the Work.
|
65 |
+
|
66 |
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
67 |
+
this License, each Contributor hereby grants to You a perpetual,
|
68 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
69 |
+
copyright license to reproduce, prepare Derivative Works of,
|
70 |
+
publicly display, publicly perform, sublicense, and distribute the
|
71 |
+
Work and such Derivative Works in Source or Object form.
|
72 |
+
|
73 |
+
3. Grant of Patent License. Subject to the terms and conditions of
|
74 |
+
this License, each Contributor hereby grants to You a perpetual,
|
75 |
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
76 |
+
(except as stated in this section) patent license to make, have made,
|
77 |
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
78 |
+
where such license applies only to those patent claims licensable
|
79 |
+
by such Contributor that are necessarily infringed by their
|
80 |
+
Contribution(s) alone or by combination of their Contribution(s)
|
81 |
+
with the Work to which such Contribution(s) was submitted. If You
|
82 |
+
institute patent litigation against any entity (including a
|
83 |
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
84 |
+
or a Contribution incorporated within the Work constitutes direct
|
85 |
+
or contributory patent infringement, then any patent licenses
|
86 |
+
granted to You under this License for that Work shall terminate
|
87 |
+
as of the date such litigation is filed.
|
88 |
+
|
89 |
+
4. Redistribution. You may reproduce and distribute copies of the
|
90 |
+
Work or Derivative Works thereof in any medium, with or without
|
91 |
+
modifications, and in Source or Object form, provided that You
|
92 |
+
meet the following conditions:
|
93 |
+
|
94 |
+
(a) You must give any other recipients of the Work or
|
95 |
+
Derivative Works a copy of this License; and
|
96 |
+
|
97 |
+
(b) You must cause any modified files to carry prominent notices
|
98 |
+
stating that You changed the files; and
|
99 |
+
|
100 |
+
(c) You must retain, in the Source form of any Derivative Works
|
101 |
+
that You distribute, all copyright, patent, trademark, and
|
102 |
+
attribution notices from the Source form of the Work,
|
103 |
+
excluding those notices that do not pertain to any part of
|
104 |
+
the Derivative Works; and
|
105 |
+
|
106 |
+
(d) If the Work includes a "NOTICE" text file as part of its
|
107 |
+
distribution, then any Derivative Works that You distribute must
|
108 |
+
include a readable copy of the attribution notices contained
|
109 |
+
within such NOTICE file, excluding those notices that do not
|
110 |
+
pertain to any part of the Derivative Works, in at least one
|
111 |
+
of the following places: within a NOTICE text file distributed
|
112 |
+
as part of the Derivative Works; within the Source form or
|
113 |
+
documentation, if provided along with the Derivative Works; or,
|
114 |
+
within a display generated by the Derivative Works, if and
|
115 |
+
wherever such third-party notices normally appear. The contents
|
116 |
+
of the NOTICE file are for informational purposes only and
|
117 |
+
do not modify the License. You may add Your own attribution
|
118 |
+
notices within Derivative Works that You distribute, alongside
|
119 |
+
or as an addendum to the NOTICE text from the Work, provided
|
120 |
+
that such additional attribution notices cannot be construed
|
121 |
+
as modifying the License.
|
122 |
+
|
123 |
+
You may add Your own copyright statement to Your modifications and
|
124 |
+
may provide additional or different license terms and conditions
|
125 |
+
for use, reproduction, or distribution of Your modifications, or
|
126 |
+
for any such Derivative Works as a whole, provided Your use,
|
127 |
+
reproduction, and distribution of the Work otherwise complies with
|
128 |
+
the conditions stated in this License.
|
129 |
+
|
130 |
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
131 |
+
any Contribution intentionally submitted for inclusion in the Work
|
132 |
+
by You to the Licensor shall be under the terms and conditions of
|
133 |
+
this License, without any additional terms or conditions.
|
134 |
+
Notwithstanding the above, nothing herein shall supersede or modify
|
135 |
+
the terms of any separate license agreement you may have executed
|
136 |
+
with Licensor regarding such Contributions.
|
137 |
+
|
138 |
+
6. Trademarks. This License does not grant permission to use the trade
|
139 |
+
names, trademarks, service marks, or product names of the Licensor,
|
140 |
+
except as required for reasonable and customary use in describing the
|
141 |
+
origin of the Work and reproducing the content of the NOTICE file.
|
142 |
+
|
143 |
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
144 |
+
agreed to in writing, Licensor provides the Work (and each
|
145 |
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
146 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
147 |
+
implied, including, without limitation, any warranties or conditions
|
148 |
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
149 |
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
150 |
+
appropriateness of using or redistributing the Work and assume any
|
151 |
+
risks associated with Your exercise of permissions under this License.
|
152 |
+
|
153 |
+
8. Limitation of Liability. In no event and under no legal theory,
|
154 |
+
whether in tort (including negligence), contract, or otherwise,
|
155 |
+
unless required by applicable law (such as deliberate and grossly
|
156 |
+
negligent acts) or agreed to in writing, shall any Contributor be
|
157 |
+
liable to You for damages, including any direct, indirect, special,
|
158 |
+
incidental, or consequential damages of any character arising as a
|
159 |
+
result of this License or out of the use or inability to use the
|
160 |
+
Work (including but not limited to damages for loss of goodwill,
|
161 |
+
work stoppage, computer failure or malfunction, or any and all
|
162 |
+
other commercial damages or losses), even if such Contributor
|
163 |
+
has been advised of the possibility of such damages.
|
164 |
+
|
165 |
+
9. Accepting Warranty or Additional Liability. While redistributing
|
166 |
+
the Work or Derivative Works thereof, You may choose to offer,
|
167 |
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
168 |
+
or other liability obligations and/or rights consistent with this
|
169 |
+
License. However, in accepting such obligations, You may act only
|
170 |
+
on Your own behalf and on Your sole responsibility, not on behalf
|
171 |
+
of any other Contributor, and only if You agree to indemnify,
|
172 |
+
defend, and hold each Contributor harmless for any liability
|
173 |
+
incurred by, or claims asserted against, such Contributor by reason
|
174 |
+
of your accepting any such warranty or additional liability.
|
175 |
+
|
176 |
+
END OF TERMS AND CONDITIONS
|
177 |
+
|
178 |
+
APPENDIX: How to apply the Apache License to your work.
|
179 |
+
|
180 |
+
To apply the Apache License to your work, attach the following
|
181 |
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
182 |
+
replaced with your own identifying information. (Don't include
|
183 |
+
the brackets!) The text should be enclosed in the appropriate
|
184 |
+
comment syntax for the file format. We also recommend that a
|
185 |
+
file or class name and description of purpose be included on the
|
186 |
+
same "printed page" as the copyright notice for easier
|
187 |
+
identification within third-party archives.
|
188 |
+
|
189 |
+
Copyright [yyyy] [name of copyright owner]
|
190 |
+
|
191 |
+
|
192 |
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193 |
+
you may not use this file except in compliance with the License.
|
194 |
+
You may obtain a copy of the License at
|
195 |
+
|
196 |
+
http://www.apache.org/licenses/LICENSE-2.0
|
197 |
+
|
198 |
+
Unless required by applicable law or agreed to in writing, software
|
199 |
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200 |
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201 |
+
See the License for the specific language governing permissions and
|
202 |
+
limitations under the License.
|
detectron2/MODEL_ZOO.md
ADDED
@@ -0,0 +1,1052 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Detectron2 Model Zoo and Baselines
|
2 |
+
|
3 |
+
## Introduction
|
4 |
+
|
5 |
+
This file documents a large collection of baselines trained
|
6 |
+
with detectron2 in Sep-Oct, 2019.
|
7 |
+
All numbers were obtained on [Big Basin](https://engineering.fb.com/data-center-engineering/introducing-big-basin-our-next-generation-ai-hardware/)
|
8 |
+
servers with 8 NVIDIA V100 GPUs & NVLink. The speed numbers are periodically updated with latest PyTorch/CUDA/cuDNN versions.
|
9 |
+
You can access these models from code using [detectron2.model_zoo](https://detectron2.readthedocs.io/modules/model_zoo.html) APIs.
|
10 |
+
|
11 |
+
In addition to these official baseline models, you can find more models in [projects/](projects/).
|
12 |
+
|
13 |
+
#### How to Read the Tables
|
14 |
+
* The "Name" column contains a link to the config file. Models can be reproduced using `tools/train_net.py` with the corresponding yaml config file,
|
15 |
+
or `tools/lazyconfig_train_net.py` for python config files.
|
16 |
+
* Training speed is averaged across the entire training.
|
17 |
+
We keep updating the speed with latest version of detectron2/pytorch/etc.,
|
18 |
+
so they might be different from the `metrics` file.
|
19 |
+
Training speed for multi-machine jobs is not provided.
|
20 |
+
* Inference speed is measured by `tools/train_net.py --eval-only`, or [inference_on_dataset()](https://detectron2.readthedocs.io/modules/evaluation.html#detectron2.evaluation.inference_on_dataset),
|
21 |
+
with batch size 1 in detectron2 directly.
|
22 |
+
Measuring it with custom code may introduce other overhead.
|
23 |
+
Actual deployment in production should in general be faster than the given inference
|
24 |
+
speed due to more optimizations.
|
25 |
+
* The *model id* column is provided for ease of reference.
|
26 |
+
To check downloaded file integrity, any model on this page contains its md5 prefix in its file name.
|
27 |
+
* Training curves and other statistics can be found in `metrics` for each model.
|
28 |
+
|
29 |
+
#### Common Settings for COCO Models
|
30 |
+
* All COCO models were trained on `train2017` and evaluated on `val2017`.
|
31 |
+
* The default settings are __not directly comparable__ with Detectron's standard settings.
|
32 |
+
For example, our default training data augmentation uses scale jittering in addition to horizontal flipping.
|
33 |
+
|
34 |
+
To make fair comparisons with Detectron's settings, see
|
35 |
+
[Detectron1-Comparisons](configs/Detectron1-Comparisons/) for accuracy comparison,
|
36 |
+
and [benchmarks](https://detectron2.readthedocs.io/notes/benchmarks.html)
|
37 |
+
for speed comparison.
|
38 |
+
* For Faster/Mask R-CNN, we provide baselines based on __3 different backbone combinations__:
|
39 |
+
* __FPN__: Use a ResNet+FPN backbone with standard conv and FC heads for mask and box prediction,
|
40 |
+
respectively. It obtains the best
|
41 |
+
speed/accuracy tradeoff, but the other two are still useful for research.
|
42 |
+
* __C4__: Use a ResNet conv4 backbone with conv5 head. The original baseline in the Faster R-CNN paper.
|
43 |
+
* __DC5__ (Dilated-C5): Use a ResNet conv5 backbone with dilations in conv5, and standard conv and FC heads
|
44 |
+
for mask and box prediction, respectively.
|
45 |
+
This is used by the Deformable ConvNet paper.
|
46 |
+
* Most models are trained with the 3x schedule (~37 COCO epochs).
|
47 |
+
Although 1x models are heavily under-trained, we provide some ResNet-50 models with the 1x (~12 COCO epochs)
|
48 |
+
training schedule for comparison when doing quick research iteration.
|
49 |
+
|
50 |
+
#### ImageNet Pretrained Models
|
51 |
+
|
52 |
+
It's common to initialize from backbone models pre-trained on ImageNet classification tasks. The following backbone models are available:
|
53 |
+
|
54 |
+
* [R-50.pkl](https://dl.fbaipublicfiles.com/detectron2/ImageNetPretrained/MSRA/R-50.pkl): converted copy of [MSRA's original ResNet-50](https://github.com/KaimingHe/deep-residual-networks) model.
|
55 |
+
* [R-101.pkl](https://dl.fbaipublicfiles.com/detectron2/ImageNetPretrained/MSRA/R-101.pkl): converted copy of [MSRA's original ResNet-101](https://github.com/KaimingHe/deep-residual-networks) model.
|
56 |
+
* [X-101-32x8d.pkl](https://dl.fbaipublicfiles.com/detectron2/ImageNetPretrained/FAIR/X-101-32x8d.pkl): ResNeXt-101-32x8d model trained with Caffe2 at FB.
|
57 |
+
* [R-50.pkl (torchvision)](https://dl.fbaipublicfiles.com/detectron2/ImageNetPretrained/torchvision/R-50.pkl): converted copy of [torchvision's ResNet-50](https://pytorch.org/docs/stable/torchvision/models.html#torchvision.models.resnet50) model.
|
58 |
+
More details can be found in [the conversion script](tools/convert-torchvision-to-d2.py).
|
59 |
+
|
60 |
+
Note that the above models have __different__ format from those provided in Detectron: we do not fuse BatchNorm into an affine layer.
|
61 |
+
Pretrained models in Detectron's format can still be used. For example:
|
62 |
+
* [X-152-32x8d-IN5k.pkl](https://dl.fbaipublicfiles.com/detectron/ImageNetPretrained/25093814/X-152-32x8d-IN5k.pkl):
|
63 |
+
ResNeXt-152-32x8d model trained on ImageNet-5k with Caffe2 at FB (see ResNeXt paper for details on ImageNet-5k).
|
64 |
+
* [R-50-GN.pkl](https://dl.fbaipublicfiles.com/detectron/ImageNetPretrained/47261647/R-50-GN.pkl):
|
65 |
+
ResNet-50 with Group Normalization.
|
66 |
+
* [R-101-GN.pkl](https://dl.fbaipublicfiles.com/detectron/ImageNetPretrained/47592356/R-101-GN.pkl):
|
67 |
+
ResNet-101 with Group Normalization.
|
68 |
+
|
69 |
+
These models require slightly different settings regarding normalization and architecture. See the model zoo configs for reference.
|
70 |
+
|
71 |
+
#### License
|
72 |
+
|
73 |
+
All models available for download through this document are licensed under the
|
74 |
+
[Creative Commons Attribution-ShareAlike 3.0 license](https://creativecommons.org/licenses/by-sa/3.0/).
|
75 |
+
|
76 |
+
### COCO Object Detection Baselines
|
77 |
+
|
78 |
+
#### Faster R-CNN:
|
79 |
+
<!--
|
80 |
+
(fb only) To update the table in vim:
|
81 |
+
1. Remove the old table: d}
|
82 |
+
2. Copy the below command to the place of the table
|
83 |
+
3. :.!bash
|
84 |
+
|
85 |
+
./gen_html_table.py --config 'COCO-Detection/faster*50*'{1x,3x}'*' 'COCO-Detection/faster*101*' --name R50-C4 R50-DC5 R50-FPN R50-C4 R50-DC5 R50-FPN R101-C4 R101-DC5 R101-FPN X101-FPN --fields lr_sched train_speed inference_speed mem box_AP
|
86 |
+
-->
|
87 |
+
|
88 |
+
|
89 |
+
<table><tbody>
|
90 |
+
<!-- START TABLE -->
|
91 |
+
<!-- TABLE HEADER -->
|
92 |
+
<th valign="bottom">Name</th>
|
93 |
+
<th valign="bottom">lr<br/>sched</th>
|
94 |
+
<th valign="bottom">train<br/>time<br/>(s/iter)</th>
|
95 |
+
<th valign="bottom">inference<br/>time<br/>(s/im)</th>
|
96 |
+
<th valign="bottom">train<br/>mem<br/>(GB)</th>
|
97 |
+
<th valign="bottom">box<br/>AP</th>
|
98 |
+
<th valign="bottom">model id</th>
|
99 |
+
<th valign="bottom">download</th>
|
100 |
+
<!-- TABLE BODY -->
|
101 |
+
<!-- ROW: faster_rcnn_R_50_C4_1x -->
|
102 |
+
<tr><td align="left"><a href="configs/COCO-Detection/faster_rcnn_R_50_C4_1x.yaml">R50-C4</a></td>
|
103 |
+
<td align="center">1x</td>
|
104 |
+
<td align="center">0.551</td>
|
105 |
+
<td align="center">0.102</td>
|
106 |
+
<td align="center">4.8</td>
|
107 |
+
<td align="center">35.7</td>
|
108 |
+
<td align="center">137257644</td>
|
109 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_50_C4_1x/137257644/model_final_721ade.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_50_C4_1x/137257644/metrics.json">metrics</a></td>
|
110 |
+
</tr>
|
111 |
+
<!-- ROW: faster_rcnn_R_50_DC5_1x -->
|
112 |
+
<tr><td align="left"><a href="configs/COCO-Detection/faster_rcnn_R_50_DC5_1x.yaml">R50-DC5</a></td>
|
113 |
+
<td align="center">1x</td>
|
114 |
+
<td align="center">0.380</td>
|
115 |
+
<td align="center">0.068</td>
|
116 |
+
<td align="center">5.0</td>
|
117 |
+
<td align="center">37.3</td>
|
118 |
+
<td align="center">137847829</td>
|
119 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_50_DC5_1x/137847829/model_final_51d356.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_50_DC5_1x/137847829/metrics.json">metrics</a></td>
|
120 |
+
</tr>
|
121 |
+
<!-- ROW: faster_rcnn_R_50_FPN_1x -->
|
122 |
+
<tr><td align="left"><a href="configs/COCO-Detection/faster_rcnn_R_50_FPN_1x.yaml">R50-FPN</a></td>
|
123 |
+
<td align="center">1x</td>
|
124 |
+
<td align="center">0.210</td>
|
125 |
+
<td align="center">0.038</td>
|
126 |
+
<td align="center">3.0</td>
|
127 |
+
<td align="center">37.9</td>
|
128 |
+
<td align="center">137257794</td>
|
129 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_50_FPN_1x/137257794/model_final_b275ba.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_50_FPN_1x/137257794/metrics.json">metrics</a></td>
|
130 |
+
</tr>
|
131 |
+
<!-- ROW: faster_rcnn_R_50_C4_3x -->
|
132 |
+
<tr><td align="left"><a href="configs/COCO-Detection/faster_rcnn_R_50_C4_3x.yaml">R50-C4</a></td>
|
133 |
+
<td align="center">3x</td>
|
134 |
+
<td align="center">0.543</td>
|
135 |
+
<td align="center">0.104</td>
|
136 |
+
<td align="center">4.8</td>
|
137 |
+
<td align="center">38.4</td>
|
138 |
+
<td align="center">137849393</td>
|
139 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_50_C4_3x/137849393/model_final_f97cb7.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_50_C4_3x/137849393/metrics.json">metrics</a></td>
|
140 |
+
</tr>
|
141 |
+
<!-- ROW: faster_rcnn_R_50_DC5_3x -->
|
142 |
+
<tr><td align="left"><a href="configs/COCO-Detection/faster_rcnn_R_50_DC5_3x.yaml">R50-DC5</a></td>
|
143 |
+
<td align="center">3x</td>
|
144 |
+
<td align="center">0.378</td>
|
145 |
+
<td align="center">0.070</td>
|
146 |
+
<td align="center">5.0</td>
|
147 |
+
<td align="center">39.0</td>
|
148 |
+
<td align="center">137849425</td>
|
149 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_50_DC5_3x/137849425/model_final_68d202.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_50_DC5_3x/137849425/metrics.json">metrics</a></td>
|
150 |
+
</tr>
|
151 |
+
<!-- ROW: faster_rcnn_R_50_FPN_3x -->
|
152 |
+
<tr><td align="left"><a href="configs/COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml">R50-FPN</a></td>
|
153 |
+
<td align="center">3x</td>
|
154 |
+
<td align="center">0.209</td>
|
155 |
+
<td align="center">0.038</td>
|
156 |
+
<td align="center">3.0</td>
|
157 |
+
<td align="center">40.2</td>
|
158 |
+
<td align="center">137849458</td>
|
159 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_50_FPN_3x/137849458/model_final_280758.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_50_FPN_3x/137849458/metrics.json">metrics</a></td>
|
160 |
+
</tr>
|
161 |
+
<!-- ROW: faster_rcnn_R_101_C4_3x -->
|
162 |
+
<tr><td align="left"><a href="configs/COCO-Detection/faster_rcnn_R_101_C4_3x.yaml">R101-C4</a></td>
|
163 |
+
<td align="center">3x</td>
|
164 |
+
<td align="center">0.619</td>
|
165 |
+
<td align="center">0.139</td>
|
166 |
+
<td align="center">5.9</td>
|
167 |
+
<td align="center">41.1</td>
|
168 |
+
<td align="center">138204752</td>
|
169 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_101_C4_3x/138204752/model_final_298dad.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_101_C4_3x/138204752/metrics.json">metrics</a></td>
|
170 |
+
</tr>
|
171 |
+
<!-- ROW: faster_rcnn_R_101_DC5_3x -->
|
172 |
+
<tr><td align="left"><a href="configs/COCO-Detection/faster_rcnn_R_101_DC5_3x.yaml">R101-DC5</a></td>
|
173 |
+
<td align="center">3x</td>
|
174 |
+
<td align="center">0.452</td>
|
175 |
+
<td align="center">0.086</td>
|
176 |
+
<td align="center">6.1</td>
|
177 |
+
<td align="center">40.6</td>
|
178 |
+
<td align="center">138204841</td>
|
179 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_101_DC5_3x/138204841/model_final_3e0943.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_101_DC5_3x/138204841/metrics.json">metrics</a></td>
|
180 |
+
</tr>
|
181 |
+
<!-- ROW: faster_rcnn_R_101_FPN_3x -->
|
182 |
+
<tr><td align="left"><a href="configs/COCO-Detection/faster_rcnn_R_101_FPN_3x.yaml">R101-FPN</a></td>
|
183 |
+
<td align="center">3x</td>
|
184 |
+
<td align="center">0.286</td>
|
185 |
+
<td align="center">0.051</td>
|
186 |
+
<td align="center">4.1</td>
|
187 |
+
<td align="center">42.0</td>
|
188 |
+
<td align="center">137851257</td>
|
189 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_101_FPN_3x/137851257/model_final_f6e8b1.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_R_101_FPN_3x/137851257/metrics.json">metrics</a></td>
|
190 |
+
</tr>
|
191 |
+
<!-- ROW: faster_rcnn_X_101_32x8d_FPN_3x -->
|
192 |
+
<tr><td align="left"><a href="configs/COCO-Detection/faster_rcnn_X_101_32x8d_FPN_3x.yaml">X101-FPN</a></td>
|
193 |
+
<td align="center">3x</td>
|
194 |
+
<td align="center">0.638</td>
|
195 |
+
<td align="center">0.098</td>
|
196 |
+
<td align="center">6.7</td>
|
197 |
+
<td align="center">43.0</td>
|
198 |
+
<td align="center">139173657</td>
|
199 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_X_101_32x8d_FPN_3x/139173657/model_final_68b088.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/faster_rcnn_X_101_32x8d_FPN_3x/139173657/metrics.json">metrics</a></td>
|
200 |
+
</tr>
|
201 |
+
</tbody></table>
|
202 |
+
|
203 |
+
#### RetinaNet:
|
204 |
+
<!--
|
205 |
+
./gen_html_table.py --config 'COCO-Detection/retina*50*' 'COCO-Detection/retina*101*' --name R50 R50 R101 --fields lr_sched train_speed inference_speed mem box_AP
|
206 |
+
-->
|
207 |
+
|
208 |
+
<table><tbody>
|
209 |
+
<!-- START TABLE -->
|
210 |
+
<!-- TABLE HEADER -->
|
211 |
+
<th valign="bottom">Name</th>
|
212 |
+
<th valign="bottom">lr<br/>sched</th>
|
213 |
+
<th valign="bottom">train<br/>time<br/>(s/iter)</th>
|
214 |
+
<th valign="bottom">inference<br/>time<br/>(s/im)</th>
|
215 |
+
<th valign="bottom">train<br/>mem<br/>(GB)</th>
|
216 |
+
<th valign="bottom">box<br/>AP</th>
|
217 |
+
<th valign="bottom">model id</th>
|
218 |
+
<th valign="bottom">download</th>
|
219 |
+
<!-- TABLE BODY -->
|
220 |
+
<!-- ROW: retinanet_R_50_FPN_1x -->
|
221 |
+
<tr><td align="left"><a href="configs/COCO-Detection/retinanet_R_50_FPN_1x.yaml">R50</a></td>
|
222 |
+
<td align="center">1x</td>
|
223 |
+
<td align="center">0.205</td>
|
224 |
+
<td align="center">0.041</td>
|
225 |
+
<td align="center">4.1</td>
|
226 |
+
<td align="center">37.4</td>
|
227 |
+
<td align="center">190397773</td>
|
228 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/retinanet_R_50_FPN_1x/190397773/model_final_bfca0b.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/retinanet_R_50_FPN_1x/190397773/metrics.json">metrics</a></td>
|
229 |
+
</tr>
|
230 |
+
<!-- ROW: retinanet_R_50_FPN_3x -->
|
231 |
+
<tr><td align="left"><a href="configs/COCO-Detection/retinanet_R_50_FPN_3x.yaml">R50</a></td>
|
232 |
+
<td align="center">3x</td>
|
233 |
+
<td align="center">0.205</td>
|
234 |
+
<td align="center">0.041</td>
|
235 |
+
<td align="center">4.1</td>
|
236 |
+
<td align="center">38.7</td>
|
237 |
+
<td align="center">190397829</td>
|
238 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/retinanet_R_50_FPN_3x/190397829/model_final_5bd44e.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/retinanet_R_50_FPN_3x/190397829/metrics.json">metrics</a></td>
|
239 |
+
</tr>
|
240 |
+
<!-- ROW: retinanet_R_101_FPN_3x -->
|
241 |
+
<tr><td align="left"><a href="configs/COCO-Detection/retinanet_R_101_FPN_3x.yaml">R101</a></td>
|
242 |
+
<td align="center">3x</td>
|
243 |
+
<td align="center">0.291</td>
|
244 |
+
<td align="center">0.054</td>
|
245 |
+
<td align="center">5.2</td>
|
246 |
+
<td align="center">40.4</td>
|
247 |
+
<td align="center">190397697</td>
|
248 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/retinanet_R_101_FPN_3x/190397697/model_final_971ab9.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/retinanet_R_101_FPN_3x/190397697/metrics.json">metrics</a></td>
|
249 |
+
</tr>
|
250 |
+
</tbody></table>
|
251 |
+
|
252 |
+
|
253 |
+
#### RPN & Fast R-CNN:
|
254 |
+
<!--
|
255 |
+
./gen_html_table.py --config 'COCO-Detection/rpn*' 'COCO-Detection/fast_rcnn*' --name "RPN R50-C4" "RPN R50-FPN" "Fast R-CNN R50-FPN" --fields lr_sched train_speed inference_speed mem box_AP prop_AR
|
256 |
+
-->
|
257 |
+
|
258 |
+
<table><tbody>
|
259 |
+
<!-- START TABLE -->
|
260 |
+
<!-- TABLE HEADER -->
|
261 |
+
<th valign="bottom">Name</th>
|
262 |
+
<th valign="bottom">lr<br/>sched</th>
|
263 |
+
<th valign="bottom">train<br/>time<br/>(s/iter)</th>
|
264 |
+
<th valign="bottom">inference<br/>time<br/>(s/im)</th>
|
265 |
+
<th valign="bottom">train<br/>mem<br/>(GB)</th>
|
266 |
+
<th valign="bottom">box<br/>AP</th>
|
267 |
+
<th valign="bottom">prop.<br/>AR</th>
|
268 |
+
<th valign="bottom">model id</th>
|
269 |
+
<th valign="bottom">download</th>
|
270 |
+
<!-- TABLE BODY -->
|
271 |
+
<!-- ROW: rpn_R_50_C4_1x -->
|
272 |
+
<tr><td align="left"><a href="configs/COCO-Detection/rpn_R_50_C4_1x.yaml">RPN R50-C4</a></td>
|
273 |
+
<td align="center">1x</td>
|
274 |
+
<td align="center">0.130</td>
|
275 |
+
<td align="center">0.034</td>
|
276 |
+
<td align="center">1.5</td>
|
277 |
+
<td align="center"></td>
|
278 |
+
<td align="center">51.6</td>
|
279 |
+
<td align="center">137258005</td>
|
280 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/rpn_R_50_C4_1x/137258005/model_final_450694.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/rpn_R_50_C4_1x/137258005/metrics.json">metrics</a></td>
|
281 |
+
</tr>
|
282 |
+
<!-- ROW: rpn_R_50_FPN_1x -->
|
283 |
+
<tr><td align="left"><a href="configs/COCO-Detection/rpn_R_50_FPN_1x.yaml">RPN R50-FPN</a></td>
|
284 |
+
<td align="center">1x</td>
|
285 |
+
<td align="center">0.186</td>
|
286 |
+
<td align="center">0.032</td>
|
287 |
+
<td align="center">2.7</td>
|
288 |
+
<td align="center"></td>
|
289 |
+
<td align="center">58.0</td>
|
290 |
+
<td align="center">137258492</td>
|
291 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/rpn_R_50_FPN_1x/137258492/model_final_02ce48.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/rpn_R_50_FPN_1x/137258492/metrics.json">metrics</a></td>
|
292 |
+
</tr>
|
293 |
+
<!-- ROW: fast_rcnn_R_50_FPN_1x -->
|
294 |
+
<tr><td align="left"><a href="configs/COCO-Detection/fast_rcnn_R_50_FPN_1x.yaml">Fast R-CNN R50-FPN</a></td>
|
295 |
+
<td align="center">1x</td>
|
296 |
+
<td align="center">0.140</td>
|
297 |
+
<td align="center">0.029</td>
|
298 |
+
<td align="center">2.6</td>
|
299 |
+
<td align="center">37.8</td>
|
300 |
+
<td align="center"></td>
|
301 |
+
<td align="center">137635226</td>
|
302 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/fast_rcnn_R_50_FPN_1x/137635226/model_final_e5f7ce.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Detection/fast_rcnn_R_50_FPN_1x/137635226/metrics.json">metrics</a></td>
|
303 |
+
</tr>
|
304 |
+
</tbody></table>
|
305 |
+
|
306 |
+
### COCO Instance Segmentation Baselines with Mask R-CNN
|
307 |
+
<!--
|
308 |
+
./gen_html_table.py --config 'COCO-InstanceSegmentation/mask*50*'{1x,3x}'*' 'COCO-InstanceSegmentation/mask*101*' --name R50-C4 R50-DC5 R50-FPN R50-C4 R50-DC5 R50-FPN R101-C4 R101-DC5 R101-FPN X101-FPN --fields lr_sched train_speed inference_speed mem box_AP mask_AP
|
309 |
+
-->
|
310 |
+
|
311 |
+
|
312 |
+
|
313 |
+
<table><tbody>
|
314 |
+
<!-- START TABLE -->
|
315 |
+
<!-- TABLE HEADER -->
|
316 |
+
<th valign="bottom">Name</th>
|
317 |
+
<th valign="bottom">lr<br/>sched</th>
|
318 |
+
<th valign="bottom">train<br/>time<br/>(s/iter)</th>
|
319 |
+
<th valign="bottom">inference<br/>time<br/>(s/im)</th>
|
320 |
+
<th valign="bottom">train<br/>mem<br/>(GB)</th>
|
321 |
+
<th valign="bottom">box<br/>AP</th>
|
322 |
+
<th valign="bottom">mask<br/>AP</th>
|
323 |
+
<th valign="bottom">model id</th>
|
324 |
+
<th valign="bottom">download</th>
|
325 |
+
<!-- TABLE BODY -->
|
326 |
+
<!-- ROW: mask_rcnn_R_50_C4_1x -->
|
327 |
+
<tr><td align="left"><a href="configs/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_1x.yaml">R50-C4</a></td>
|
328 |
+
<td align="center">1x</td>
|
329 |
+
<td align="center">0.584</td>
|
330 |
+
<td align="center">0.110</td>
|
331 |
+
<td align="center">5.2</td>
|
332 |
+
<td align="center">36.8</td>
|
333 |
+
<td align="center">32.2</td>
|
334 |
+
<td align="center">137259246</td>
|
335 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_1x/137259246/model_final_9243eb.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_1x/137259246/metrics.json">metrics</a></td>
|
336 |
+
</tr>
|
337 |
+
<!-- ROW: mask_rcnn_R_50_DC5_1x -->
|
338 |
+
<tr><td align="left"><a href="configs/COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_1x.yaml">R50-DC5</a></td>
|
339 |
+
<td align="center">1x</td>
|
340 |
+
<td align="center">0.471</td>
|
341 |
+
<td align="center">0.076</td>
|
342 |
+
<td align="center">6.5</td>
|
343 |
+
<td align="center">38.3</td>
|
344 |
+
<td align="center">34.2</td>
|
345 |
+
<td align="center">137260150</td>
|
346 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_1x/137260150/model_final_4f86c3.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_1x/137260150/metrics.json">metrics</a></td>
|
347 |
+
</tr>
|
348 |
+
<!-- ROW: mask_rcnn_R_50_FPN_1x -->
|
349 |
+
<tr><td align="left"><a href="configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml">R50-FPN</a></td>
|
350 |
+
<td align="center">1x</td>
|
351 |
+
<td align="center">0.261</td>
|
352 |
+
<td align="center">0.043</td>
|
353 |
+
<td align="center">3.4</td>
|
354 |
+
<td align="center">38.6</td>
|
355 |
+
<td align="center">35.2</td>
|
356 |
+
<td align="center">137260431</td>
|
357 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x/137260431/model_final_a54504.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x/137260431/metrics.json">metrics</a></td>
|
358 |
+
</tr>
|
359 |
+
<!-- ROW: mask_rcnn_R_50_C4_3x -->
|
360 |
+
<tr><td align="left"><a href="configs/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_3x.yaml">R50-C4</a></td>
|
361 |
+
<td align="center">3x</td>
|
362 |
+
<td align="center">0.575</td>
|
363 |
+
<td align="center">0.111</td>
|
364 |
+
<td align="center">5.2</td>
|
365 |
+
<td align="center">39.8</td>
|
366 |
+
<td align="center">34.4</td>
|
367 |
+
<td align="center">137849525</td>
|
368 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_3x/137849525/model_final_4ce675.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_C4_3x/137849525/metrics.json">metrics</a></td>
|
369 |
+
</tr>
|
370 |
+
<!-- ROW: mask_rcnn_R_50_DC5_3x -->
|
371 |
+
<tr><td align="left"><a href="configs/COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_3x.yaml">R50-DC5</a></td>
|
372 |
+
<td align="center">3x</td>
|
373 |
+
<td align="center">0.470</td>
|
374 |
+
<td align="center">0.076</td>
|
375 |
+
<td align="center">6.5</td>
|
376 |
+
<td align="center">40.0</td>
|
377 |
+
<td align="center">35.9</td>
|
378 |
+
<td align="center">137849551</td>
|
379 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_3x/137849551/model_final_84107b.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_DC5_3x/137849551/metrics.json">metrics</a></td>
|
380 |
+
</tr>
|
381 |
+
<!-- ROW: mask_rcnn_R_50_FPN_3x -->
|
382 |
+
<tr><td align="left"><a href="configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml">R50-FPN</a></td>
|
383 |
+
<td align="center">3x</td>
|
384 |
+
<td align="center">0.261</td>
|
385 |
+
<td align="center">0.043</td>
|
386 |
+
<td align="center">3.4</td>
|
387 |
+
<td align="center">41.0</td>
|
388 |
+
<td align="center">37.2</td>
|
389 |
+
<td align="center">137849600</td>
|
390 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/metrics.json">metrics</a></td>
|
391 |
+
</tr>
|
392 |
+
<!-- ROW: mask_rcnn_R_101_C4_3x -->
|
393 |
+
<tr><td align="left"><a href="configs/COCO-InstanceSegmentation/mask_rcnn_R_101_C4_3x.yaml">R101-C4</a></td>
|
394 |
+
<td align="center">3x</td>
|
395 |
+
<td align="center">0.652</td>
|
396 |
+
<td align="center">0.145</td>
|
397 |
+
<td align="center">6.3</td>
|
398 |
+
<td align="center">42.6</td>
|
399 |
+
<td align="center">36.7</td>
|
400 |
+
<td align="center">138363239</td>
|
401 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_101_C4_3x/138363239/model_final_a2914c.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_101_C4_3x/138363239/metrics.json">metrics</a></td>
|
402 |
+
</tr>
|
403 |
+
<!-- ROW: mask_rcnn_R_101_DC5_3x -->
|
404 |
+
<tr><td align="left"><a href="configs/COCO-InstanceSegmentation/mask_rcnn_R_101_DC5_3x.yaml">R101-DC5</a></td>
|
405 |
+
<td align="center">3x</td>
|
406 |
+
<td align="center">0.545</td>
|
407 |
+
<td align="center">0.092</td>
|
408 |
+
<td align="center">7.6</td>
|
409 |
+
<td align="center">41.9</td>
|
410 |
+
<td align="center">37.3</td>
|
411 |
+
<td align="center">138363294</td>
|
412 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_101_DC5_3x/138363294/model_final_0464b7.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_101_DC5_3x/138363294/metrics.json">metrics</a></td>
|
413 |
+
</tr>
|
414 |
+
<!-- ROW: mask_rcnn_R_101_FPN_3x -->
|
415 |
+
<tr><td align="left"><a href="configs/COCO-InstanceSegmentation/mask_rcnn_R_101_FPN_3x.yaml">R101-FPN</a></td>
|
416 |
+
<td align="center">3x</td>
|
417 |
+
<td align="center">0.340</td>
|
418 |
+
<td align="center">0.056</td>
|
419 |
+
<td align="center">4.6</td>
|
420 |
+
<td align="center">42.9</td>
|
421 |
+
<td align="center">38.6</td>
|
422 |
+
<td align="center">138205316</td>
|
423 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_101_FPN_3x/138205316/model_final_a3ec72.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_101_FPN_3x/138205316/metrics.json">metrics</a></td>
|
424 |
+
</tr>
|
425 |
+
<!-- ROW: mask_rcnn_X_101_32x8d_FPN_3x -->
|
426 |
+
<tr><td align="left"><a href="configs/COCO-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_3x.yaml">X101-FPN</a></td>
|
427 |
+
<td align="center">3x</td>
|
428 |
+
<td align="center">0.690</td>
|
429 |
+
<td align="center">0.103</td>
|
430 |
+
<td align="center">7.2</td>
|
431 |
+
<td align="center">44.3</td>
|
432 |
+
<td align="center">39.5</td>
|
433 |
+
<td align="center">139653917</td>
|
434 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_3x/139653917/model_final_2d9806.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_3x/139653917/metrics.json">metrics</a></td>
|
435 |
+
</tr>
|
436 |
+
</tbody></table>
|
437 |
+
|
438 |
+
|
439 |
+
|
440 |
+
#### New baselines using Large-Scale Jitter and Longer Training Schedule
|
441 |
+
|
442 |
+
The following baselines of COCO Instance Segmentation with Mask R-CNN are generated
|
443 |
+
using a longer training schedule and large-scale jitter as described in Google's
|
444 |
+
[Simple Copy-Paste Data Augmentation](https://arxiv.org/pdf/2012.07177.pdf) paper. These
|
445 |
+
models are trained from scratch using random initialization. These baselines exceed the
|
446 |
+
previous Mask R-CNN baselines.
|
447 |
+
|
448 |
+
In the following table, one epoch consists of training on 118000 COCO images.
|
449 |
+
|
450 |
+
<table><tbody>
|
451 |
+
<!-- START TABLE -->
|
452 |
+
<!-- TABLE HEADER -->
|
453 |
+
<th valign="bottom">Name</th>
|
454 |
+
<th valign="bottom">epochs</th>
|
455 |
+
<th valign="bottom">train<br/>time<br/>(s/im)</th>
|
456 |
+
<th valign="bottom">inference<br/>time<br/>(s/im)</th>
|
457 |
+
<th valign="bottom">box<br/>AP</th>
|
458 |
+
<th valign="bottom">mask<br/>AP</th>
|
459 |
+
<th valign="bottom">model id</th>
|
460 |
+
<th valign="bottom">download</th>
|
461 |
+
<!-- TABLE BODY -->
|
462 |
+
<!-- ROW: mask_rcnn_R_50_FPN_100ep_LSJ -->
|
463 |
+
<tr><td align="left"><a href="configs/new_baselines/mask_rcnn_R_50_FPN_100ep_LSJ.py">R50-FPN</a></td>
|
464 |
+
<td align="center">100</td>
|
465 |
+
<td align="center">0.376</td>
|
466 |
+
<td align="center">0.069</td>
|
467 |
+
<td align="center">44.6</td>
|
468 |
+
<td align="center">40.3</td>
|
469 |
+
<td align="center">42047764</td>
|
470 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_R_50_FPN_100ep_LSJ/42047764/model_final_bb69de.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_R_50_FPN_100ep_LSJ/42047764/metrics.json">metrics</a></td>
|
471 |
+
</tr>
|
472 |
+
<!-- ROW: mask_rcnn_R_50_FPN_200ep_LSJ -->
|
473 |
+
<tr><td align="left"><a href="configs/new_baselines/mask_rcnn_R_50_FPN_200ep_LSJ.py">R50-FPN</a></td>
|
474 |
+
<td align="center">200</td>
|
475 |
+
<td align="center">0.376</td>
|
476 |
+
<td align="center">0.069</td>
|
477 |
+
<td align="center">46.3</td>
|
478 |
+
<td align="center">41.7</td>
|
479 |
+
<td align="center">42047638</td>
|
480 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_R_50_FPN_200ep_LSJ/42047638/model_final_89a8d3.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_R_50_FPN_200ep_LSJ/42047638/metrics.json">metrics</a></td>
|
481 |
+
</tr>
|
482 |
+
<!-- ROW: mask_rcnn_R_50_FPN_400ep_LSJ -->
|
483 |
+
<tr><td align="left"><a href="configs/new_baselines/mask_rcnn_R_50_FPN_400ep_LSJ.py">R50-FPN</a></td>
|
484 |
+
<td align="center">400</td>
|
485 |
+
<td align="center">0.376</td>
|
486 |
+
<td align="center">0.069</td>
|
487 |
+
<td align="center">47.4</td>
|
488 |
+
<td align="center">42.5</td>
|
489 |
+
<td align="center">42019571</td>
|
490 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_R_50_FPN_400ep_LSJ/42019571/model_final_14d201.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_R_50_FPN_400ep_LSJ/42019571/metrics.json">metrics</a></td>
|
491 |
+
</tr>
|
492 |
+
<!-- ROW: mask_rcnn_R_101_FPN_100ep_LSJ -->
|
493 |
+
<tr><td align="left"><a href="configs/new_baselines/mask_rcnn_R_101_FPN_100ep_LSJ.py">R101-FPN</a></td>
|
494 |
+
<td align="center">100</td>
|
495 |
+
<td align="center">0.518</td>
|
496 |
+
<td align="center">0.073</td>
|
497 |
+
<td align="center">46.4</td>
|
498 |
+
<td align="center">41.6</td>
|
499 |
+
<td align="center">42025812</td>
|
500 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_R_101_FPN_100ep_LSJ/42025812/model_final_4f7b58.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_R_101_FPN_100ep_LSJ/42025812/metrics.json">metrics</a></td>
|
501 |
+
</tr>
|
502 |
+
<!-- ROW: mask_rcnn_R_101_FPN_200ep_LSJ -->
|
503 |
+
<tr><td align="left"><a href="configs/new_baselines/mask_rcnn_R_101_FPN_200ep_LSJ.py">R101-FPN</a></td>
|
504 |
+
<td align="center">200</td>
|
505 |
+
<td align="center">0.518</td>
|
506 |
+
<td align="center">0.073</td>
|
507 |
+
<td align="center">48.0</td>
|
508 |
+
<td align="center">43.1</td>
|
509 |
+
<td align="center">42131867</td>
|
510 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_R_101_FPN_200ep_LSJ/42131867/model_final_0bb7ae.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_R_101_FPN_200ep_LSJ/42131867/metrics.json">metrics</a></td>
|
511 |
+
</tr>
|
512 |
+
<!-- ROW: mask_rcnn_R_101_FPN_400ep_LSJ -->
|
513 |
+
<tr><td align="left"><a href="configs/new_baselines/mask_rcnn_R_101_FPN_400ep_LSJ.py">R101-FPN</a></td>
|
514 |
+
<td align="center">400</td>
|
515 |
+
<td align="center">0.518</td>
|
516 |
+
<td align="center">0.073</td>
|
517 |
+
<td align="center">48.9</td>
|
518 |
+
<td align="center">43.7</td>
|
519 |
+
<td align="center">42073830</td>
|
520 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_R_101_FPN_400ep_LSJ/42073830/model_final_f96b26.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_R_101_FPN_400ep_LSJ/42073830/metrics.json">metrics</a></td>
|
521 |
+
</tr>
|
522 |
+
<!-- ROW: mask_rcnn_regnetx_4gf_dds_FPN_100ep_LSJ -->
|
523 |
+
<tr><td align="left"><a href="configs/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_100ep_LSJ.py">regnetx_4gf_dds_FPN</a></td>
|
524 |
+
<td align="center">100</td>
|
525 |
+
<td align="center">0.474</td>
|
526 |
+
<td align="center">0.071</td>
|
527 |
+
<td align="center">46.0</td>
|
528 |
+
<td align="center">41.3</td>
|
529 |
+
<td align="center">42047771</td>
|
530 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_100ep_LSJ/42047771/model_final_b7fbab.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_100ep_LSJ/42047771/metrics.json">metrics</a></td>
|
531 |
+
</tr>
|
532 |
+
<!-- ROW: mask_rcnn_regnetx_4gf_dds_FPN_200ep_LSJ -->
|
533 |
+
<tr><td align="left"><a href="configs/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_200ep_LSJ.py">regnetx_4gf_dds_FPN</a></td>
|
534 |
+
<td align="center">200</td>
|
535 |
+
<td align="center">0.474</td>
|
536 |
+
<td align="center">0.071</td>
|
537 |
+
<td align="center">48.1</td>
|
538 |
+
<td align="center">43.1</td>
|
539 |
+
<td align="center">42132721</td>
|
540 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_200ep_LSJ/42132721/model_final_5d87c1.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_200ep_LSJ/42132721/metrics.json">metrics</a></td>
|
541 |
+
</tr>
|
542 |
+
<!-- ROW: mask_rcnn_regnetx_4gf_dds_FPN_400ep_LSJ -->
|
543 |
+
<tr><td align="left"><a href="configs/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_400ep_LSJ.py">regnetx_4gf_dds_FPN</a></td>
|
544 |
+
<td align="center">400</td>
|
545 |
+
<td align="center">0.474</td>
|
546 |
+
<td align="center">0.071</td>
|
547 |
+
<td align="center">48.6</td>
|
548 |
+
<td align="center">43.5</td>
|
549 |
+
<td align="center">42025447</td>
|
550 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_400ep_LSJ/42025447/model_final_f1362d.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_regnetx_4gf_dds_FPN_400ep_LSJ/42025447/metrics.json">metrics</a></td>
|
551 |
+
</tr>
|
552 |
+
<!-- ROW: mask_rcnn_regnety_4gf_dds_FPN_100ep_LSJ -->
|
553 |
+
<tr><td align="left"><a href="configs/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_100ep_LSJ.py">regnety_4gf_dds_FPN</a></td>
|
554 |
+
<td align="center">100</td>
|
555 |
+
<td align="center">0.487</td>
|
556 |
+
<td align="center">0.073</td>
|
557 |
+
<td align="center">46.1</td>
|
558 |
+
<td align="center">41.6</td>
|
559 |
+
<td align="center">42047784</td>
|
560 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_100ep_LSJ/42047784/model_final_6ba57e.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_100ep_LSJ/42047784/metrics.json">metrics</a></td>
|
561 |
+
</tr>
|
562 |
+
<!-- ROW: mask_rcnn_regnety_4gf_dds_FPN_200ep_LSJ -->
|
563 |
+
<tr><td align="left"><a href="configs/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_200ep_LSJ.py">regnety_4gf_dds_FPN</a></td>
|
564 |
+
<td align="center">200</td>
|
565 |
+
<td align="center">0.487</td>
|
566 |
+
<td align="center">0.072</td>
|
567 |
+
<td align="center">47.8</td>
|
568 |
+
<td align="center">43.0</td>
|
569 |
+
<td align="center">42047642</td>
|
570 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_200ep_LSJ/42047642/model_final_27b9c1.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_200ep_LSJ/42047642/metrics.json">metrics</a></td>
|
571 |
+
</tr>
|
572 |
+
<!-- ROW: mask_rcnn_regnety_4gf_dds_FPN_400ep_LSJ -->
|
573 |
+
<tr><td align="left"><a href="configs/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_400ep_LSJ.py">regnety_4gf_dds_FPN</a></td>
|
574 |
+
<td align="center">400</td>
|
575 |
+
<td align="center">0.487</td>
|
576 |
+
<td align="center">0.072</td>
|
577 |
+
<td align="center">48.2</td>
|
578 |
+
<td align="center">43.3</td>
|
579 |
+
<td align="center">42045954</td>
|
580 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_400ep_LSJ/42045954/model_final_ef3a80.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/new_baselines/mask_rcnn_regnety_4gf_dds_FPN_400ep_LSJ/42045954/metrics.json">metrics</a></td>
|
581 |
+
</tr>
|
582 |
+
</tbody></table>
|
583 |
+
|
584 |
+
### COCO Person Keypoint Detection Baselines with Keypoint R-CNN
|
585 |
+
<!--
|
586 |
+
./gen_html_table.py --config 'COCO-Keypoints/*50*' 'COCO-Keypoints/*101*' --name R50-FPN R50-FPN R101-FPN X101-FPN --fields lr_sched train_speed inference_speed mem box_AP keypoint_AP
|
587 |
+
-->
|
588 |
+
|
589 |
+
|
590 |
+
<table><tbody>
|
591 |
+
<!-- START TABLE -->
|
592 |
+
<!-- TABLE HEADER -->
|
593 |
+
<th valign="bottom">Name</th>
|
594 |
+
<th valign="bottom">lr<br/>sched</th>
|
595 |
+
<th valign="bottom">train<br/>time<br/>(s/iter)</th>
|
596 |
+
<th valign="bottom">inference<br/>time<br/>(s/im)</th>
|
597 |
+
<th valign="bottom">train<br/>mem<br/>(GB)</th>
|
598 |
+
<th valign="bottom">box<br/>AP</th>
|
599 |
+
<th valign="bottom">kp.<br/>AP</th>
|
600 |
+
<th valign="bottom">model id</th>
|
601 |
+
<th valign="bottom">download</th>
|
602 |
+
<!-- TABLE BODY -->
|
603 |
+
<!-- ROW: keypoint_rcnn_R_50_FPN_1x -->
|
604 |
+
<tr><td align="left"><a href="configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_1x.yaml">R50-FPN</a></td>
|
605 |
+
<td align="center">1x</td>
|
606 |
+
<td align="center">0.315</td>
|
607 |
+
<td align="center">0.072</td>
|
608 |
+
<td align="center">5.0</td>
|
609 |
+
<td align="center">53.6</td>
|
610 |
+
<td align="center">64.0</td>
|
611 |
+
<td align="center">137261548</td>
|
612 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Keypoints/keypoint_rcnn_R_50_FPN_1x/137261548/model_final_04e291.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Keypoints/keypoint_rcnn_R_50_FPN_1x/137261548/metrics.json">metrics</a></td>
|
613 |
+
</tr>
|
614 |
+
<!-- ROW: keypoint_rcnn_R_50_FPN_3x -->
|
615 |
+
<tr><td align="left"><a href="configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x.yaml">R50-FPN</a></td>
|
616 |
+
<td align="center">3x</td>
|
617 |
+
<td align="center">0.316</td>
|
618 |
+
<td align="center">0.066</td>
|
619 |
+
<td align="center">5.0</td>
|
620 |
+
<td align="center">55.4</td>
|
621 |
+
<td align="center">65.5</td>
|
622 |
+
<td align="center">137849621</td>
|
623 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x/137849621/model_final_a6e10b.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x/137849621/metrics.json">metrics</a></td>
|
624 |
+
</tr>
|
625 |
+
<!-- ROW: keypoint_rcnn_R_101_FPN_3x -->
|
626 |
+
<tr><td align="left"><a href="configs/COCO-Keypoints/keypoint_rcnn_R_101_FPN_3x.yaml">R101-FPN</a></td>
|
627 |
+
<td align="center">3x</td>
|
628 |
+
<td align="center">0.390</td>
|
629 |
+
<td align="center">0.076</td>
|
630 |
+
<td align="center">6.1</td>
|
631 |
+
<td align="center">56.4</td>
|
632 |
+
<td align="center">66.1</td>
|
633 |
+
<td align="center">138363331</td>
|
634 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Keypoints/keypoint_rcnn_R_101_FPN_3x/138363331/model_final_997cc7.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Keypoints/keypoint_rcnn_R_101_FPN_3x/138363331/metrics.json">metrics</a></td>
|
635 |
+
</tr>
|
636 |
+
<!-- ROW: keypoint_rcnn_X_101_32x8d_FPN_3x -->
|
637 |
+
<tr><td align="left"><a href="configs/COCO-Keypoints/keypoint_rcnn_X_101_32x8d_FPN_3x.yaml">X101-FPN</a></td>
|
638 |
+
<td align="center">3x</td>
|
639 |
+
<td align="center">0.738</td>
|
640 |
+
<td align="center">0.121</td>
|
641 |
+
<td align="center">8.7</td>
|
642 |
+
<td align="center">57.3</td>
|
643 |
+
<td align="center">66.0</td>
|
644 |
+
<td align="center">139686956</td>
|
645 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Keypoints/keypoint_rcnn_X_101_32x8d_FPN_3x/139686956/model_final_5ad38f.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-Keypoints/keypoint_rcnn_X_101_32x8d_FPN_3x/139686956/metrics.json">metrics</a></td>
|
646 |
+
</tr>
|
647 |
+
</tbody></table>
|
648 |
+
|
649 |
+
### COCO Panoptic Segmentation Baselines with Panoptic FPN
|
650 |
+
<!--
|
651 |
+
./gen_html_table.py --config 'COCO-PanopticSegmentation/*50*' 'COCO-PanopticSegmentation/*101*' --name R50-FPN R50-FPN R101-FPN --fields lr_sched train_speed inference_speed mem box_AP mask_AP PQ
|
652 |
+
-->
|
653 |
+
|
654 |
+
|
655 |
+
<table><tbody>
|
656 |
+
<!-- START TABLE -->
|
657 |
+
<!-- TABLE HEADER -->
|
658 |
+
<th valign="bottom">Name</th>
|
659 |
+
<th valign="bottom">lr<br/>sched</th>
|
660 |
+
<th valign="bottom">train<br/>time<br/>(s/iter)</th>
|
661 |
+
<th valign="bottom">inference<br/>time<br/>(s/im)</th>
|
662 |
+
<th valign="bottom">train<br/>mem<br/>(GB)</th>
|
663 |
+
<th valign="bottom">box<br/>AP</th>
|
664 |
+
<th valign="bottom">mask<br/>AP</th>
|
665 |
+
<th valign="bottom">PQ</th>
|
666 |
+
<th valign="bottom">model id</th>
|
667 |
+
<th valign="bottom">download</th>
|
668 |
+
<!-- TABLE BODY -->
|
669 |
+
<!-- ROW: panoptic_fpn_R_50_1x -->
|
670 |
+
<tr><td align="left"><a href="configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_1x.yaml">R50-FPN</a></td>
|
671 |
+
<td align="center">1x</td>
|
672 |
+
<td align="center">0.304</td>
|
673 |
+
<td align="center">0.053</td>
|
674 |
+
<td align="center">4.8</td>
|
675 |
+
<td align="center">37.6</td>
|
676 |
+
<td align="center">34.7</td>
|
677 |
+
<td align="center">39.4</td>
|
678 |
+
<td align="center">139514544</td>
|
679 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-PanopticSegmentation/panoptic_fpn_R_50_1x/139514544/model_final_dbfeb4.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-PanopticSegmentation/panoptic_fpn_R_50_1x/139514544/metrics.json">metrics</a></td>
|
680 |
+
</tr>
|
681 |
+
<!-- ROW: panoptic_fpn_R_50_3x -->
|
682 |
+
<tr><td align="left"><a href="configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_3x.yaml">R50-FPN</a></td>
|
683 |
+
<td align="center">3x</td>
|
684 |
+
<td align="center">0.302</td>
|
685 |
+
<td align="center">0.053</td>
|
686 |
+
<td align="center">4.8</td>
|
687 |
+
<td align="center">40.0</td>
|
688 |
+
<td align="center">36.5</td>
|
689 |
+
<td align="center">41.5</td>
|
690 |
+
<td align="center">139514569</td>
|
691 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-PanopticSegmentation/panoptic_fpn_R_50_3x/139514569/model_final_c10459.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-PanopticSegmentation/panoptic_fpn_R_50_3x/139514569/metrics.json">metrics</a></td>
|
692 |
+
</tr>
|
693 |
+
<!-- ROW: panoptic_fpn_R_101_3x -->
|
694 |
+
<tr><td align="left"><a href="configs/COCO-PanopticSegmentation/panoptic_fpn_R_101_3x.yaml">R101-FPN</a></td>
|
695 |
+
<td align="center">3x</td>
|
696 |
+
<td align="center">0.392</td>
|
697 |
+
<td align="center">0.066</td>
|
698 |
+
<td align="center">6.0</td>
|
699 |
+
<td align="center">42.4</td>
|
700 |
+
<td align="center">38.5</td>
|
701 |
+
<td align="center">43.0</td>
|
702 |
+
<td align="center">139514519</td>
|
703 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-PanopticSegmentation/panoptic_fpn_R_101_3x/139514519/model_final_cafdb1.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-PanopticSegmentation/panoptic_fpn_R_101_3x/139514519/metrics.json">metrics</a></td>
|
704 |
+
</tr>
|
705 |
+
</tbody></table>
|
706 |
+
|
707 |
+
|
708 |
+
### LVIS Instance Segmentation Baselines with Mask R-CNN
|
709 |
+
|
710 |
+
Mask R-CNN baselines on the [LVIS dataset](https://lvisdataset.org), v0.5.
|
711 |
+
These baselines are described in Table 3(c) of the [LVIS paper](https://arxiv.org/abs/1908.03195).
|
712 |
+
|
713 |
+
NOTE: the 1x schedule here has the same amount of __iterations__ as the COCO 1x baselines.
|
714 |
+
They are roughly 24 epochs of LVISv0.5 data.
|
715 |
+
The final results of these configs have large variance across different runs.
|
716 |
+
|
717 |
+
<!--
|
718 |
+
./gen_html_table.py --config 'LVISv0.5-InstanceSegmentation/mask*50*' 'LVISv0.5-InstanceSegmentation/mask*101*' --name R50-FPN R101-FPN X101-FPN --fields lr_sched train_speed inference_speed mem box_AP mask_AP
|
719 |
+
-->
|
720 |
+
|
721 |
+
|
722 |
+
<table><tbody>
|
723 |
+
<!-- START TABLE -->
|
724 |
+
<!-- TABLE HEADER -->
|
725 |
+
<th valign="bottom">Name</th>
|
726 |
+
<th valign="bottom">lr<br/>sched</th>
|
727 |
+
<th valign="bottom">train<br/>time<br/>(s/iter)</th>
|
728 |
+
<th valign="bottom">inference<br/>time<br/>(s/im)</th>
|
729 |
+
<th valign="bottom">train<br/>mem<br/>(GB)</th>
|
730 |
+
<th valign="bottom">box<br/>AP</th>
|
731 |
+
<th valign="bottom">mask<br/>AP</th>
|
732 |
+
<th valign="bottom">model id</th>
|
733 |
+
<th valign="bottom">download</th>
|
734 |
+
<!-- TABLE BODY -->
|
735 |
+
<!-- ROW: mask_rcnn_R_50_FPN_1x -->
|
736 |
+
<tr><td align="left"><a href="configs/LVISv0.5-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml">R50-FPN</a></td>
|
737 |
+
<td align="center">1x</td>
|
738 |
+
<td align="center">0.292</td>
|
739 |
+
<td align="center">0.107</td>
|
740 |
+
<td align="center">7.1</td>
|
741 |
+
<td align="center">23.6</td>
|
742 |
+
<td align="center">24.4</td>
|
743 |
+
<td align="center">144219072</td>
|
744 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/LVISv0.5-InstanceSegmentation/mask_rcnn_R_50_FPN_1x/144219072/model_final_571f7c.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/LVISv0.5-InstanceSegmentation/mask_rcnn_R_50_FPN_1x/144219072/metrics.json">metrics</a></td>
|
745 |
+
</tr>
|
746 |
+
<!-- ROW: mask_rcnn_R_101_FPN_1x -->
|
747 |
+
<tr><td align="left"><a href="configs/LVISv0.5-InstanceSegmentation/mask_rcnn_R_101_FPN_1x.yaml">R101-FPN</a></td>
|
748 |
+
<td align="center">1x</td>
|
749 |
+
<td align="center">0.371</td>
|
750 |
+
<td align="center">0.114</td>
|
751 |
+
<td align="center">7.8</td>
|
752 |
+
<td align="center">25.6</td>
|
753 |
+
<td align="center">25.9</td>
|
754 |
+
<td align="center">144219035</td>
|
755 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/LVISv0.5-InstanceSegmentation/mask_rcnn_R_101_FPN_1x/144219035/model_final_824ab5.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/LVISv0.5-InstanceSegmentation/mask_rcnn_R_101_FPN_1x/144219035/metrics.json">metrics</a></td>
|
756 |
+
</tr>
|
757 |
+
<!-- ROW: mask_rcnn_X_101_32x8d_FPN_1x -->
|
758 |
+
<tr><td align="left"><a href="configs/LVISv0.5-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_1x.yaml">X101-FPN</a></td>
|
759 |
+
<td align="center">1x</td>
|
760 |
+
<td align="center">0.712</td>
|
761 |
+
<td align="center">0.151</td>
|
762 |
+
<td align="center">10.2</td>
|
763 |
+
<td align="center">26.7</td>
|
764 |
+
<td align="center">27.1</td>
|
765 |
+
<td align="center">144219108</td>
|
766 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/LVISv0.5-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_1x/144219108/model_final_5e3439.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/LVISv0.5-InstanceSegmentation/mask_rcnn_X_101_32x8d_FPN_1x/144219108/metrics.json">metrics</a></td>
|
767 |
+
</tr>
|
768 |
+
</tbody></table>
|
769 |
+
|
770 |
+
|
771 |
+
|
772 |
+
### Cityscapes & Pascal VOC Baselines
|
773 |
+
|
774 |
+
Simple baselines for
|
775 |
+
* Mask R-CNN on Cityscapes instance segmentation (initialized from COCO pre-training, then trained on Cityscapes fine annotations only)
|
776 |
+
* Faster R-CNN on PASCAL VOC object detection (trained on VOC 2007 train+val + VOC 2012 train+val, tested on VOC 2007 using 11-point interpolated AP)
|
777 |
+
|
778 |
+
<!--
|
779 |
+
./gen_html_table.py --config 'Cityscapes/*' 'PascalVOC-Detection/*' --name "R50-FPN, Cityscapes" "R50-C4, VOC" --fields train_speed inference_speed mem box_AP box_AP50 mask_AP
|
780 |
+
-->
|
781 |
+
|
782 |
+
|
783 |
+
<table><tbody>
|
784 |
+
<!-- START TABLE -->
|
785 |
+
<!-- TABLE HEADER -->
|
786 |
+
<th valign="bottom">Name</th>
|
787 |
+
<th valign="bottom">train<br/>time<br/>(s/iter)</th>
|
788 |
+
<th valign="bottom">inference<br/>time<br/>(s/im)</th>
|
789 |
+
<th valign="bottom">train<br/>mem<br/>(GB)</th>
|
790 |
+
<th valign="bottom">box<br/>AP</th>
|
791 |
+
<th valign="bottom">box<br/>AP50</th>
|
792 |
+
<th valign="bottom">mask<br/>AP</th>
|
793 |
+
<th valign="bottom">model id</th>
|
794 |
+
<th valign="bottom">download</th>
|
795 |
+
<!-- TABLE BODY -->
|
796 |
+
<!-- ROW: mask_rcnn_R_50_FPN -->
|
797 |
+
<tr><td align="left"><a href="configs/Cityscapes/mask_rcnn_R_50_FPN.yaml">R50-FPN, Cityscapes</a></td>
|
798 |
+
<td align="center">0.240</td>
|
799 |
+
<td align="center">0.078</td>
|
800 |
+
<td align="center">4.4</td>
|
801 |
+
<td align="center"></td>
|
802 |
+
<td align="center"></td>
|
803 |
+
<td align="center">36.5</td>
|
804 |
+
<td align="center">142423278</td>
|
805 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/Cityscapes/mask_rcnn_R_50_FPN/142423278/model_final_af9cf5.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/Cityscapes/mask_rcnn_R_50_FPN/142423278/metrics.json">metrics</a></td>
|
806 |
+
</tr>
|
807 |
+
<!-- ROW: faster_rcnn_R_50_C4 -->
|
808 |
+
<tr><td align="left"><a href="configs/PascalVOC-Detection/faster_rcnn_R_50_C4.yaml">R50-C4, VOC</a></td>
|
809 |
+
<td align="center">0.537</td>
|
810 |
+
<td align="center">0.081</td>
|
811 |
+
<td align="center">4.8</td>
|
812 |
+
<td align="center">51.9</td>
|
813 |
+
<td align="center">80.3</td>
|
814 |
+
<td align="center"></td>
|
815 |
+
<td align="center">142202221</td>
|
816 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/PascalVOC-Detection/faster_rcnn_R_50_C4/142202221/model_final_b1acc2.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/PascalVOC-Detection/faster_rcnn_R_50_C4/142202221/metrics.json">metrics</a></td>
|
817 |
+
</tr>
|
818 |
+
</tbody></table>
|
819 |
+
|
820 |
+
|
821 |
+
|
822 |
+
### Other Settings
|
823 |
+
|
824 |
+
Ablations for Deformable Conv and Cascade R-CNN:
|
825 |
+
|
826 |
+
<!--
|
827 |
+
./gen_html_table.py --config 'COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml' 'Misc/*R_50_FPN_1x_dconv*' 'Misc/cascade*1x.yaml' 'COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml' 'Misc/*R_50_FPN_3x_dconv*' 'Misc/cascade*3x.yaml' --name "Baseline R50-FPN" "Deformable Conv" "Cascade R-CNN" "Baseline R50-FPN" "Deformable Conv" "Cascade R-CNN" --fields lr_sched train_speed inference_speed mem box_AP mask_AP
|
828 |
+
-->
|
829 |
+
|
830 |
+
|
831 |
+
<table><tbody>
|
832 |
+
<!-- START TABLE -->
|
833 |
+
<!-- TABLE HEADER -->
|
834 |
+
<th valign="bottom">Name</th>
|
835 |
+
<th valign="bottom">lr<br/>sched</th>
|
836 |
+
<th valign="bottom">train<br/>time<br/>(s/iter)</th>
|
837 |
+
<th valign="bottom">inference<br/>time<br/>(s/im)</th>
|
838 |
+
<th valign="bottom">train<br/>mem<br/>(GB)</th>
|
839 |
+
<th valign="bottom">box<br/>AP</th>
|
840 |
+
<th valign="bottom">mask<br/>AP</th>
|
841 |
+
<th valign="bottom">model id</th>
|
842 |
+
<th valign="bottom">download</th>
|
843 |
+
<!-- TABLE BODY -->
|
844 |
+
<!-- ROW: mask_rcnn_R_50_FPN_1x -->
|
845 |
+
<tr><td align="left"><a href="configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml">Baseline R50-FPN</a></td>
|
846 |
+
<td align="center">1x</td>
|
847 |
+
<td align="center">0.261</td>
|
848 |
+
<td align="center">0.043</td>
|
849 |
+
<td align="center">3.4</td>
|
850 |
+
<td align="center">38.6</td>
|
851 |
+
<td align="center">35.2</td>
|
852 |
+
<td align="center">137260431</td>
|
853 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x/137260431/model_final_a54504.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x/137260431/metrics.json">metrics</a></td>
|
854 |
+
</tr>
|
855 |
+
<!-- ROW: mask_rcnn_R_50_FPN_1x_dconv_c3-c5 -->
|
856 |
+
<tr><td align="left"><a href="configs/Misc/mask_rcnn_R_50_FPN_1x_dconv_c3-c5.yaml">Deformable Conv</a></td>
|
857 |
+
<td align="center">1x</td>
|
858 |
+
<td align="center">0.342</td>
|
859 |
+
<td align="center">0.048</td>
|
860 |
+
<td align="center">3.5</td>
|
861 |
+
<td align="center">41.5</td>
|
862 |
+
<td align="center">37.5</td>
|
863 |
+
<td align="center">138602867</td>
|
864 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/Misc/mask_rcnn_R_50_FPN_1x_dconv_c3-c5/138602867/model_final_65c703.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/Misc/mask_rcnn_R_50_FPN_1x_dconv_c3-c5/138602867/metrics.json">metrics</a></td>
|
865 |
+
</tr>
|
866 |
+
<!-- ROW: cascade_mask_rcnn_R_50_FPN_1x -->
|
867 |
+
<tr><td align="left"><a href="configs/Misc/cascade_mask_rcnn_R_50_FPN_1x.yaml">Cascade R-CNN</a></td>
|
868 |
+
<td align="center">1x</td>
|
869 |
+
<td align="center">0.317</td>
|
870 |
+
<td align="center">0.052</td>
|
871 |
+
<td align="center">4.0</td>
|
872 |
+
<td align="center">42.1</td>
|
873 |
+
<td align="center">36.4</td>
|
874 |
+
<td align="center">138602847</td>
|
875 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/Misc/cascade_mask_rcnn_R_50_FPN_1x/138602847/model_final_e9d89b.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/Misc/cascade_mask_rcnn_R_50_FPN_1x/138602847/metrics.json">metrics</a></td>
|
876 |
+
</tr>
|
877 |
+
<!-- ROW: mask_rcnn_R_50_FPN_3x -->
|
878 |
+
<tr><td align="left"><a href="configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml">Baseline R50-FPN</a></td>
|
879 |
+
<td align="center">3x</td>
|
880 |
+
<td align="center">0.261</td>
|
881 |
+
<td align="center">0.043</td>
|
882 |
+
<td align="center">3.4</td>
|
883 |
+
<td align="center">41.0</td>
|
884 |
+
<td align="center">37.2</td>
|
885 |
+
<td align="center">137849600</td>
|
886 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/metrics.json">metrics</a></td>
|
887 |
+
</tr>
|
888 |
+
<!-- ROW: mask_rcnn_R_50_FPN_3x_dconv_c3-c5 -->
|
889 |
+
<tr><td align="left"><a href="configs/Misc/mask_rcnn_R_50_FPN_3x_dconv_c3-c5.yaml">Deformable Conv</a></td>
|
890 |
+
<td align="center">3x</td>
|
891 |
+
<td align="center">0.349</td>
|
892 |
+
<td align="center">0.047</td>
|
893 |
+
<td align="center">3.5</td>
|
894 |
+
<td align="center">42.7</td>
|
895 |
+
<td align="center">38.5</td>
|
896 |
+
<td align="center">144998336</td>
|
897 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/Misc/mask_rcnn_R_50_FPN_3x_dconv_c3-c5/144998336/model_final_821d0b.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/Misc/mask_rcnn_R_50_FPN_3x_dconv_c3-c5/144998336/metrics.json">metrics</a></td>
|
898 |
+
</tr>
|
899 |
+
<!-- ROW: cascade_mask_rcnn_R_50_FPN_3x -->
|
900 |
+
<tr><td align="left"><a href="configs/Misc/cascade_mask_rcnn_R_50_FPN_3x.yaml">Cascade R-CNN</a></td>
|
901 |
+
<td align="center">3x</td>
|
902 |
+
<td align="center">0.328</td>
|
903 |
+
<td align="center">0.053</td>
|
904 |
+
<td align="center">4.0</td>
|
905 |
+
<td align="center">44.3</td>
|
906 |
+
<td align="center">38.5</td>
|
907 |
+
<td align="center">144998488</td>
|
908 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/Misc/cascade_mask_rcnn_R_50_FPN_3x/144998488/model_final_480dd8.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/Misc/cascade_mask_rcnn_R_50_FPN_3x/144998488/metrics.json">metrics</a></td>
|
909 |
+
</tr>
|
910 |
+
</tbody></table>
|
911 |
+
|
912 |
+
|
913 |
+
Ablations for normalization methods, and a few models trained from scratch following [Rethinking ImageNet Pre-training](https://arxiv.org/abs/1811.08883).
|
914 |
+
(Note: The baseline uses `2fc` head while the others use [`4conv1fc` head](https://arxiv.org/abs/1803.08494))
|
915 |
+
<!--
|
916 |
+
./gen_html_table.py --config 'COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml' 'Misc/mask*50_FPN_3x_gn.yaml' 'Misc/mask*50_FPN_3x_syncbn.yaml' 'Misc/scratch*' --name "Baseline R50-FPN" "GN" "SyncBN" "GN (from scratch)" "GN (from scratch)" "SyncBN (from scratch)" --fields lr_sched train_speed inference_speed mem box_AP mask_AP
|
917 |
+
-->
|
918 |
+
|
919 |
+
|
920 |
+
<table><tbody>
|
921 |
+
<!-- START TABLE -->
|
922 |
+
<!-- TABLE HEADER -->
|
923 |
+
<th valign="bottom">Name</th>
|
924 |
+
<th valign="bottom">lr<br/>sched</th>
|
925 |
+
<th valign="bottom">train<br/>time<br/>(s/iter)</th>
|
926 |
+
<th valign="bottom">inference<br/>time<br/>(s/im)</th>
|
927 |
+
<th valign="bottom">train<br/>mem<br/>(GB)</th>
|
928 |
+
<th valign="bottom">box<br/>AP</th>
|
929 |
+
<th valign="bottom">mask<br/>AP</th>
|
930 |
+
<th valign="bottom">model id</th>
|
931 |
+
<th valign="bottom">download</th>
|
932 |
+
<!-- TABLE BODY -->
|
933 |
+
<!-- ROW: mask_rcnn_R_50_FPN_3x -->
|
934 |
+
<tr><td align="left"><a href="configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml">Baseline R50-FPN</a></td>
|
935 |
+
<td align="center">3x</td>
|
936 |
+
<td align="center">0.261</td>
|
937 |
+
<td align="center">0.043</td>
|
938 |
+
<td align="center">3.4</td>
|
939 |
+
<td align="center">41.0</td>
|
940 |
+
<td align="center">37.2</td>
|
941 |
+
<td align="center">137849600</td>
|
942 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/metrics.json">metrics</a></td>
|
943 |
+
</tr>
|
944 |
+
<!-- ROW: mask_rcnn_R_50_FPN_3x_gn -->
|
945 |
+
<tr><td align="left"><a href="configs/Misc/mask_rcnn_R_50_FPN_3x_gn.yaml">GN</a></td>
|
946 |
+
<td align="center">3x</td>
|
947 |
+
<td align="center">0.309</td>
|
948 |
+
<td align="center">0.060</td>
|
949 |
+
<td align="center">5.6</td>
|
950 |
+
<td align="center">42.6</td>
|
951 |
+
<td align="center">38.6</td>
|
952 |
+
<td align="center">138602888</td>
|
953 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/Misc/mask_rcnn_R_50_FPN_3x_gn/138602888/model_final_dc5d9e.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/Misc/mask_rcnn_R_50_FPN_3x_gn/138602888/metrics.json">metrics</a></td>
|
954 |
+
</tr>
|
955 |
+
<!-- ROW: mask_rcnn_R_50_FPN_3x_syncbn -->
|
956 |
+
<tr><td align="left"><a href="configs/Misc/mask_rcnn_R_50_FPN_3x_syncbn.yaml">SyncBN</a></td>
|
957 |
+
<td align="center">3x</td>
|
958 |
+
<td align="center">0.345</td>
|
959 |
+
<td align="center">0.053</td>
|
960 |
+
<td align="center">5.5</td>
|
961 |
+
<td align="center">41.9</td>
|
962 |
+
<td align="center">37.8</td>
|
963 |
+
<td align="center">169527823</td>
|
964 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/Misc/mask_rcnn_R_50_FPN_3x_syncbn/169527823/model_final_3b3c51.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/Misc/mask_rcnn_R_50_FPN_3x_syncbn/169527823/metrics.json">metrics</a></td>
|
965 |
+
</tr>
|
966 |
+
<!-- ROW: scratch_mask_rcnn_R_50_FPN_3x_gn -->
|
967 |
+
<tr><td align="left"><a href="configs/Misc/scratch_mask_rcnn_R_50_FPN_3x_gn.yaml">GN (from scratch)</a></td>
|
968 |
+
<td align="center">3x</td>
|
969 |
+
<td align="center">0.338</td>
|
970 |
+
<td align="center">0.061</td>
|
971 |
+
<td align="center">7.2</td>
|
972 |
+
<td align="center">39.9</td>
|
973 |
+
<td align="center">36.6</td>
|
974 |
+
<td align="center">138602908</td>
|
975 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/Misc/scratch_mask_rcnn_R_50_FPN_3x_gn/138602908/model_final_01ca85.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/Misc/scratch_mask_rcnn_R_50_FPN_3x_gn/138602908/metrics.json">metrics</a></td>
|
976 |
+
</tr>
|
977 |
+
<!-- ROW: scratch_mask_rcnn_R_50_FPN_9x_gn -->
|
978 |
+
<tr><td align="left"><a href="configs/Misc/scratch_mask_rcnn_R_50_FPN_9x_gn.yaml">GN (from scratch)</a></td>
|
979 |
+
<td align="center">9x</td>
|
980 |
+
<td align="center">N/A</td>
|
981 |
+
<td align="center">0.061</td>
|
982 |
+
<td align="center">7.2</td>
|
983 |
+
<td align="center">43.7</td>
|
984 |
+
<td align="center">39.6</td>
|
985 |
+
<td align="center">183808979</td>
|
986 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/Misc/scratch_mask_rcnn_R_50_FPN_9x_gn/183808979/model_final_da7b4c.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/Misc/scratch_mask_rcnn_R_50_FPN_9x_gn/183808979/metrics.json">metrics</a></td>
|
987 |
+
</tr>
|
988 |
+
<!-- ROW: scratch_mask_rcnn_R_50_FPN_9x_syncbn -->
|
989 |
+
<tr><td align="left"><a href="configs/Misc/scratch_mask_rcnn_R_50_FPN_9x_syncbn.yaml">SyncBN (from scratch)</a></td>
|
990 |
+
<td align="center">9x</td>
|
991 |
+
<td align="center">N/A</td>
|
992 |
+
<td align="center">0.055</td>
|
993 |
+
<td align="center">7.2</td>
|
994 |
+
<td align="center">43.6</td>
|
995 |
+
<td align="center">39.3</td>
|
996 |
+
<td align="center">184226666</td>
|
997 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/Misc/scratch_mask_rcnn_R_50_FPN_9x_syncbn/184226666/model_final_5ce33e.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/Misc/scratch_mask_rcnn_R_50_FPN_9x_syncbn/184226666/metrics.json">metrics</a></td>
|
998 |
+
</tr>
|
999 |
+
</tbody></table>
|
1000 |
+
|
1001 |
+
|
1002 |
+
A few very large models trained for a long time, for demo purposes. They are trained using multiple machines:
|
1003 |
+
|
1004 |
+
<!--
|
1005 |
+
./gen_html_table.py --config 'Misc/panoptic_*dconv*' 'Misc/cascade_*152*' --name "Panoptic FPN R101" "Mask R-CNN X152" --fields inference_speed mem box_AP mask_AP PQ
|
1006 |
+
# manually add TTA results
|
1007 |
+
-->
|
1008 |
+
|
1009 |
+
|
1010 |
+
<table><tbody>
|
1011 |
+
<!-- START TABLE -->
|
1012 |
+
<!-- TABLE HEADER -->
|
1013 |
+
<th valign="bottom">Name</th>
|
1014 |
+
<th valign="bottom">inference<br/>time<br/>(s/im)</th>
|
1015 |
+
<th valign="bottom">train<br/>mem<br/>(GB)</th>
|
1016 |
+
<th valign="bottom">box<br/>AP</th>
|
1017 |
+
<th valign="bottom">mask<br/>AP</th>
|
1018 |
+
<th valign="bottom">PQ</th>
|
1019 |
+
<th valign="bottom">model id</th>
|
1020 |
+
<th valign="bottom">download</th>
|
1021 |
+
<!-- TABLE BODY -->
|
1022 |
+
<!-- ROW: panoptic_fpn_R_101_dconv_cascade_gn_3x -->
|
1023 |
+
<tr><td align="left"><a href="configs/Misc/panoptic_fpn_R_101_dconv_cascade_gn_3x.yaml">Panoptic FPN R101</a></td>
|
1024 |
+
<td align="center">0.098</td>
|
1025 |
+
<td align="center">11.4</td>
|
1026 |
+
<td align="center">47.4</td>
|
1027 |
+
<td align="center">41.3</td>
|
1028 |
+
<td align="center">46.1</td>
|
1029 |
+
<td align="center">139797668</td>
|
1030 |
+
<td align="center"><a href="https://dl.fbaipublicfiles.com/detectron2/Misc/panoptic_fpn_R_101_dconv_cascade_gn_3x/139797668/model_final_be35db.pkl">model</a> | <a href="https://dl.fbaipublicfiles.com/detectron2/Misc/panoptic_fpn_R_101_dconv_cascade_gn_3x/139797668/metrics.json">metrics</a></td>
|
1031 |
+
</tr>
|
1032 |
+
<!-- ROW: cascade_mask_rcnn_X_152_32x8d_FPN_IN5k_gn_dconv -->
|
1033 |
+
<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>
|
1034 |
+
<td align="center">0.234</td>
|
1035 |
+
<td align="center">15.1</td>
|
1036 |
+
<td align="center">50.2</td>
|
1037 |
+
<td align="center">44.0</td>
|
1038 |
+
<td align="center"></td>
|
1039 |
+
<td align="center">18131413</td>
|
1040 |
+
<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> | <a href="https://dl.fbaipublicfiles.com/detectron2/Misc/cascade_mask_rcnn_X_152_32x8d_FPN_IN5k_gn_dconv/18131413/metrics.json">metrics</a></td>
|
1041 |
+
</tr>
|
1042 |
+
<!-- ROW: TTA cascade_mask_rcnn_X_152_32x8d_FPN_IN5k_gn_dconv -->
|
1043 |
+
<tr><td align="left">above + test-time aug.</td>
|
1044 |
+
<td align="center"></td>
|
1045 |
+
<td align="center"></td>
|
1046 |
+
<td align="center">51.9</td>
|
1047 |
+
<td align="center">45.9</td>
|
1048 |
+
<td align="center"></td>
|
1049 |
+
<td align="center"></td>
|
1050 |
+
<td align="center"></td>
|
1051 |
+
</tr>
|
1052 |
+
</tbody></table>
|
detectron2/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<img src=".github/Detectron2-Logo-Horz.svg" width="300" >
|
2 |
+
|
3 |
+
<a href="https://opensource.facebook.com/support-ukraine">
|
4 |
+
<img src="https://img.shields.io/badge/Support-Ukraine-FFD500?style=flat&labelColor=005BBB" alt="Support Ukraine - Help Provide Humanitarian Aid to Ukraine." />
|
5 |
+
</a>
|
6 |
+
|
7 |
+
Detectron2 is Facebook AI Research's next generation library
|
8 |
+
that provides state-of-the-art detection and segmentation algorithms.
|
9 |
+
It is the successor of
|
10 |
+
[Detectron](https://github.com/facebookresearch/Detectron/)
|
11 |
+
and [maskrcnn-benchmark](https://github.com/facebookresearch/maskrcnn-benchmark/).
|
12 |
+
It supports a number of computer vision research projects and production applications in Facebook.
|
13 |
+
|
14 |
+
<div align="center">
|
15 |
+
<img src="https://user-images.githubusercontent.com/1381301/66535560-d3422200-eace-11e9-9123-5535d469db19.png"/>
|
16 |
+
</div>
|
17 |
+
<br>
|
18 |
+
|
19 |
+
## Learn More about Detectron2
|
20 |
+
|
21 |
+
Explain Like I’m 5: Detectron2 | Using Machine Learning with Detectron2
|
22 |
+
:-------------------------:|:-------------------------:
|
23 |
+
[![Explain Like I’m 5: Detectron2](https://img.youtube.com/vi/1oq1Ye7dFqc/0.jpg)](https://www.youtube.com/watch?v=1oq1Ye7dFqc) | [![Using Machine Learning with Detectron2](https://img.youtube.com/vi/eUSgtfK4ivk/0.jpg)](https://www.youtube.com/watch?v=eUSgtfK4ivk)
|
24 |
+
|
25 |
+
## What's New
|
26 |
+
* Includes new capabilities such as panoptic segmentation, Densepose, Cascade R-CNN, rotated bounding boxes, PointRend,
|
27 |
+
DeepLab, ViTDet, MViTv2 etc.
|
28 |
+
* Used as a library to support building [research projects](projects/) on top of it.
|
29 |
+
* Models can be exported to TorchScript format or Caffe2 format for deployment.
|
30 |
+
* It [trains much faster](https://detectron2.readthedocs.io/notes/benchmarks.html).
|
31 |
+
|
32 |
+
See our [blog post](https://ai.facebook.com/blog/-detectron2-a-pytorch-based-modular-object-detection-library-/)
|
33 |
+
to see more demos and learn about detectron2.
|
34 |
+
|
35 |
+
## Installation
|
36 |
+
|
37 |
+
See [installation instructions](https://detectron2.readthedocs.io/tutorials/install.html).
|
38 |
+
|
39 |
+
## Getting Started
|
40 |
+
|
41 |
+
See [Getting Started with Detectron2](https://detectron2.readthedocs.io/tutorials/getting_started.html),
|
42 |
+
and the [Colab Notebook](https://colab.research.google.com/drive/16jcaJoc6bCFAQ96jDe2HwtXj7BMD_-m5)
|
43 |
+
to learn about basic usage.
|
44 |
+
|
45 |
+
Learn more at our [documentation](https://detectron2.readthedocs.org).
|
46 |
+
And see [projects/](projects/) for some projects that are built on top of detectron2.
|
47 |
+
|
48 |
+
## Model Zoo and Baselines
|
49 |
+
|
50 |
+
We provide a large set of baseline results and trained models available for download in the [Detectron2 Model Zoo](MODEL_ZOO.md).
|
51 |
+
|
52 |
+
## License
|
53 |
+
|
54 |
+
Detectron2 is released under the [Apache 2.0 license](LICENSE).
|
55 |
+
|
56 |
+
## Citing Detectron2
|
57 |
+
|
58 |
+
If you use Detectron2 in your research or wish to refer to the baseline results published in the [Model Zoo](MODEL_ZOO.md), please use the following BibTeX entry.
|
59 |
+
|
60 |
+
```BibTeX
|
61 |
+
@misc{wu2019detectron2,
|
62 |
+
author = {Yuxin Wu and Alexander Kirillov and Francisco Massa and
|
63 |
+
Wan-Yen Lo and Ross Girshick},
|
64 |
+
title = {Detectron2},
|
65 |
+
howpublished = {\url{https://github.com/facebookresearch/detectron2}},
|
66 |
+
year = {2019}
|
67 |
+
}
|
68 |
+
```
|
detectron2/__init__.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
2 |
+
|
3 |
+
from .utils.env import setup_environment
|
4 |
+
|
5 |
+
setup_environment()
|
6 |
+
|
7 |
+
|
8 |
+
# This line will be programatically read/write by setup.py.
|
9 |
+
# Leave them at the bottom of this file and don't touch them.
|
10 |
+
__version__ = "0.6"
|
detectron2/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (232 Bytes). View file
|
|
detectron2/__pycache__/__init__.cpython-311.pyc
ADDED
Binary file (327 Bytes). View file
|
|
detectron2/checkpoint/__init__.py
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
3 |
+
# File:
|
4 |
+
|
5 |
+
|
6 |
+
from . import catalog as _UNUSED # register the handler
|
7 |
+
from .detection_checkpoint import DetectionCheckpointer
|
8 |
+
from fvcore.common.checkpoint import Checkpointer, PeriodicCheckpointer
|
9 |
+
|
10 |
+
__all__ = ["Checkpointer", "PeriodicCheckpointer", "DetectionCheckpointer"]
|
detectron2/checkpoint/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (400 Bytes). View file
|
|
detectron2/checkpoint/__pycache__/__init__.cpython-311.pyc
ADDED
Binary file (510 Bytes). View file
|
|
detectron2/checkpoint/__pycache__/c2_model_loading.cpython-310.pyc
ADDED
Binary file (15.4 kB). View file
|
|
detectron2/checkpoint/__pycache__/c2_model_loading.cpython-311.pyc
ADDED
Binary file (30 kB). View file
|
|
detectron2/checkpoint/__pycache__/catalog.cpython-310.pyc
ADDED
Binary file (4.83 kB). View file
|
|
detectron2/checkpoint/__pycache__/catalog.cpython-311.pyc
ADDED
Binary file (6.57 kB). View file
|
|
detectron2/checkpoint/__pycache__/detection_checkpoint.cpython-310.pyc
ADDED
Binary file (4.58 kB). View file
|
|
detectron2/checkpoint/__pycache__/detection_checkpoint.cpython-311.pyc
ADDED
Binary file (8.57 kB). View file
|
|
detectron2/checkpoint/c2_model_loading.py
ADDED
@@ -0,0 +1,412 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
2 |
+
import copy
|
3 |
+
import logging
|
4 |
+
import re
|
5 |
+
from typing import Dict, List
|
6 |
+
import torch
|
7 |
+
from tabulate import tabulate
|
8 |
+
|
9 |
+
|
10 |
+
def convert_basic_c2_names(original_keys):
|
11 |
+
"""
|
12 |
+
Apply some basic name conversion to names in C2 weights.
|
13 |
+
It only deals with typical backbone models.
|
14 |
+
|
15 |
+
Args:
|
16 |
+
original_keys (list[str]):
|
17 |
+
Returns:
|
18 |
+
list[str]: The same number of strings matching those in original_keys.
|
19 |
+
"""
|
20 |
+
layer_keys = copy.deepcopy(original_keys)
|
21 |
+
layer_keys = [
|
22 |
+
{"pred_b": "linear_b", "pred_w": "linear_w"}.get(k, k) for k in layer_keys
|
23 |
+
] # some hard-coded mappings
|
24 |
+
|
25 |
+
layer_keys = [k.replace("_", ".") for k in layer_keys]
|
26 |
+
layer_keys = [re.sub("\\.b$", ".bias", k) for k in layer_keys]
|
27 |
+
layer_keys = [re.sub("\\.w$", ".weight", k) for k in layer_keys]
|
28 |
+
# Uniform both bn and gn names to "norm"
|
29 |
+
layer_keys = [re.sub("bn\\.s$", "norm.weight", k) for k in layer_keys]
|
30 |
+
layer_keys = [re.sub("bn\\.bias$", "norm.bias", k) for k in layer_keys]
|
31 |
+
layer_keys = [re.sub("bn\\.rm", "norm.running_mean", k) for k in layer_keys]
|
32 |
+
layer_keys = [re.sub("bn\\.running.mean$", "norm.running_mean", k) for k in layer_keys]
|
33 |
+
layer_keys = [re.sub("bn\\.riv$", "norm.running_var", k) for k in layer_keys]
|
34 |
+
layer_keys = [re.sub("bn\\.running.var$", "norm.running_var", k) for k in layer_keys]
|
35 |
+
layer_keys = [re.sub("bn\\.gamma$", "norm.weight", k) for k in layer_keys]
|
36 |
+
layer_keys = [re.sub("bn\\.beta$", "norm.bias", k) for k in layer_keys]
|
37 |
+
layer_keys = [re.sub("gn\\.s$", "norm.weight", k) for k in layer_keys]
|
38 |
+
layer_keys = [re.sub("gn\\.bias$", "norm.bias", k) for k in layer_keys]
|
39 |
+
|
40 |
+
# stem
|
41 |
+
layer_keys = [re.sub("^res\\.conv1\\.norm\\.", "conv1.norm.", k) for k in layer_keys]
|
42 |
+
# to avoid mis-matching with "conv1" in other components (e.g. detection head)
|
43 |
+
layer_keys = [re.sub("^conv1\\.", "stem.conv1.", k) for k in layer_keys]
|
44 |
+
|
45 |
+
# layer1-4 is used by torchvision, however we follow the C2 naming strategy (res2-5)
|
46 |
+
# layer_keys = [re.sub("^res2.", "layer1.", k) for k in layer_keys]
|
47 |
+
# layer_keys = [re.sub("^res3.", "layer2.", k) for k in layer_keys]
|
48 |
+
# layer_keys = [re.sub("^res4.", "layer3.", k) for k in layer_keys]
|
49 |
+
# layer_keys = [re.sub("^res5.", "layer4.", k) for k in layer_keys]
|
50 |
+
|
51 |
+
# blocks
|
52 |
+
layer_keys = [k.replace(".branch1.", ".shortcut.") for k in layer_keys]
|
53 |
+
layer_keys = [k.replace(".branch2a.", ".conv1.") for k in layer_keys]
|
54 |
+
layer_keys = [k.replace(".branch2b.", ".conv2.") for k in layer_keys]
|
55 |
+
layer_keys = [k.replace(".branch2c.", ".conv3.") for k in layer_keys]
|
56 |
+
|
57 |
+
# DensePose substitutions
|
58 |
+
layer_keys = [re.sub("^body.conv.fcn", "body_conv_fcn", k) for k in layer_keys]
|
59 |
+
layer_keys = [k.replace("AnnIndex.lowres", "ann_index_lowres") for k in layer_keys]
|
60 |
+
layer_keys = [k.replace("Index.UV.lowres", "index_uv_lowres") for k in layer_keys]
|
61 |
+
layer_keys = [k.replace("U.lowres", "u_lowres") for k in layer_keys]
|
62 |
+
layer_keys = [k.replace("V.lowres", "v_lowres") for k in layer_keys]
|
63 |
+
return layer_keys
|
64 |
+
|
65 |
+
|
66 |
+
def convert_c2_detectron_names(weights):
|
67 |
+
"""
|
68 |
+
Map Caffe2 Detectron weight names to Detectron2 names.
|
69 |
+
|
70 |
+
Args:
|
71 |
+
weights (dict): name -> tensor
|
72 |
+
|
73 |
+
Returns:
|
74 |
+
dict: detectron2 names -> tensor
|
75 |
+
dict: detectron2 names -> C2 names
|
76 |
+
"""
|
77 |
+
logger = logging.getLogger(__name__)
|
78 |
+
logger.info("Renaming Caffe2 weights ......")
|
79 |
+
original_keys = sorted(weights.keys())
|
80 |
+
layer_keys = copy.deepcopy(original_keys)
|
81 |
+
|
82 |
+
layer_keys = convert_basic_c2_names(layer_keys)
|
83 |
+
|
84 |
+
# --------------------------------------------------------------------------
|
85 |
+
# RPN hidden representation conv
|
86 |
+
# --------------------------------------------------------------------------
|
87 |
+
# FPN case
|
88 |
+
# In the C2 model, the RPN hidden layer conv is defined for FPN level 2 and then
|
89 |
+
# shared for all other levels, hence the appearance of "fpn2"
|
90 |
+
layer_keys = [
|
91 |
+
k.replace("conv.rpn.fpn2", "proposal_generator.rpn_head.conv") for k in layer_keys
|
92 |
+
]
|
93 |
+
# Non-FPN case
|
94 |
+
layer_keys = [k.replace("conv.rpn", "proposal_generator.rpn_head.conv") for k in layer_keys]
|
95 |
+
|
96 |
+
# --------------------------------------------------------------------------
|
97 |
+
# RPN box transformation conv
|
98 |
+
# --------------------------------------------------------------------------
|
99 |
+
# FPN case (see note above about "fpn2")
|
100 |
+
layer_keys = [
|
101 |
+
k.replace("rpn.bbox.pred.fpn2", "proposal_generator.rpn_head.anchor_deltas")
|
102 |
+
for k in layer_keys
|
103 |
+
]
|
104 |
+
layer_keys = [
|
105 |
+
k.replace("rpn.cls.logits.fpn2", "proposal_generator.rpn_head.objectness_logits")
|
106 |
+
for k in layer_keys
|
107 |
+
]
|
108 |
+
# Non-FPN case
|
109 |
+
layer_keys = [
|
110 |
+
k.replace("rpn.bbox.pred", "proposal_generator.rpn_head.anchor_deltas") for k in layer_keys
|
111 |
+
]
|
112 |
+
layer_keys = [
|
113 |
+
k.replace("rpn.cls.logits", "proposal_generator.rpn_head.objectness_logits")
|
114 |
+
for k in layer_keys
|
115 |
+
]
|
116 |
+
|
117 |
+
# --------------------------------------------------------------------------
|
118 |
+
# Fast R-CNN box head
|
119 |
+
# --------------------------------------------------------------------------
|
120 |
+
layer_keys = [re.sub("^bbox\\.pred", "bbox_pred", k) for k in layer_keys]
|
121 |
+
layer_keys = [re.sub("^cls\\.score", "cls_score", k) for k in layer_keys]
|
122 |
+
layer_keys = [re.sub("^fc6\\.", "box_head.fc1.", k) for k in layer_keys]
|
123 |
+
layer_keys = [re.sub("^fc7\\.", "box_head.fc2.", k) for k in layer_keys]
|
124 |
+
# 4conv1fc head tensor names: head_conv1_w, head_conv1_gn_s
|
125 |
+
layer_keys = [re.sub("^head\\.conv", "box_head.conv", k) for k in layer_keys]
|
126 |
+
|
127 |
+
# --------------------------------------------------------------------------
|
128 |
+
# FPN lateral and output convolutions
|
129 |
+
# --------------------------------------------------------------------------
|
130 |
+
def fpn_map(name):
|
131 |
+
"""
|
132 |
+
Look for keys with the following patterns:
|
133 |
+
1) Starts with "fpn.inner."
|
134 |
+
Example: "fpn.inner.res2.2.sum.lateral.weight"
|
135 |
+
Meaning: These are lateral pathway convolutions
|
136 |
+
2) Starts with "fpn.res"
|
137 |
+
Example: "fpn.res2.2.sum.weight"
|
138 |
+
Meaning: These are FPN output convolutions
|
139 |
+
"""
|
140 |
+
splits = name.split(".")
|
141 |
+
norm = ".norm" if "norm" in splits else ""
|
142 |
+
if name.startswith("fpn.inner."):
|
143 |
+
# splits example: ['fpn', 'inner', 'res2', '2', 'sum', 'lateral', 'weight']
|
144 |
+
stage = int(splits[2][len("res") :])
|
145 |
+
return "fpn_lateral{}{}.{}".format(stage, norm, splits[-1])
|
146 |
+
elif name.startswith("fpn.res"):
|
147 |
+
# splits example: ['fpn', 'res2', '2', 'sum', 'weight']
|
148 |
+
stage = int(splits[1][len("res") :])
|
149 |
+
return "fpn_output{}{}.{}".format(stage, norm, splits[-1])
|
150 |
+
return name
|
151 |
+
|
152 |
+
layer_keys = [fpn_map(k) for k in layer_keys]
|
153 |
+
|
154 |
+
# --------------------------------------------------------------------------
|
155 |
+
# Mask R-CNN mask head
|
156 |
+
# --------------------------------------------------------------------------
|
157 |
+
# roi_heads.StandardROIHeads case
|
158 |
+
layer_keys = [k.replace(".[mask].fcn", "mask_head.mask_fcn") for k in layer_keys]
|
159 |
+
layer_keys = [re.sub("^\\.mask\\.fcn", "mask_head.mask_fcn", k) for k in layer_keys]
|
160 |
+
layer_keys = [k.replace("mask.fcn.logits", "mask_head.predictor") for k in layer_keys]
|
161 |
+
# roi_heads.Res5ROIHeads case
|
162 |
+
layer_keys = [k.replace("conv5.mask", "mask_head.deconv") for k in layer_keys]
|
163 |
+
|
164 |
+
# --------------------------------------------------------------------------
|
165 |
+
# Keypoint R-CNN head
|
166 |
+
# --------------------------------------------------------------------------
|
167 |
+
# interestingly, the keypoint head convs have blob names that are simply "conv_fcnX"
|
168 |
+
layer_keys = [k.replace("conv.fcn", "roi_heads.keypoint_head.conv_fcn") for k in layer_keys]
|
169 |
+
layer_keys = [
|
170 |
+
k.replace("kps.score.lowres", "roi_heads.keypoint_head.score_lowres") for k in layer_keys
|
171 |
+
]
|
172 |
+
layer_keys = [k.replace("kps.score.", "roi_heads.keypoint_head.score.") for k in layer_keys]
|
173 |
+
|
174 |
+
# --------------------------------------------------------------------------
|
175 |
+
# Done with replacements
|
176 |
+
# --------------------------------------------------------------------------
|
177 |
+
assert len(set(layer_keys)) == len(layer_keys)
|
178 |
+
assert len(original_keys) == len(layer_keys)
|
179 |
+
|
180 |
+
new_weights = {}
|
181 |
+
new_keys_to_original_keys = {}
|
182 |
+
for orig, renamed in zip(original_keys, layer_keys):
|
183 |
+
new_keys_to_original_keys[renamed] = orig
|
184 |
+
if renamed.startswith("bbox_pred.") or renamed.startswith("mask_head.predictor."):
|
185 |
+
# remove the meaningless prediction weight for background class
|
186 |
+
new_start_idx = 4 if renamed.startswith("bbox_pred.") else 1
|
187 |
+
new_weights[renamed] = weights[orig][new_start_idx:]
|
188 |
+
logger.info(
|
189 |
+
"Remove prediction weight for background class in {}. The shape changes from "
|
190 |
+
"{} to {}.".format(
|
191 |
+
renamed, tuple(weights[orig].shape), tuple(new_weights[renamed].shape)
|
192 |
+
)
|
193 |
+
)
|
194 |
+
elif renamed.startswith("cls_score."):
|
195 |
+
# move weights of bg class from original index 0 to last index
|
196 |
+
logger.info(
|
197 |
+
"Move classification weights for background class in {} from index 0 to "
|
198 |
+
"index {}.".format(renamed, weights[orig].shape[0] - 1)
|
199 |
+
)
|
200 |
+
new_weights[renamed] = torch.cat([weights[orig][1:], weights[orig][:1]])
|
201 |
+
else:
|
202 |
+
new_weights[renamed] = weights[orig]
|
203 |
+
|
204 |
+
return new_weights, new_keys_to_original_keys
|
205 |
+
|
206 |
+
|
207 |
+
# Note the current matching is not symmetric.
|
208 |
+
# it assumes model_state_dict will have longer names.
|
209 |
+
def align_and_update_state_dicts(model_state_dict, ckpt_state_dict, c2_conversion=True):
|
210 |
+
"""
|
211 |
+
Match names between the two state-dict, and returns a new chkpt_state_dict with names
|
212 |
+
converted to match model_state_dict with heuristics. The returned dict can be later
|
213 |
+
loaded with fvcore checkpointer.
|
214 |
+
If `c2_conversion==True`, `ckpt_state_dict` is assumed to be a Caffe2
|
215 |
+
model and will be renamed at first.
|
216 |
+
|
217 |
+
Strategy: suppose that the models that we will create will have prefixes appended
|
218 |
+
to each of its keys, for example due to an extra level of nesting that the original
|
219 |
+
pre-trained weights from ImageNet won't contain. For example, model.state_dict()
|
220 |
+
might return backbone[0].body.res2.conv1.weight, while the pre-trained model contains
|
221 |
+
res2.conv1.weight. We thus want to match both parameters together.
|
222 |
+
For that, we look for each model weight, look among all loaded keys if there is one
|
223 |
+
that is a suffix of the current weight name, and use it if that's the case.
|
224 |
+
If multiple matches exist, take the one with longest size
|
225 |
+
of the corresponding name. For example, for the same model as before, the pretrained
|
226 |
+
weight file can contain both res2.conv1.weight, as well as conv1.weight. In this case,
|
227 |
+
we want to match backbone[0].body.conv1.weight to conv1.weight, and
|
228 |
+
backbone[0].body.res2.conv1.weight to res2.conv1.weight.
|
229 |
+
"""
|
230 |
+
model_keys = sorted(model_state_dict.keys())
|
231 |
+
if c2_conversion:
|
232 |
+
ckpt_state_dict, original_keys = convert_c2_detectron_names(ckpt_state_dict)
|
233 |
+
# original_keys: the name in the original dict (before renaming)
|
234 |
+
else:
|
235 |
+
original_keys = {x: x for x in ckpt_state_dict.keys()}
|
236 |
+
ckpt_keys = sorted(ckpt_state_dict.keys())
|
237 |
+
|
238 |
+
def match(a, b):
|
239 |
+
# Matched ckpt_key should be a complete (starts with '.') suffix.
|
240 |
+
# For example, roi_heads.mesh_head.whatever_conv1 does not match conv1,
|
241 |
+
# but matches whatever_conv1 or mesh_head.whatever_conv1.
|
242 |
+
return a == b or a.endswith("." + b)
|
243 |
+
|
244 |
+
# get a matrix of string matches, where each (i, j) entry correspond to the size of the
|
245 |
+
# ckpt_key string, if it matches
|
246 |
+
match_matrix = [len(j) if match(i, j) else 0 for i in model_keys for j in ckpt_keys]
|
247 |
+
match_matrix = torch.as_tensor(match_matrix).view(len(model_keys), len(ckpt_keys))
|
248 |
+
# use the matched one with longest size in case of multiple matches
|
249 |
+
max_match_size, idxs = match_matrix.max(1)
|
250 |
+
# remove indices that correspond to no-match
|
251 |
+
idxs[max_match_size == 0] = -1
|
252 |
+
|
253 |
+
logger = logging.getLogger(__name__)
|
254 |
+
# matched_pairs (matched checkpoint key --> matched model key)
|
255 |
+
matched_keys = {}
|
256 |
+
result_state_dict = {}
|
257 |
+
for idx_model, idx_ckpt in enumerate(idxs.tolist()):
|
258 |
+
if idx_ckpt == -1:
|
259 |
+
continue
|
260 |
+
key_model = model_keys[idx_model]
|
261 |
+
key_ckpt = ckpt_keys[idx_ckpt]
|
262 |
+
value_ckpt = ckpt_state_dict[key_ckpt]
|
263 |
+
shape_in_model = model_state_dict[key_model].shape
|
264 |
+
|
265 |
+
if shape_in_model != value_ckpt.shape:
|
266 |
+
logger.warning(
|
267 |
+
"Shape of {} in checkpoint is {}, while shape of {} in model is {}.".format(
|
268 |
+
key_ckpt, value_ckpt.shape, key_model, shape_in_model
|
269 |
+
)
|
270 |
+
)
|
271 |
+
logger.warning(
|
272 |
+
"{} will not be loaded. Please double check and see if this is desired.".format(
|
273 |
+
key_ckpt
|
274 |
+
)
|
275 |
+
)
|
276 |
+
continue
|
277 |
+
|
278 |
+
assert key_model not in result_state_dict
|
279 |
+
result_state_dict[key_model] = value_ckpt
|
280 |
+
if key_ckpt in matched_keys: # already added to matched_keys
|
281 |
+
logger.error(
|
282 |
+
"Ambiguity found for {} in checkpoint!"
|
283 |
+
"It matches at least two keys in the model ({} and {}).".format(
|
284 |
+
key_ckpt, key_model, matched_keys[key_ckpt]
|
285 |
+
)
|
286 |
+
)
|
287 |
+
raise ValueError("Cannot match one checkpoint key to multiple keys in the model.")
|
288 |
+
|
289 |
+
matched_keys[key_ckpt] = key_model
|
290 |
+
|
291 |
+
# logging:
|
292 |
+
matched_model_keys = sorted(matched_keys.values())
|
293 |
+
if len(matched_model_keys) == 0:
|
294 |
+
logger.warning("No weights in checkpoint matched with model.")
|
295 |
+
return ckpt_state_dict
|
296 |
+
common_prefix = _longest_common_prefix(matched_model_keys)
|
297 |
+
rev_matched_keys = {v: k for k, v in matched_keys.items()}
|
298 |
+
original_keys = {k: original_keys[rev_matched_keys[k]] for k in matched_model_keys}
|
299 |
+
|
300 |
+
model_key_groups = _group_keys_by_module(matched_model_keys, original_keys)
|
301 |
+
table = []
|
302 |
+
memo = set()
|
303 |
+
for key_model in matched_model_keys:
|
304 |
+
if key_model in memo:
|
305 |
+
continue
|
306 |
+
if key_model in model_key_groups:
|
307 |
+
group = model_key_groups[key_model]
|
308 |
+
memo |= set(group)
|
309 |
+
shapes = [tuple(model_state_dict[k].shape) for k in group]
|
310 |
+
table.append(
|
311 |
+
(
|
312 |
+
_longest_common_prefix([k[len(common_prefix) :] for k in group]) + "*",
|
313 |
+
_group_str([original_keys[k] for k in group]),
|
314 |
+
" ".join([str(x).replace(" ", "") for x in shapes]),
|
315 |
+
)
|
316 |
+
)
|
317 |
+
else:
|
318 |
+
key_checkpoint = original_keys[key_model]
|
319 |
+
shape = str(tuple(model_state_dict[key_model].shape))
|
320 |
+
table.append((key_model[len(common_prefix) :], key_checkpoint, shape))
|
321 |
+
table_str = tabulate(
|
322 |
+
table, tablefmt="pipe", headers=["Names in Model", "Names in Checkpoint", "Shapes"]
|
323 |
+
)
|
324 |
+
logger.info(
|
325 |
+
"Following weights matched with "
|
326 |
+
+ (f"submodule {common_prefix[:-1]}" if common_prefix else "model")
|
327 |
+
+ ":\n"
|
328 |
+
+ table_str
|
329 |
+
)
|
330 |
+
|
331 |
+
unmatched_ckpt_keys = [k for k in ckpt_keys if k not in set(matched_keys.keys())]
|
332 |
+
for k in unmatched_ckpt_keys:
|
333 |
+
result_state_dict[k] = ckpt_state_dict[k]
|
334 |
+
return result_state_dict
|
335 |
+
|
336 |
+
|
337 |
+
def _group_keys_by_module(keys: List[str], original_names: Dict[str, str]):
|
338 |
+
"""
|
339 |
+
Params in the same submodule are grouped together.
|
340 |
+
|
341 |
+
Args:
|
342 |
+
keys: names of all parameters
|
343 |
+
original_names: mapping from parameter name to their name in the checkpoint
|
344 |
+
|
345 |
+
Returns:
|
346 |
+
dict[name -> all other names in the same group]
|
347 |
+
"""
|
348 |
+
|
349 |
+
def _submodule_name(key):
|
350 |
+
pos = key.rfind(".")
|
351 |
+
if pos < 0:
|
352 |
+
return None
|
353 |
+
prefix = key[: pos + 1]
|
354 |
+
return prefix
|
355 |
+
|
356 |
+
all_submodules = [_submodule_name(k) for k in keys]
|
357 |
+
all_submodules = [x for x in all_submodules if x]
|
358 |
+
all_submodules = sorted(all_submodules, key=len)
|
359 |
+
|
360 |
+
ret = {}
|
361 |
+
for prefix in all_submodules:
|
362 |
+
group = [k for k in keys if k.startswith(prefix)]
|
363 |
+
if len(group) <= 1:
|
364 |
+
continue
|
365 |
+
original_name_lcp = _longest_common_prefix_str([original_names[k] for k in group])
|
366 |
+
if len(original_name_lcp) == 0:
|
367 |
+
# don't group weights if original names don't share prefix
|
368 |
+
continue
|
369 |
+
|
370 |
+
for k in group:
|
371 |
+
if k in ret:
|
372 |
+
continue
|
373 |
+
ret[k] = group
|
374 |
+
return ret
|
375 |
+
|
376 |
+
|
377 |
+
def _longest_common_prefix(names: List[str]) -> str:
|
378 |
+
"""
|
379 |
+
["abc.zfg", "abc.zef"] -> "abc."
|
380 |
+
"""
|
381 |
+
names = [n.split(".") for n in names]
|
382 |
+
m1, m2 = min(names), max(names)
|
383 |
+
ret = [a for a, b in zip(m1, m2) if a == b]
|
384 |
+
ret = ".".join(ret) + "." if len(ret) else ""
|
385 |
+
return ret
|
386 |
+
|
387 |
+
|
388 |
+
def _longest_common_prefix_str(names: List[str]) -> str:
|
389 |
+
m1, m2 = min(names), max(names)
|
390 |
+
lcp = []
|
391 |
+
for a, b in zip(m1, m2):
|
392 |
+
if a == b:
|
393 |
+
lcp.append(a)
|
394 |
+
else:
|
395 |
+
break
|
396 |
+
lcp = "".join(lcp)
|
397 |
+
return lcp
|
398 |
+
|
399 |
+
|
400 |
+
def _group_str(names: List[str]) -> str:
|
401 |
+
"""
|
402 |
+
Turn "common1", "common2", "common3" into "common{1,2,3}"
|
403 |
+
"""
|
404 |
+
lcp = _longest_common_prefix_str(names)
|
405 |
+
rest = [x[len(lcp) :] for x in names]
|
406 |
+
rest = "{" + ",".join(rest) + "}"
|
407 |
+
ret = lcp + rest
|
408 |
+
|
409 |
+
# add some simplification for BN specifically
|
410 |
+
ret = ret.replace("bn_{beta,running_mean,running_var,gamma}", "bn_*")
|
411 |
+
ret = ret.replace("bn_beta,bn_running_mean,bn_running_var,bn_gamma", "bn_*")
|
412 |
+
return ret
|
detectron2/checkpoint/catalog.py
ADDED
@@ -0,0 +1,115 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
2 |
+
import logging
|
3 |
+
|
4 |
+
from detectron2.utils.file_io import PathHandler, PathManager
|
5 |
+
|
6 |
+
|
7 |
+
class ModelCatalog(object):
|
8 |
+
"""
|
9 |
+
Store mappings from names to third-party models.
|
10 |
+
"""
|
11 |
+
|
12 |
+
S3_C2_DETECTRON_PREFIX = "https://dl.fbaipublicfiles.com/detectron"
|
13 |
+
|
14 |
+
# MSRA models have STRIDE_IN_1X1=True. False otherwise.
|
15 |
+
# NOTE: all BN models here have fused BN into an affine layer.
|
16 |
+
# As a result, you should only load them to a model with "FrozenBN".
|
17 |
+
# Loading them to a model with regular BN or SyncBN is wrong.
|
18 |
+
# Even when loaded to FrozenBN, it is still different from affine by an epsilon,
|
19 |
+
# which should be negligible for training.
|
20 |
+
# NOTE: all models here uses PIXEL_STD=[1,1,1]
|
21 |
+
# NOTE: Most of the BN models here are no longer used. We use the
|
22 |
+
# re-converted pre-trained models under detectron2 model zoo instead.
|
23 |
+
C2_IMAGENET_MODELS = {
|
24 |
+
"MSRA/R-50": "ImageNetPretrained/MSRA/R-50.pkl",
|
25 |
+
"MSRA/R-101": "ImageNetPretrained/MSRA/R-101.pkl",
|
26 |
+
"FAIR/R-50-GN": "ImageNetPretrained/47261647/R-50-GN.pkl",
|
27 |
+
"FAIR/R-101-GN": "ImageNetPretrained/47592356/R-101-GN.pkl",
|
28 |
+
"FAIR/X-101-32x8d": "ImageNetPretrained/20171220/X-101-32x8d.pkl",
|
29 |
+
"FAIR/X-101-64x4d": "ImageNetPretrained/FBResNeXt/X-101-64x4d.pkl",
|
30 |
+
"FAIR/X-152-32x8d-IN5k": "ImageNetPretrained/25093814/X-152-32x8d-IN5k.pkl",
|
31 |
+
}
|
32 |
+
|
33 |
+
C2_DETECTRON_PATH_FORMAT = (
|
34 |
+
"{prefix}/{url}/output/train/{dataset}/{type}/model_final.pkl" # noqa B950
|
35 |
+
)
|
36 |
+
|
37 |
+
C2_DATASET_COCO = "coco_2014_train%3Acoco_2014_valminusminival"
|
38 |
+
C2_DATASET_COCO_KEYPOINTS = "keypoints_coco_2014_train%3Akeypoints_coco_2014_valminusminival"
|
39 |
+
|
40 |
+
# format: {model_name} -> part of the url
|
41 |
+
C2_DETECTRON_MODELS = {
|
42 |
+
"35857197/e2e_faster_rcnn_R-50-C4_1x": "35857197/12_2017_baselines/e2e_faster_rcnn_R-50-C4_1x.yaml.01_33_49.iAX0mXvW", # noqa B950
|
43 |
+
"35857345/e2e_faster_rcnn_R-50-FPN_1x": "35857345/12_2017_baselines/e2e_faster_rcnn_R-50-FPN_1x.yaml.01_36_30.cUF7QR7I", # noqa B950
|
44 |
+
"35857890/e2e_faster_rcnn_R-101-FPN_1x": "35857890/12_2017_baselines/e2e_faster_rcnn_R-101-FPN_1x.yaml.01_38_50.sNxI7sX7", # noqa B950
|
45 |
+
"36761737/e2e_faster_rcnn_X-101-32x8d-FPN_1x": "36761737/12_2017_baselines/e2e_faster_rcnn_X-101-32x8d-FPN_1x.yaml.06_31_39.5MIHi1fZ", # noqa B950
|
46 |
+
"35858791/e2e_mask_rcnn_R-50-C4_1x": "35858791/12_2017_baselines/e2e_mask_rcnn_R-50-C4_1x.yaml.01_45_57.ZgkA7hPB", # noqa B950
|
47 |
+
"35858933/e2e_mask_rcnn_R-50-FPN_1x": "35858933/12_2017_baselines/e2e_mask_rcnn_R-50-FPN_1x.yaml.01_48_14.DzEQe4wC", # noqa B950
|
48 |
+
"35861795/e2e_mask_rcnn_R-101-FPN_1x": "35861795/12_2017_baselines/e2e_mask_rcnn_R-101-FPN_1x.yaml.02_31_37.KqyEK4tT", # noqa B950
|
49 |
+
"36761843/e2e_mask_rcnn_X-101-32x8d-FPN_1x": "36761843/12_2017_baselines/e2e_mask_rcnn_X-101-32x8d-FPN_1x.yaml.06_35_59.RZotkLKI", # noqa B950
|
50 |
+
"48616381/e2e_mask_rcnn_R-50-FPN_2x_gn": "GN/48616381/04_2018_gn_baselines/e2e_mask_rcnn_R-50-FPN_2x_gn_0416.13_23_38.bTlTI97Q", # noqa B950
|
51 |
+
"37697547/e2e_keypoint_rcnn_R-50-FPN_1x": "37697547/12_2017_baselines/e2e_keypoint_rcnn_R-50-FPN_1x.yaml.08_42_54.kdzV35ao", # noqa B950
|
52 |
+
"35998355/rpn_R-50-C4_1x": "35998355/12_2017_baselines/rpn_R-50-C4_1x.yaml.08_00_43.njH5oD9L", # noqa B950
|
53 |
+
"35998814/rpn_R-50-FPN_1x": "35998814/12_2017_baselines/rpn_R-50-FPN_1x.yaml.08_06_03.Axg0r179", # noqa B950
|
54 |
+
"36225147/fast_R-50-FPN_1x": "36225147/12_2017_baselines/fast_rcnn_R-50-FPN_1x.yaml.08_39_09.L3obSdQ2", # noqa B950
|
55 |
+
}
|
56 |
+
|
57 |
+
@staticmethod
|
58 |
+
def get(name):
|
59 |
+
if name.startswith("Caffe2Detectron/COCO"):
|
60 |
+
return ModelCatalog._get_c2_detectron_baseline(name)
|
61 |
+
if name.startswith("ImageNetPretrained/"):
|
62 |
+
return ModelCatalog._get_c2_imagenet_pretrained(name)
|
63 |
+
raise RuntimeError("model not present in the catalog: {}".format(name))
|
64 |
+
|
65 |
+
@staticmethod
|
66 |
+
def _get_c2_imagenet_pretrained(name):
|
67 |
+
prefix = ModelCatalog.S3_C2_DETECTRON_PREFIX
|
68 |
+
name = name[len("ImageNetPretrained/") :]
|
69 |
+
name = ModelCatalog.C2_IMAGENET_MODELS[name]
|
70 |
+
url = "/".join([prefix, name])
|
71 |
+
return url
|
72 |
+
|
73 |
+
@staticmethod
|
74 |
+
def _get_c2_detectron_baseline(name):
|
75 |
+
name = name[len("Caffe2Detectron/COCO/") :]
|
76 |
+
url = ModelCatalog.C2_DETECTRON_MODELS[name]
|
77 |
+
if "keypoint_rcnn" in name:
|
78 |
+
dataset = ModelCatalog.C2_DATASET_COCO_KEYPOINTS
|
79 |
+
else:
|
80 |
+
dataset = ModelCatalog.C2_DATASET_COCO
|
81 |
+
|
82 |
+
if "35998355/rpn_R-50-C4_1x" in name:
|
83 |
+
# this one model is somehow different from others ..
|
84 |
+
type = "rpn"
|
85 |
+
else:
|
86 |
+
type = "generalized_rcnn"
|
87 |
+
|
88 |
+
# Detectron C2 models are stored in the structure defined in `C2_DETECTRON_PATH_FORMAT`.
|
89 |
+
url = ModelCatalog.C2_DETECTRON_PATH_FORMAT.format(
|
90 |
+
prefix=ModelCatalog.S3_C2_DETECTRON_PREFIX, url=url, type=type, dataset=dataset
|
91 |
+
)
|
92 |
+
return url
|
93 |
+
|
94 |
+
|
95 |
+
class ModelCatalogHandler(PathHandler):
|
96 |
+
"""
|
97 |
+
Resolve URL like catalog://.
|
98 |
+
"""
|
99 |
+
|
100 |
+
PREFIX = "catalog://"
|
101 |
+
|
102 |
+
def _get_supported_prefixes(self):
|
103 |
+
return [self.PREFIX]
|
104 |
+
|
105 |
+
def _get_local_path(self, path, **kwargs):
|
106 |
+
logger = logging.getLogger(__name__)
|
107 |
+
catalog_path = ModelCatalog.get(path[len(self.PREFIX) :])
|
108 |
+
logger.info("Catalog entry {} points to {}".format(path, catalog_path))
|
109 |
+
return PathManager.get_local_path(catalog_path, **kwargs)
|
110 |
+
|
111 |
+
def _open(self, path, mode="r", **kwargs):
|
112 |
+
return PathManager.open(self._get_local_path(path), mode, **kwargs)
|
113 |
+
|
114 |
+
|
115 |
+
PathManager.register_handler(ModelCatalogHandler())
|
detectron2/checkpoint/detection_checkpoint.py
ADDED
@@ -0,0 +1,143 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
2 |
+
import logging
|
3 |
+
import os
|
4 |
+
import pickle
|
5 |
+
from urllib.parse import parse_qs, urlparse
|
6 |
+
import torch
|
7 |
+
from fvcore.common.checkpoint import Checkpointer
|
8 |
+
from torch.nn.parallel import DistributedDataParallel
|
9 |
+
|
10 |
+
import detectron2.utils.comm as comm
|
11 |
+
from detectron2.utils.file_io import PathManager
|
12 |
+
|
13 |
+
from .c2_model_loading import align_and_update_state_dicts
|
14 |
+
|
15 |
+
|
16 |
+
class DetectionCheckpointer(Checkpointer):
|
17 |
+
"""
|
18 |
+
Same as :class:`Checkpointer`, but is able to:
|
19 |
+
1. handle models in detectron & detectron2 model zoo, and apply conversions for legacy models.
|
20 |
+
2. correctly load checkpoints that are only available on the master worker
|
21 |
+
"""
|
22 |
+
|
23 |
+
def __init__(self, model, save_dir="", *, save_to_disk=None, **checkpointables):
|
24 |
+
is_main_process = comm.is_main_process()
|
25 |
+
super().__init__(
|
26 |
+
model,
|
27 |
+
save_dir,
|
28 |
+
save_to_disk=is_main_process if save_to_disk is None else save_to_disk,
|
29 |
+
**checkpointables,
|
30 |
+
)
|
31 |
+
self.path_manager = PathManager
|
32 |
+
self._parsed_url_during_load = None
|
33 |
+
|
34 |
+
def load(self, path, *args, **kwargs):
|
35 |
+
assert self._parsed_url_during_load is None
|
36 |
+
need_sync = False
|
37 |
+
logger = logging.getLogger(__name__)
|
38 |
+
logger.info("[DetectionCheckpointer] Loading from {} ...".format(path))
|
39 |
+
|
40 |
+
if path and isinstance(self.model, DistributedDataParallel):
|
41 |
+
path = self.path_manager.get_local_path(path)
|
42 |
+
has_file = os.path.isfile(path)
|
43 |
+
all_has_file = comm.all_gather(has_file)
|
44 |
+
if not all_has_file[0]:
|
45 |
+
raise OSError(f"File {path} not found on main worker.")
|
46 |
+
if not all(all_has_file):
|
47 |
+
logger.warning(
|
48 |
+
f"Not all workers can read checkpoint {path}. "
|
49 |
+
"Training may fail to fully resume."
|
50 |
+
)
|
51 |
+
# TODO: broadcast the checkpoint file contents from main
|
52 |
+
# worker, and load from it instead.
|
53 |
+
need_sync = True
|
54 |
+
if not has_file:
|
55 |
+
path = None # don't load if not readable
|
56 |
+
|
57 |
+
if path:
|
58 |
+
parsed_url = urlparse(path)
|
59 |
+
self._parsed_url_during_load = parsed_url
|
60 |
+
path = parsed_url._replace(query="").geturl() # remove query from filename
|
61 |
+
path = self.path_manager.get_local_path(path)
|
62 |
+
ret = super().load(path, *args, **kwargs)
|
63 |
+
|
64 |
+
if need_sync:
|
65 |
+
logger.info("Broadcasting model states from main worker ...")
|
66 |
+
self.model._sync_params_and_buffers()
|
67 |
+
self._parsed_url_during_load = None # reset to None
|
68 |
+
return ret
|
69 |
+
|
70 |
+
def _load_file(self, filename):
|
71 |
+
if filename.endswith(".pkl"):
|
72 |
+
with PathManager.open(filename, "rb") as f:
|
73 |
+
data = pickle.load(f, encoding="latin1")
|
74 |
+
if "model" in data and "__author__" in data:
|
75 |
+
# file is in Detectron2 model zoo format
|
76 |
+
self.logger.info("Reading a file from '{}'".format(data["__author__"]))
|
77 |
+
return data
|
78 |
+
else:
|
79 |
+
# assume file is from Caffe2 / Detectron1 model zoo
|
80 |
+
if "blobs" in data:
|
81 |
+
# Detection models have "blobs", but ImageNet models don't
|
82 |
+
data = data["blobs"]
|
83 |
+
data = {k: v for k, v in data.items() if not k.endswith("_momentum")}
|
84 |
+
return {"model": data, "__author__": "Caffe2", "matching_heuristics": True}
|
85 |
+
elif filename.endswith(".pyth"):
|
86 |
+
# assume file is from pycls; no one else seems to use the ".pyth" extension
|
87 |
+
with PathManager.open(filename, "rb") as f:
|
88 |
+
data = torch.load(f)
|
89 |
+
assert (
|
90 |
+
"model_state" in data
|
91 |
+
), f"Cannot load .pyth file {filename}; pycls checkpoints must contain 'model_state'."
|
92 |
+
model_state = {
|
93 |
+
k: v
|
94 |
+
for k, v in data["model_state"].items()
|
95 |
+
if not k.endswith("num_batches_tracked")
|
96 |
+
}
|
97 |
+
return {"model": model_state, "__author__": "pycls", "matching_heuristics": True}
|
98 |
+
|
99 |
+
loaded = self._torch_load(filename)
|
100 |
+
if "model" not in loaded:
|
101 |
+
loaded = {"model": loaded}
|
102 |
+
assert self._parsed_url_during_load is not None, "`_load_file` must be called inside `load`"
|
103 |
+
parsed_url = self._parsed_url_during_load
|
104 |
+
queries = parse_qs(parsed_url.query)
|
105 |
+
if queries.pop("matching_heuristics", "False") == ["True"]:
|
106 |
+
loaded["matching_heuristics"] = True
|
107 |
+
if len(queries) > 0:
|
108 |
+
raise ValueError(
|
109 |
+
f"Unsupported query remaining: f{queries}, orginal filename: {parsed_url.geturl()}"
|
110 |
+
)
|
111 |
+
return loaded
|
112 |
+
|
113 |
+
def _torch_load(self, f):
|
114 |
+
return super()._load_file(f)
|
115 |
+
|
116 |
+
def _load_model(self, checkpoint):
|
117 |
+
if checkpoint.get("matching_heuristics", False):
|
118 |
+
self._convert_ndarray_to_tensor(checkpoint["model"])
|
119 |
+
# convert weights by name-matching heuristics
|
120 |
+
checkpoint["model"] = align_and_update_state_dicts(
|
121 |
+
self.model.state_dict(),
|
122 |
+
checkpoint["model"],
|
123 |
+
c2_conversion=checkpoint.get("__author__", None) == "Caffe2",
|
124 |
+
)
|
125 |
+
# for non-caffe2 models, use standard ways to load it
|
126 |
+
incompatible = super()._load_model(checkpoint)
|
127 |
+
|
128 |
+
model_buffers = dict(self.model.named_buffers(recurse=False))
|
129 |
+
for k in ["pixel_mean", "pixel_std"]:
|
130 |
+
# Ignore missing key message about pixel_mean/std.
|
131 |
+
# Though they may be missing in old checkpoints, they will be correctly
|
132 |
+
# initialized from config anyway.
|
133 |
+
if k in model_buffers:
|
134 |
+
try:
|
135 |
+
incompatible.missing_keys.remove(k)
|
136 |
+
except ValueError:
|
137 |
+
pass
|
138 |
+
for k in incompatible.unexpected_keys[:]:
|
139 |
+
# Ignore unexpected keys about cell anchors. They exist in old checkpoints
|
140 |
+
# but now they are non-persistent buffers and will not be in new checkpoints.
|
141 |
+
if "anchor_generator.cell_anchors" in k:
|
142 |
+
incompatible.unexpected_keys.remove(k)
|
143 |
+
return incompatible
|
detectron2/config/__init__.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Copyright (c) Facebook, Inc. and its affiliates.
|
2 |
+
from .compat import downgrade_config, upgrade_config
|
3 |
+
from .config import CfgNode, get_cfg, global_cfg, set_global_cfg, configurable
|
4 |
+
from .instantiate import instantiate
|
5 |
+
from .lazy import LazyCall, LazyConfig
|
6 |
+
|
7 |
+
__all__ = [
|
8 |
+
"CfgNode",
|
9 |
+
"get_cfg",
|
10 |
+
"global_cfg",
|
11 |
+
"set_global_cfg",
|
12 |
+
"downgrade_config",
|
13 |
+
"upgrade_config",
|
14 |
+
"configurable",
|
15 |
+
"instantiate",
|
16 |
+
"LazyCall",
|
17 |
+
"LazyConfig",
|
18 |
+
]
|
19 |
+
|
20 |
+
|
21 |
+
from detectron2.utils.env import fixup_module_metadata
|
22 |
+
|
23 |
+
fixup_module_metadata(__name__, globals(), __all__)
|
24 |
+
del fixup_module_metadata
|
detectron2/config/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (626 Bytes). View file
|
|
detectron2/config/__pycache__/__init__.cpython-311.pyc
ADDED
Binary file (860 Bytes). View file
|
|
detectron2/config/__pycache__/compat.cpython-310.pyc
ADDED
Binary file (7.74 kB). View file
|
|
detectron2/config/__pycache__/compat.cpython-311.pyc
ADDED
Binary file (11.7 kB). View file
|
|
detectron2/config/__pycache__/config.cpython-310.pyc
ADDED
Binary file (8.01 kB). View file
|
|
detectron2/config/__pycache__/config.cpython-311.pyc
ADDED
Binary file (11.7 kB). View file
|
|
detectron2/config/__pycache__/defaults.cpython-310.pyc
ADDED
Binary file (6.28 kB). View file
|
|
detectron2/config/__pycache__/defaults.cpython-311.pyc
ADDED
Binary file (13.7 kB). View file
|
|
detectron2/config/__pycache__/instantiate.cpython-310.pyc
ADDED
Binary file (2.71 kB). View file
|
|