Skip to content

Commit efe36be

Browse files
GeorgePearseclaude
andcommitted
revert: remove unrelated changes, keep only blue-sky-ideas doc
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 87e0c4b commit efe36be

35 files changed

Lines changed: 545 additions & 732 deletions

.pre-commit-config.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,6 @@ repos:
257257
pass_filenames: false
258258
files: ^visdet/engine/hub/
259259

260-
- id: zuban-models
261-
name: Zuban type checker (visdet/models)
262-
entry: uv run zuban check visdet/models --exclude '/dense_heads/' --exclude '/backbones/hrnet.py' --exclude '/backbones/swin.py' --exclude '/backbones/regnet.py' --exclude '/backbones/res2net.py' --exclude '/backbones/resnest.py' --exclude '/backbones/cspnext.py'
263-
language: system
264-
types: [python]
265-
pass_filenames: false
266-
files: ^visdet/models/
267-
268260
- repo: https://github.com/kynan/nbstripout
269261
rev: 0.8.1
270262
hooks:

docs/about/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ visdet-worktrees/
2828
We use the following tools to maintain code quality:
2929

3030
- `ruff` for linting and formatting
31-
- `zuban` for type checking
31+
- `pyright` for type checking
3232
- `prek` hooks for automated checks (faster Rust-based alternative to pre-commit)
3333

3434
To set up the development environment:

docs/development/contributing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ We appreciate all contributions to improve VisDet. Please follow the guidelines
1515
We use the following tools to maintain code quality:
1616

1717
- `ruff` for linting and formatting
18-
- `zuban` for type checking
18+
- `pyright` for type checking
1919
- `prek` hooks for automated checks (faster Rust-based alternative to pre-commit)
2020

2121
To set up the development environment:
Lines changed: 163 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,143 +1,234 @@
1-
# Installation
2-
3-
VisDet is published as a normal Python package. In most cases you **do not** need to clone this repository to use it.
4-
5-
Cloning the repo is only needed if you want to:
6-
7-
- Develop VisDet itself (editable install, tests, docs)
8-
- Use the repo’s training scripts under `tools/`
9-
- Use the repo’s example assets/configs as-is
1+
# Prerequisites
102

11-
## Requirements
3+
In this section we demonstrate how to prepare an environment with PyTorch.
124

13-
- Python `>=3.10,<3.13`
14-
- PyTorch + torchvision
15-
- For CUDA / GPU support, install PyTorch following https://pytorch.org first (so you get the correct CUDA build).
5+
This framework works on Linux, Windows and macOS. It requires Python 3.7+, CUDA 9.2+ and PyTorch 1.5+.
166

17-
## Install with uv (recommended)
7+
```{note}
8+
If you are experienced with PyTorch and have already installed it, just skip this part and jump to the [next section](#installation). Otherwise, you can follow these steps for the preparation.
9+
```
1810

19-
**Step 0.** Install [uv](https://docs.astral.sh/uv/) (if you don’t already have it).
11+
**Step 0.** Install [uv](https://docs.astral.sh/uv/) - a fast Python package manager.
2012

2113
```shell
22-
# macOS / Linux
14+
# On macOS and Linux
2315
curl -LsSf https://astral.sh/uv/install.sh | sh
2416

25-
# Windows
17+
# On Windows
2618
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
2719
```
2820

29-
**Step 1.** Create a virtual environment.
21+
**Step 1.** uv will automatically manage Python versions and virtual environments for you. No separate setup needed!
3022

31-
```shell
32-
uv venv --python 3.12
33-
```
23+
# Installation
3424

35-
**Step 2.** Activate it.
25+
We recommend that users follow our best practices to install VisDet using uv. However, the whole process is highly customizable. See [Customize Installation](#customize-installation) section for more information.
3626

37-
```shell
38-
# macOS / Linux
39-
source .venv/bin/activate
27+
## Best Practices
4028

41-
# Windows (PowerShell)
42-
.venv\Scripts\Activate.ps1
29+
**Step 0.** Clone the repository and navigate to it.
30+
31+
```shell
32+
git clone <your-repository-url>
33+
cd visdet
4334
```
4435

45-
**Step 3.** Install VisDet.
36+
**Step 1.** Install dependencies using uv.
37+
38+
For development (includes all dependencies):
4639

4740
```shell
48-
uv pip install visdet
41+
uv sync
4942
```
5043

51-
### Optional extras
44+
For specific extras (e.g., just documentation):
5245

5346
```shell
54-
# Extra (optional) dependencies used by some features
55-
uv pip install "visdet[optional]"
56-
57-
# Everything in the optional group
58-
uv pip install "visdet[all]"
47+
uv sync --extra mkdocs
5948
```
6049

61-
## Install with pip
50+
**Step 2.** That's it! uv has:
51+
- Created a virtual environment
52+
- Installed Python 3.12 (or the version specified in `.python-version`)
53+
- Installed all dependencies from `pyproject.toml`
54+
- Installed the package in editable mode
55+
56+
## Verify the installation
57+
58+
To verify whether This framework installed correctly, we provide some sample codes to run an inference demo.
6259

63-
If you prefer standard tooling:
60+
**Step 1.** We need to download config and checkpoint files.
6461

6562
```shell
66-
python -m venv .venv
67-
source .venv/bin/activate # or .venv\Scripts\activate on Windows
68-
pip install -U pip
69-
pip install visdet
63+
uv run mim download mmdet --config yolov3_mobilenetv2_320_300e_coco --dest .
7064
```
7165

72-
## Verify the installation
66+
The downloading will take several seconds or more, depending on your network environment. When it is done, you will find two files `yolov3_mobilenetv2_320_300e_coco.py` and `yolov3_mobilenetv2_320_300e_coco_20210719_215349-d18dff72.pth` in your current folder.
7367

74-
A minimal smoke-check (no repo clone required):
68+
**Step 2.** Verify the inference demo.
7569

7670
```shell
77-
python -c "import visdet; print(visdet.__version__)"
71+
uv run python demo/image_demo.py demo/demo.jpg yolov3_mobilenetv2_320_300e_coco.py yolov3_mobilenetv2_320_300e_coco_20210719_215349-d18dff72.pth --device cpu --out-file result.jpg
7872
```
7973

80-
Optional: run a quick inference using a built-in YAML preset (this may download model weights on first use):
74+
You will see a new image `result.jpg` on your current folder, where bounding boxes are plotted on cars, benches, etc.
75+
76+
Alternatively, you can run Python code directly:
8177

8278
```python
83-
from visdet.apis import DetInferencer
79+
# Run with: uv run python
80+
from mmdet.apis import init_detector, inference_detector
81+
82+
config_file = 'yolov3_mobilenetv2_320_300e_coco.py'
83+
checkpoint_file = 'yolov3_mobilenetv2_320_300e_coco_20210719_215349-d18dff72.pth'
84+
model = init_detector(config_file, checkpoint_file, device='cpu') # or device='cuda:0'
85+
inference_detector(model, 'demo/demo.jpg')
86+
```
8487

85-
inferencer = DetInferencer(model="rtmdet-s", device="cpu")
86-
results = inferencer("path/to/your_image.jpg")
87-
print(results)
88+
You will see a list of arrays printed, indicating the detected bounding boxes.
89+
90+
## Customize Installation
91+
92+
### CUDA versions
93+
94+
When installing PyTorch, you need to specify the version of CUDA. If you are not clear on which to choose, follow our recommendations:
95+
96+
- For Ampere-based NVIDIA GPUs, such as GeForce 30 series and NVIDIA A100, CUDA 11 is a must.
97+
- For older NVIDIA GPUs, CUDA 11 is backward compatible, but CUDA 10.2 offers better compatibility and is more lightweight.
98+
99+
Please make sure the GPU driver satisfies the minimum version requirements. See [this table](https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html#cuda-major-component-versions__table-cuda-toolkit-driver-versions) for more information.
100+
101+
```{note}
102+
uv handles PyTorch installation automatically based on your `pyproject.toml` configuration. For specific CUDA versions, you may need to configure the PyTorch index URL in your project settings.
88103
```
89104

90-
## Install from source (development)
105+
### Installing additional packages
91106

92-
Only needed if you’re contributing to VisDet.
107+
To add additional packages to your project:
93108

94109
```shell
95-
git clone <your-repository-url>
96-
cd visdet
97-
uv sync
110+
# Add a new dependency
111+
uv add package-name
112+
113+
# Add a development dependency
114+
uv add --dev package-name
115+
116+
# Add an optional dependency to a specific group
117+
uv add --optional group-name package-name
98118
```
99119

100-
That will:
120+
### Install on CPU-only platforms
121+
122+
This framework can be built for CPU only environment. In CPU mode you can train, test or inference a model.
123+
124+
However some functionalities are gone in this mode:
125+
126+
- Deformable Convolution
127+
- Modulated Deformable Convolution
128+
- ROI pooling
129+
- Deformable ROI pooling
130+
- CARAFE
131+
- SyncBatchNorm
132+
- CrissCrossAttention
133+
- MaskedConv2d
134+
- Temporal Interlace Shift
135+
- nms_cuda
136+
- sigmoid_focal_loss_cuda
137+
- bbox_overlaps
101138

102-
- Create a virtual environment
103-
- Install dependencies from `pyproject.toml`
104-
- Install VisDet in editable mode
139+
If you try to train/test/inference a model containing above ops, an error will be raised.
140+
The following table lists affected algorithms.
105141

106-
## Install on Google Colab
142+
| Operator | Model |
143+
| :-----------------------------------------------------: | :--------------------------------------------------------------------------------------: |
144+
| Deformable Convolution/Modulated Deformable Convolution | DCN、Guided Anchoring、RepPoints、CentripetalNet、VFNet、CascadeRPN、NAS-FCOS、DetectoRS |
145+
| MaskedConv2d | Guided Anchoring |
146+
| CARAFE | CARAFE |
147+
| SyncBatchNorm | ResNeSt |
107148

108-
Colab usually already has PyTorch installed.
149+
### Install on Google Colab
150+
151+
[Google Colab](https://research.google.com/) usually has PyTorch installed.
152+
Here's how to install visdet with uv on Colab:
153+
154+
**Step 1.** Install uv in Colab.
109155

110156
```shell
111157
!curl -LsSf https://astral.sh/uv/install.sh | sh
112-
!uv venv --python 3.12
113-
!uv pip install visdet
114158
```
115159

160+
**Step 2.** Clone and install visdet.
161+
162+
```shell
163+
!git clone <your-repository-url>
164+
%cd visdet
165+
!uv sync
166+
```
167+
168+
**Step 3.** Verification.
169+
116170
```python
117-
import visdet
118-
print(visdet.__version__)
171+
!uv run python -c "import mmdet; print(mmdet.__version__)"
119172
```
120173

121174
```{note}
122-
Within Jupyter, the exclamation mark `!` runs shell commands.
175+
Within Jupyter, the exclamation mark `!` is used to call external executables and `%cd` is a [magic command](https://ipython.readthedocs.io/en/stable/interactive/magics.html#magic-cd) to change the current working directory of Python.
123176
```
124177

125-
## Using VisDet with Docker
178+
### Using VisDet with Docker
126179

127-
The repo contains a `docker/` folder with a Dockerfile. This path **does** require cloning the repository.
180+
We provide a Dockerfile in the `docker/` directory to build an image. Ensure that your [docker version](https://docs.docker.com/engine/install/) >=19.03.
128181

129182
```shell
183+
# build an image with PyTorch 1.6, CUDA 10.1
184+
# If you prefer other versions, just modified the Dockerfile
130185
docker build -t visdet docker/
131186
```
132187

133-
Run it with:
188+
Run it with
134189

135190
```shell
136191
docker run --gpus all --shm-size=8g -it -v {DATA_DIR}:/visdet/data visdet
137192
```
138193

139-
## Troubleshooting
194+
### Running commands with uv
195+
196+
All commands should be prefixed with `uv run` to ensure they use the project's virtual environment:
197+
198+
```shell
199+
# Running Python scripts
200+
uv run python your_script.py
201+
202+
# Running installed CLI tools
203+
uv run pytest tests/
204+
205+
# Running prek hooks
206+
uv run prek run --all-files
207+
208+
# Building documentation
209+
uv run mkdocs build
210+
```
211+
212+
Alternatively, you can activate the virtual environment manually:
213+
214+
```shell
215+
source .venv/bin/activate # On Linux/macOS
216+
# or
217+
.venv\Scripts\activate # On Windows
218+
219+
# Now you can run commands without 'uv run' prefix
220+
python your_script.py
221+
pytest tests/
222+
```
223+
224+
## Trouble shooting
225+
226+
If you have some issues during the installation, please check the documentation carefully.
227+
228+
Common issues and solutions:
229+
230+
- **Import errors**: Make sure you have installed the package with `uv sync`
231+
- **CUDA issues**: Verify your CUDA version matches your PyTorch installation
232+
- **Version conflicts**: Try creating a fresh virtual environment
140233

141-
- **Import errors**: ensure you installed into the environment you’re running (`which python` / `python -V`).
142-
- **CUDA issues**: install PyTorch for your CUDA version (then reinstall `visdet` if needed).
143-
- **Version conflicts**: try a fresh env: `rm -rf .venv && uv venv && uv pip install visdet`.
234+
If you encounter problems not covered in the documentation, please refer to the [Contributing Guide](../development/contributing.md) for how to report issues.

docs/getting-started/quick-start.md

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,40 +22,31 @@ runner.train()
2222

2323
## Inference with Pre-trained Models
2424

25-
### Using YAML model presets (no repo clone)
25+
### Using High-level APIs
2626

27-
VisDet ships with YAML model presets, so you can run inference without needing this repository’s Python config files.
27+
You can use high-level APIs to perform inference on images:
2828

2929
```python
30-
from visdet.apis import DetInferencer
30+
from visdet.apis import init_detector, inference_detector
3131

32-
# Uses a built-in preset name/alias; may download weights on first use
33-
inferencer = DetInferencer(model="rtmdet-s", device="cuda:0")
34-
result = inferencer("path/to/image.jpg")
35-
print(result)
36-
```
37-
38-
### Using explicit config + checkpoint (repo-style)
32+
# Specify the config file and checkpoint file
33+
config_file = 'configs/faster_rcnn/faster_rcnn_r50_fpn_1x_coco.py'
34+
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco.pth'
3935

40-
If you *are* working from a cloned repo (or you have your own configs/checkpoints), you can still use the classic APIs:
41-
42-
```python
43-
from visdet.apis import init_detector, inference_detector, show_result_pyplot
36+
# Build the model from a config file and a checkpoint file
37+
model = init_detector(config_file, checkpoint_file, device='cuda:0')
4438

45-
config_file = "path/to/config.py"
46-
checkpoint_file = "path/to/checkpoint.pth"
47-
48-
model = init_detector(config_file, checkpoint_file, device="cuda:0")
49-
img = "path/to/image.jpg"
39+
# Test a single image
40+
img = 'demo/demo.jpg'
5041
result = inference_detector(model, img)
42+
43+
# Show the results
44+
from visdet.apis import show_result_pyplot
5145
show_result_pyplot(model, img, result)
5246
```
5347

5448
## Training a Model
5549

56-
The training / testing entrypoints under `tools/` are part of this repository.
57-
If you want to use them, clone the repo and run from the repo root.
58-
5950
### Train with a Single GPU
6051

6152
```bash

0 commit comments

Comments
 (0)