Skip to content

Commit c9b9b45

Browse files
authored
Add doc structures and formulate requirements (open-mmlab#32)
1 parent c525419 commit c9b9b45

23 files changed

+376
-8
lines changed

docs/Makefile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/changelog.md

Whitespace-only changes.

docs/conf.py

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
import os
14+
import sys
15+
16+
sys.path.insert(0, os.path.abspath('..'))
17+
18+
# -- Project information -----------------------------------------------------
19+
20+
project = 'MMTracking'
21+
copyright = '2018-2020, OpenMMLab'
22+
author = 'MMTracking Authors'
23+
version_file = '../mmtrack/version.py'
24+
25+
26+
def get_version():
27+
with open(version_file, 'r') as f:
28+
exec(compile(f.read(), version_file, 'exec'))
29+
return locals()['__version__']
30+
31+
32+
# The full version, including alpha/beta/rc tags
33+
release = get_version()
34+
35+
# -- General configuration ---------------------------------------------------
36+
37+
# Add any Sphinx extension module names here, as strings. They can be
38+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
39+
# ones.
40+
extensions = [
41+
'sphinx.ext.autodoc',
42+
'sphinx.ext.napoleon',
43+
'sphinx.ext.viewcode',
44+
'recommonmark',
45+
'sphinx_markdown_tables',
46+
]
47+
48+
autodoc_mock_imports = [
49+
'matplotlib', 'pycocotools', 'terminaltables', 'mmtrack.version',
50+
'mmcv.ops'
51+
]
52+
53+
# Add any paths that contain templates here, relative to this directory.
54+
templates_path = ['_templates']
55+
56+
# The suffix(es) of source filenames.
57+
# You can specify multiple suffix as a list of string:
58+
#
59+
source_suffix = {
60+
'.rst': 'restructuredtext',
61+
'.md': 'markdown',
62+
}
63+
64+
# The master toctree document.
65+
master_doc = 'index'
66+
67+
# List of patterns, relative to source directory, that match files and
68+
# directories to ignore when looking for source files.
69+
# This pattern also affects html_static_path and html_extra_path.
70+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
71+
72+
# -- Options for HTML output -------------------------------------------------
73+
74+
# The theme to use for HTML and HTML Help pages. See the documentation for
75+
# a list of builtin themes.
76+
#
77+
html_theme = 'sphinx_rtd_theme'
78+
79+
# Add any paths that contain custom static files (such as style sheets) here,
80+
# relative to this directory. They are copied after the builtin static files,
81+
# so a file named "default.css" will overwrite the builtin "default.css".
82+
html_static_path = ['_static']
83+
84+
# def builder_inited_handler(app):
85+
# subprocess.run(['./stat.py'])
86+
87+
# def setup(app):
88+
# app.connect('builder-inited', builder_inited_handler)

docs/dataset.py

Whitespace-only changes.

docs/faq.md

Whitespace-only changes.

docs/get_started.md

+187
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
## Prerequisites
2+
3+
- Linux or macOS (Windows is in experimental support)
4+
- Python 3.6+
5+
- PyTorch 1.3+
6+
- CUDA 9.2+ (If you build PyTorch from source, CUDA 9.0 is also compatible)
7+
- GCC 5+
8+
- [MMCV](https://mmcv.readthedocs.io/en/latest/#installation)
9+
10+
The compatible MMDetection and MMCV versions are as below. Please install the correct version of MMCV to avoid installation issues.
11+
12+
| MMDetection version | MMCV version |
13+
|:-------------------:|:-------------------:|
14+
| master | mmcv-full>=1.1.5, <1.3|
15+
| 2.7.0 | mmcv-full>=1.1.5, <1.3|
16+
| 2.6.0 | mmcv-full>=1.1.5, <1.3|
17+
| 2.5.0 | mmcv-full>=1.1.5, <1.3|
18+
| 2.4.0 | mmcv-full>=1.1.1, <1.3|
19+
| 2.3.0 | mmcv-full==1.0.5|
20+
| 2.3.0rc0 | mmcv-full>=1.0.2 |
21+
| 2.2.1 | mmcv==0.6.2 |
22+
| 2.2.0 | mmcv==0.6.2 |
23+
| 2.1.0 | mmcv>=0.5.9, <=0.6.1|
24+
| 2.0.0 | mmcv>=0.5.1, <=0.5.8|
25+
26+
Note: You need to run `pip uninstall mmcv` first if you have mmcv installed.
27+
If mmcv and mmcv-full are both installed, there will be `ModuleNotFoundError`.
28+
29+
## Installation
30+
31+
1. Create a conda virtual environment and activate it.
32+
33+
```shell
34+
conda create -n open-mmlab python=3.7 -y
35+
conda activate open-mmlab
36+
```
37+
38+
2. Install PyTorch and torchvision following the [official instructions](https://pytorch.org/), e.g.,
39+
40+
```shell
41+
conda install pytorch torchvision -c pytorch
42+
```
43+
44+
Note: Make sure that your compilation CUDA version and runtime CUDA version match.
45+
You can check the supported CUDA version for precompiled packages on the [PyTorch website](https://pytorch.org/).
46+
47+
`E.g.1` If you have CUDA 10.1 installed under `/usr/local/cuda` and would like to install
48+
PyTorch 1.5, you need to install the prebuilt PyTorch with CUDA 10.1.
49+
50+
```shell
51+
conda install pytorch cudatoolkit=10.1 torchvision -c pytorch
52+
```
53+
54+
`E.g. 2` If you have CUDA 9.2 installed under `/usr/local/cuda` and would like to install
55+
PyTorch 1.3.1., you need to install the prebuilt PyTorch with CUDA 9.2.
56+
57+
```shell
58+
conda install pytorch=1.3.1 cudatoolkit=9.2 torchvision=0.4.2 -c pytorch
59+
```
60+
61+
If you build PyTorch from source instead of installing the prebuilt pacakge,
62+
you can use more CUDA versions such as 9.0.
63+
64+
3. Install mmcv-full, we recommend you to install the pre-build package as below.
65+
66+
```shell
67+
pip install mmcv-full==latest+torch1.6.0+cu101 -f https://download.openmmlab.com/mmcv/dist/index.html
68+
```
69+
70+
See [here](https://github.com/open-mmlab/mmcv#install-with-pip) for different versions of MMCV compatible to different PyTorch and CUDA versions.
71+
Optionally you can choose to compile mmcv from source by the following command
72+
73+
```shell
74+
git clone https://github.com/open-mmlab/mmcv.git
75+
cd mmcv
76+
MMCV_WITH_OPS=1 pip install -e . # package mmcv-full will be installed after this step
77+
cd ..
78+
```
79+
80+
Or directly run
81+
82+
```shell
83+
pip install mmcv-full
84+
```
85+
86+
4. Clone the MMDetection repository.
87+
88+
```shell
89+
git clone https://github.com/open-mmlab/mmdetection.git
90+
cd mmdetection
91+
```
92+
93+
5. Install build requirements and then install MMDetection.
94+
95+
```shell
96+
pip install -r requirements/build.txt
97+
pip install -v -e . # or "python setup.py develop"
98+
```
99+
100+
Note:
101+
102+
a. Following the above instructions, MMDetection is installed on `dev` mode
103+
, any local modifications made to the code will take effect without the need to reinstall it.
104+
105+
b. If you would like to use `opencv-python-headless` instead of `opencv
106+
-python`,
107+
you can install it before installing MMCV.
108+
109+
c. Some dependencies are optional. Simply running `pip install -v -e .` will
110+
only install the minimum runtime requirements. To use optional dependencies like `albumentations` and `imagecorruptions` either install them manually with `pip install -r requirements/optional.txt` or specify desired extras when calling `pip` (e.g. `pip install -v -e .[optional]`). Valid keys for the extras field are: `all`, `tests`, `build`, and `optional`.
111+
112+
### Install with CPU only
113+
114+
The code can be built for CPU only environment (where CUDA isn't available).
115+
116+
In CPU mode you can run the demo/webcam_demo.py for example.
117+
However some functionality is gone in this mode:
118+
119+
- Deformable Convolution
120+
- Deformable ROI pooling
121+
- CARAFE: Content-Aware ReAssembly of FEatures
122+
- nms_cuda
123+
- sigmoid_focal_loss_cuda
124+
125+
So if you try to run inference with a model containing deformable convolution you will get an error.
126+
127+
### Another option: Docker Image
128+
129+
We provide a [Dockerfile](https://github.com/open-mmlab/mmdetection/blob/master/docker/Dockerfile) to build an image. Ensure that you are using [docker version](https://docs.docker.com/engine/install/) >=19.03.
130+
131+
```shell
132+
# build an image with PyTorch 1.6, CUDA 10.1
133+
docker build -t mmdetection docker/
134+
```
135+
136+
Run it with
137+
138+
```shell
139+
docker run --gpus all --shm-size=8g -it -v {DATA_DIR}:/mmdetection/data mmdetection
140+
```
141+
142+
### A from-scratch setup script
143+
144+
Assuming that you already have CUDA 10.1 installed, here is a full script for setting up MMDetection with conda.
145+
146+
```shell
147+
conda create -n open-mmlab python=3.7 -y
148+
conda activate open-mmlab
149+
150+
conda install pytorch==1.6.0 torchvision==0.7.0 cudatoolkit=10.1 -c pytorch -y
151+
152+
# install the latest mmcv
153+
pip install mmcv-full==latest+torch1.6.0+cu101 -f https://download.openmmlab.com/mmcv/dist/index.html
154+
155+
# install mmdetection
156+
git clone https://github.com/open-mmlab/mmdetection.git
157+
cd mmdetection
158+
pip install -r requirements/build.txt
159+
pip install -v -e .
160+
```
161+
162+
### Developing with multiple MMDetection versions
163+
164+
The train and test scripts already modify the `PYTHONPATH` to ensure the script use the MMDetection in the current directory.
165+
166+
To use the default MMDetection installed in the environment rather than that you are working with, you can remove the following line in those scripts
167+
168+
```shell
169+
PYTHONPATH="$(dirname $0)/..":$PYTHONPATH
170+
```
171+
172+
## Verification
173+
174+
To verify whether MMDetection and the required environment are installed correctly, we can run sample python codes to initialize a detector and inference a demo image:
175+
176+
```python
177+
from mmdet.apis import init_detector, inference_detector
178+
179+
config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
180+
device = 'cuda:0'
181+
# init a detector
182+
model = init_detector(config_file, device=device)
183+
# inference the demo image
184+
inference_detector(model, 'demo/demo.jpg')
185+
```
186+
187+
The above code is supposed to run successfully upon you finish the installation.

docs/index.rst

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Welcome to MMTracking's documentation!
2+
=======================================
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
:caption: Get Started
7+
8+
get_started.md

docs/make.bat

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=.
11+
set BUILDDIR=_build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.http://sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/model_zoo.md

Whitespace-only changes.

docs/quick_run.md

Whitespace-only changes.

docs/tools.md

Whitespace-only changes.

docs/tutorials/config.md

Whitespace-only changes.

docs/tutorials/customize_data_pipeline.md

Whitespace-only changes.

docs/tutorials/customize_dataset.md

Whitespace-only changes.

docs/tutorials/customize_models.md

Whitespace-only changes.

docs/tutorials/customize_runtime.md

Whitespace-only changes.

mmtrack/.readthedocs.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
3+
python:
4+
version: 3.7
5+
install:
6+
- requirements: requirements/docs.txt
7+
- requirements: requirements/readthedocs.txt

requirements.txt

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
coverage
2-
mmcls
3-
mmcv>=1.0.0
4-
mmdet
5-
motmetrics
6-
numpy
7-
torch>=1.3
8-
torchvision
1+
-r requirements/build.txt
2+
-r requirements/runtime.txt
3+
-r requirements/tests.txt

requirements/build.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These must be installed before building mmdetection
2+
cython
3+
numpy

requirements/docs.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
recommonmark
2+
sphinx
3+
sphinx_markdown_tables
4+
sphinx_rtd_theme

requirements/readthedocs.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
mmcv
2+
torch
3+
torchvision

requirements/runtime.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
matplotlib
2+
mmcls
3+
mmpycocotools
4+
motmetrics
5+
numpy
6+
six
7+
terminaltables

requirements/tests.txt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
asynctest
2+
codecov
3+
flake8
4+
interrogate
5+
isort==4.3.21
6+
# Note: used for kwarray.group_items, this may be ported to mmcv in the future.
7+
kwarray
8+
pytest
9+
ubelt
10+
xdoctest>=0.10.0
11+
yapf

0 commit comments

Comments
 (0)