目录
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‘
报错: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代码在第二点中
安装注意点:
- python 建议 3.8 版本
- pytorch在官网https://pytorch.org/get-started/locally/查看安装
- 个人建议通过 pip 命令安装 MMEngine:
pip install mmengine -i https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn
- mmcv 不能直接 pip install mmcv 正确方法:(找到自己对应 系统,cuda ,torch 版本的mmcv 安装)参考连接如下:
https://blog.csdn.net/qq_36276587/article/details/127809462 - mmdet安装个人建议:用豆瓣网镜像下载: https://mirrors.cloud.tencent.com/pypi/simple/
pip install mmdet -i https://mirrors.cloud.tencent.com/pypi/simple/
-
推荐 scipy==1.10.1 numpy==1.24.4 防止 scipy 和 numpy 版本冲突
二、验证是否安装成功
-
中途遇到差什么包就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)
三、可能遇到的问题及其解决方法总结
-
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 -
git克隆错误:fatal: The remote end hung up unexpectedly
解决方法:https://www.jianshu.com/p/5996bc33d789 -
报错: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/
-
报错: 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/
-
报错: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/