pip install -U openmim★MIM is OpenMMLab's package manager — it resolves the correct prebuiltmmcvwheel for your exact PyTorch + CUDA. Install PyTorch first.mim install mmengine "mmcv>=2.0.0" mmdet★The 3.x stack. In MMCV 2.x the package is justmmcv(the oldmmcv-full);mmcv-liteskips the CUDA ops. Don'tpip install mmcvdirectly — usemim.python -c "import mmdet; print(mmdet.__version__)" # 3.3.0Confirm the install and version.mim download mmdet --config rtmdet_tiny_8xb32-300e_coco --dest .Fetch a config + pretrained checkpoint by name — the quickest way to get weights for the demo below.
from mmdet.apis import DetInferencer inf = DetInferencer("rtmdet_tiny_8xb32-300e_coco") inf("demo/demo.jpg", out_dir="outputs/", show=False)★High-level API — give it a model name (weights auto-download), an image / folder / URL, and it runs + visualizes. Easiest entry point.from mmdet.apis import init_detector, inference_detector model = init_detector(config, checkpoint, device="cuda:0") result = inference_detector(model, "img.jpg")★Low-level API for full control. Returns aDetDataSample.inst = result.pred_instances inst.bboxes · inst.scores · inst.labels★Read predictions offpred_instances. Filter by score:inst[inst.scores > 0.3]. Masks live ininst.masksfor segmentation models.
# my_config.py _base_ = "configs/rtmdet/rtmdet_tiny_8xb32-300e_coco.py"★_base_inheritance is the core idea — start from a shipped config and override only what changes. Configs live inconfigs/(hundreds of them).model = dict(bbox_head=dict(num_classes=3)) # override★Dicts deep-merge onto the base. Point this at your class count, dataset, schedule, etc. (some models nest it, e.g.roi_head.bbox_head).from mmengine.config import Config cfg = Config.fromfile("my_config.py")Load a config in Python. Inspect the fully-merged result withpython tools/misc/print_config.py my_config.py.python tools/train.py cfg.py --cfg-options train_dataloader.batch_size=4--cfg-optionsoverrides any config key from the CLI — no file edit needed for quick experiments.