1. 安装
使用openmim安装:
pip install -U openmim
mim install "mmengine>=0.7.0"
mim install "mmcv>=2.0.0rc4"
2. 测试案例
下载代码和模型:
git clone https://github.com/open-mmlab/mmdetection.git
mkdir ./checkpoints
mim download mmdet --config rtmdet_tiny_8xb32-300e_coco --dest ./checkpoints
运行代码,核心是定义inferencer和使用inferencer进行推理两行:
from mmdet.apis import DetInferencer
# Choose to use a config
model_name = 'rtmdet_tiny_8xb32-300e_coco'
# Setup a checkpoint file to load
checkpoint = './checkpoints/rtmdet_tiny_8xb32-300e_coco_20220902_112414-78e30dcc.pth'
# Set the device to be used for evaluation
device = 'cpu'
# Initialize the DetInferencer
inferencer = DetInferencer(model_name, checkpoint, device)
# Use the detector to do inference
img = 'demo.jpg'
result = inferencer(img, out_dir='./output')
# Show the structure of result dict
from rich.pretty import pprint
pprint(result, max_length=4)
# Show the output image
from PIL import Image
Image.open('./output/vis/demo.jpg')
3. 自定义数据进行训练
3.1 准备数据
建议使用coco格式,参见https://cocodataset.org/#format-data。文件从头至尾按照顺序分为以下段落:
{
“info”: info,
“licenses”: [license],
“images”: [imag

本文详细介绍了如何使用OpenMIM安装MMDetection库,提供了一个测试案例,包括数据准备、配置文件编写、模型训练过程以及在MacM2芯片上的调整。还介绍了MMYOLO、MMDetection3D等其他相关库。
最低0.47元/天 解锁文章
3980

被折叠的 条评论
为什么被折叠?



