安装detectron2
python3.6,cuda10.1,
1 ) 安装detectron2参考下面几个文档,
但出现RuntimeError:Not compiled with GPU support,一直没解决(更改了detectron的clone方式和安装方式不再出现),
便新建conda环境,使用第二种方法ok
https://blog.csdn.net/sophia_xw/article/details/102561410
conda create -n d2p36 python=3.6
source activate d2p36 // use every reboot
pip install -U torch torchvision
conda install -c menpo opencv3
pip install -U
'git+https://github.com/facebookresearch/fvcore'
pip install cython
pip install
'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
//git clone https://github.com/facebookresearch/detectron2detectron2_repo这个没有试过
//pip install -e detectron2_repo
https://blog.csdn.net/jgj123321/article/details/105475027
git clone https://github.com/facebookresearch/detectron2.git
cd detectron2
python -m pip install -e .
https://blog.csdn.net/m0_37709262/article/details/102732057 也不行
//pip install'git+https://github.com/facebookresearch/detectron2.git' //linux找不到被clone到哪里了
//(add --user if youdon't have permission)
// Or, to install it from a local clone:
git clone https://github.com/facebookresearch/detectron2.git
cd detectron2 && pip install -e .
https://github.com/facebookresearch/detectron2/blob/master/INSTALL.md
//python -m pip install detectron2 -fhttps://dl.fbaipublicfiles.com/detectron2/wheels/cu101/index.html //linux找不到被clone到哪里了
2)安装参考这个,能正常运行demo,
conda create -n dt2p36 python=3.6
source activate dt2p36 // use every reboot
https://www.aiuai.cn/aifarm1288.html
依次参考安装依赖库
...
方式二:
git clone https://github.com/facebookresearch/detectron2.git
cd detectron2
python -m pip install -e .
出现一些错误或有些库使用的是python3.5的,用下面的命令更新解决
pip install -U torch torchvision
pip install -U torch pycocotools
pip install cython
3) demo脚本 每次要重启激活环境source activate dt2p36 // use every reboot
原文链接:https://blog.csdn.net/sophia_xw/article/details/102561410
//python demo/demo.py --config-file
configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input 001.jpg
--output results --opts MODEL.WEIGHTS models/model_final_f10217.pkl
注意点:
测试图片自己找,我的是000043.jpg,放在当前工程自己新建的文件夹images中;
当前工程下,新建results文件夹存储结果图片,我在服务器环境中,没有显示器,因此给个输出文件夹;
当前工程下,新建models文件夹用来放测试模型,当然,模型自己在model zoo链接中去下载;
其他参数:
在摄像头测试
用–webcam替代–input
视频文件测试
用–video-input替代–input
存储结果
给–output参数就行
https://blog.csdn.net/enwuone/article/details/104983976
python demo/demo.py --config-file
configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input 001.jpg
--output results --opts MODEL.WEIGHTS
detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl
参数解释
demo/demo.py:demo文件
–config-file:选择配置文件
–output:输出位置(如果想直接查看,删除这个参数即可)
MODEL.WEIGHTS:预先训练好的模型
pip install opencv-python --user // no module named cv2
4) others
RuntimeError: Not compiled with GPU support
//不生效,可以参考begin
https://www.cnblogs.com/marsggbo/p/11916859.html
官方提供的检验代码查看CUDA路径:
python -c 'import torch; from torch.utils.cpp_extension
import CUDA_HOME; print(torch.cuda.is_available(), CUDA_HOME)'
vim ~/.bashrc
export CUDA_HOME=/usr/local/cuda
source ~/.bashrc
Docker Runtime Error: Not Compiled with GPU support
https://github.com/facebookresearch/maskrcnn-benchmark/issues/167
https://blog.csdn.net/u011420347/article/details/85111815
https://ask.csdn.net/questions/769137
print(t.version.cuda)
print(t.cuda.device_count())
import torch as t
tensor=t.Tensor(3,4)
tensor.cuda(0)
google搜索,参考
https://github.com/facebookresearch/detectron2/issues/62
https://github.com/facebookresearch/detectron2/issues/267
//end