MMDetection环境配置和验证教程 干货笔记 !!

目录

一、环境配置

个人亲测详细步骤:

安装注意点:

二、验证是否安装成功

 三、可能遇到的问题及其解决方法总结

git 报错:error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8)

git克隆错误:fatal: The remote end hung up unexpectedly

报错:FileNotFoundError: Could not find module ‘D:\Anaconda3\envs\labe\Library\bin\geos_c.dll‘

 报错: ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

报错:ImportError: numpy.core.multiarray failed to import


mmdetection官网教程文档:https://mmdetection.readthedocs.io/zh-cn/latest/get_started.html#id6

一、环境配置

个人亲测详细步骤:

【在你的Anaconda中的 Anaconda Prompt 命令窗口中进行以下操作】

//创建 conda虚拟环境 其中 D:\Anaconda3\envs\openmmlab 为你的虚拟环境存放位置 
conda create --prefix D:\Anaconda3\envs\openmmlab  python=3.8 -y  

//激活虚拟环境 
conda activate openmmlab

//下载pytorch CUDA 11.7
conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.7 -c pytorch -c nvidia

//安装MMEngine 运用清华网下载
pip install mmengine==0.8.4 -i https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn

//安装mmcv  
//可根据自己配置查找下载 可查找连接:https://mmcv.readthedocs.io/en/latest/get_started/installation.html
pip install mmcv==2.0.0 -i https://download.openmmlab.com/mmcv/dist/cu117/torch2.0/index.html

//下载代码
git clone https://github.com/open-mmlab/mmdetection.git

//配置环境
cd mmdetection 
pip install -r requirements/build.txt pip install -v -e .

//验证安装:python代码在第二点中

安装注意点:

pip install mmengine -i https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn

二、验证是否安装成功

  • 中途遇到差什么包就pip下载 或 运用豆瓣网镜像下载:
pip install 指定包名 -i https://mirrors.cloud.tencent.com/pypi/simple/
  • config_file 配置文件路径 

在你的 mmdetection\configs\faster_rcnn\faster-rcnn_r50_fpn_1x_coco.py 中

  • checkpoint_file :

先创建 checkpoints 文件夹在 mmdetection 中,并从以下链接下载对应权重文件 放到 checkpoints 文件夹中https://download.openxlab.org.cn/models/mmdetection/FasterR-CNN/weight/faster-rcnn_r50_fpn_1x_coco

  • 验证代码如下所示 
from mmdet.apis import init_detector, inference_detector
import mmcv

# 指定模型的配置文件和 checkpoint 文件路径
config_file = 'configs/faster_rcnn/faster-rcnn_r50_fpn_1x_coco.py'
checkpoint_file = 'checkpoints/faster_rcnn_r50_fpn_1x_coco_20200130-047c8118.pth'

# 根据配置文件和 checkpoint 文件构建模型
model = init_detector(config_file, checkpoint_file, device='cuda:0')  # or device='cuda:0'

# 测试单张图片并展示结果
img = 'demo/demo.jpg'  # 或者 img = mmcv.imread(img),这样图片仅会被读一次
result = inference_detector(model, img)
print(result)

 三、可能遇到的问题及其解决方法总结

  1. git 报错:error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8)

    解决方法:https://blog.csdn.net/qq_34466755/article/details/113748527
  2. git克隆错误:fatal: The remote end hung up unexpectedly

    解决方法:https://www.jianshu.com/p/5996bc33d789
  3. 报错:FileNotFoundError: Could not find module ‘D:\Anaconda3\envs\labe\Library\bin\geos_c.dll‘

    方法1:大部分人是没有导入 “shapely” 这个依赖。只需要导入即可
    pip install shapely

    方法2:导入这个还是报错,基本就是和你的python版本不对 【可先卸载后重新从腾讯镜像中下载即可】
    pip uninstall shapely
    ​​​​​​​pip insall shapely -i https://mirrors.cloud.tencent.com/pypi/simple/scipy/
  4.  报错: ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

    解决方法:经过上网查找资料发现时numpy的版本问题,在最新版本的numpy中已经解决了这个问题【可先卸载后重新从腾讯镜像中下载即可】
     
    pip uninstall numpy
    pip install numpy==1.24.4 -i https://mirrors.cloud.tencent.com/pypi/simple/scipy/
  5. 报错:ImportError: numpy.core.multiarray failed to import 

    解决方法:numpy版本问题【从豆瓣网镜像重新下载即可(个人下载版本:1.24.4)】
     
    pip uninstall numpy
    pip install numpy==1.24.4 -i https://mirrors.cloud.tencent.com/pypi/simple/scipy/

  • 16
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值