当前位置: 首页> 游戏> 网游 > mmdetction使用指南

mmdetction使用指南

时间:2025/7/14 19:24:07来源:https://blog.csdn.net/weixin_41012399/article/details/142175847 浏览次数:0次

一、简介
参考:https://blog.csdn.net/Adam897/article/details/127534510
MMDetection是MMLab家族的一员,是由香港中文大学和商汤科技共同推出的,以一个统一的架构支撑了15个大方向的研究领域。MMDetection依赖Pytorch和MMCV,因此安装之前需要先安装这两个库。MMCV有两mmcv-full和mmcv两个版本,两者差别在于是否包含CUDA操作,如果不需要使用CUDA可以安装mmcv,不过官方还是推荐安装完整版的mmcv-full。还有MMDetection3D,后续使用到再做研究。
二、安装
参考:https://blog.csdn.net/ArthurHai521/article/details/138356084
1、在线安装

pip install mmcv
pip install mmdet

2、离线安装

git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -v -e .

去官网指定下载地址https://download.openmmlab.com/mmcv/dist/cu118/torch2.1/index.html下载对应版本mmcv:
mmcv-2.1.0-cp310-cp310-manylinux1_x86_64.whl
安装:pip install mmcv-2.1.0-cp310-cp310-manylinux1_x86_64.whl
验证是否安装成功

// An highlighted block
import osfrom mmdet.apis import init_detector, inference_detectordef demo_mmdet():base_dir = r'D:\Program Files\Third_Part_Lib\mmdetection'       # mmdetection的安装目录config_file = os.path.join(base_dir, r'configs\faster_rcnn\faster_rcnn_r50_fpn_1x_coco.py')# download the checkpoint from model zoo and put it in `checkpoints/`# url: https://download.openmmlab.com/mmdetection/v2.0/faster_rcnn/faster_rcnn_r50_fpn_1x_coco/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pthcheckpoint_file = r'checkpoints\faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'# 根据配置文件和 checkpoint 文件构建模型model = init_detector(config_file, checkpoint_file, device='cuda:0')# 测试单张图片并展示结果img = os.path.join(base_dir, r'demo\demo.jpg') # 或者 img = mmcv.imread(img),这样图片仅会被读一次result = inference_detector(model, img)# 在一个新的窗口中将结果可视化model.show_result(img, result, out_file=None, show=True) ##有的版本可能报错没有show_result,就使用https://blog.csdn.net/csy1021/article/details/132080887方法if __name__ == '__main__':demo_mmdet()

三、使用
1、添加自定义模型
https://blog.csdn.net/qq_41627642/article/details/124754147

关键字:mmdetction使用指南

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: