https://github.com/facebookresearch/detectron2
detectron2-master.zip
我下载的detectron2版本是0.2.1
detectron2_ubuntu.tar.gz就不用测试了,只是安装detectron2环境
重点参考detectron2_train(ubuntu).tar.gz
深度学习目标检测框架 detectron2 安装流程
https://zhuanlan.zhihu.com/p/106853715
#新建虚拟环境
conda create --name mydetection_python3.7.3 python=3.7.3
source ~/anaconda3/bin/activate mydetection_python3.7.3
cd /home/liuhao/PycharmProjects/Python_3rdparty
#虽然/Detectron2_download/detectron2-master/docs/requirements.txt写的是torch-1.5.0和torchvision-0.6.0
pip install ./torchvision0.5.0/*.whl #对应torch-1.4.0
pip install ./opencv-python3.4.6/*.whl
#安装tensorboard
pip install ./tensorflow2.0.0/cachetools-4.1.1-py3-none-any.whl ./tensorflow2.0.0/rsa-4.6-py3-none-any.whl ./tensorflow2.0.0/pyasn1-0.4.8-py2.py3-none-any.whl ./tensorflow2.0.0/pyasn1_modules-0.2.8-py2.py3-none-any.whl ./tensorflow2.0.0/zipp-3.1.0-py3-none-any.whl ./tensorflow2.0.0/importlib_metadata-1.7.0-py2.py3-none-any.whl ./tensorflow2.0.0/oauthlib-3.1.0-py2.py3-none-any.whl ./tensorflow2.0.0/chardet-3.0.4-py2.py3-none-any.whl ./tensorflow2.0.0/idna-2.10-py2.py3-none-any.whl ./tensorflow2.0.0/urllib3-1.25.9-py2.py3-none-any.whl ./tensorflow2.0.0/requests_oauthlib-1.3.0-py2.py3-none-any.whl ./tensorflow2.0.0/requests-2.24.0-py2.py3-none-any.whl ./tensorflow2.0.0/Werkzeug-1.0.1-py2.py3-none-any.whl ./tensorflow2.0.0/six-1.15.0-py2.py3-none-any.whl ./tensorflow2.0.0/google_auth_oauthlib-0.4.1-py2.py3-none-any.whl ./tensorflow2.0.0/wheel-0.34.2-py2.py3-none-any.whl ./tensorflow2.0.0/Markdown-3.2.2-py3-none-any.whl ./tensorflow2.0.0/absl_py-0.9.0-py3-none-any.whl ./tensorflow2.0.0/grpcio-1.30.0-cp37-cp37m-manylinux2010_x86_64.whl ./tensorflow2.0.0/protobuf-3.12.2-cp37-cp37m-manylinux1_x86_64.whl ./tensorflow2.0.0/setuptools-47.3.1-py3-none-any.whl ./tensorflow2.0.0/google_auth-1.18.0-py2.py3-none-any.whl ./tensorflow2.0.0/numpy-1.19.0-cp37-cp37m-manylinux2010_x86_64.whl ./tensorflow2.0.0/tensorboard-2.0.2-py3-none-any.whl
pip install fvcore -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install cython -i https://pypi.tuna.tsinghua.edu.cn/simple/
pip install pycocotools -i https://pypi.tuna.tsinghua.edu.cn/simple/
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/Python_3rdparty$ pip show tensorboard
Name: tensorboard
Version: 2.0.2
Summary: TensorBoard lets you watch Tensors Flow
Home-page: https://github.com/tensorflow/tensorboard
Author: Google Inc.
Author-email: [email protected]
License: Apache 2.0
Location: /home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages
Requires: setuptools, numpy, google-auth, protobuf, werkzeug, google-auth-oauthlib, wheel, absl-py, markdown, grpcio, six, requests
Required-by:
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/Python_3rdparty$
/detectron2-master/docs/requirements.txt 仅作为参考,直接进行下一步安装,缺啥需要的库就安装一下
termcolor
numpy
tqdm
docutils==0.16
# https://github.com/sphinx-doc/sphinx/commit/7acd3ada3f38076af7b2b5c9f3b60bb9c2587a3d
git+git://github.com/sphinx-doc/sphinx.git@7acd3ada3f38076af7b2b5c9f3b60bb9c2587a3d
recommonmark==0.6.0
sphinx_rtd_theme
mock
matplotlib
termcolor
yacs
tabulate
cloudpickle
Pillow==6.2.2
future
requests
six
git+git://github.com/facebookresearch/fvcore.git
https://download.pytorch.org/whl/cpu/torch-1.5.0%2Bcpu-cp37-cp37m-linux_x86_64.whl
https://download.pytorch.org/whl/cpu/torchvision-0.6.0%2Bcpu-cp37-cp37m-linux_x86_64.whl
#在/Detectron2_download/detectron2-master文件夹下面打开终端
source ~/anaconda3/bin/activate mydetection_python3.7.3
python3 ./setup.py develop #我用的这个
或者pip install -e . #可能需要联网下载安装future;
#==========================================================================
#会在/home/liuhao/anaconda3/envs/mydetection_python3.7.3/lib/python3.7/site-packages/生成:
easy-install.pth:
/home/liuhao/PycharmProjects/DeepLearning_liuhao/Detectron2_download/detectron2-master
detectron2.egg-link
#会在/home/liuhao/PycharmProjects/DeepLearning_liuhao/CenterNet_download/DCNv2/生成:
build文件夹(里面有_C.cpython-37m-x86_64-linux-gnu.so)
detectron2.egg-info文件夹
......
Building wheels for collected packages: fvcore
Building wheel for fvcore (setup.py) ... done
Created wheel for fvcore: filename=fvcore-0.1.2.post20200912-py3-none-any.whl size=43994 sha256=6847c087ed04ebd1952672263a971c8b08fb170792ebee3d90fc33b426010712
Stored in directory: /home/liuhao/.cache/pip/wheels/f7/93/d9/8b0c812517efbb9d22a48b6755a8aed255207d9dbde7f68228
Successfully built fvcore
Installing collected packages: yacs, tabulate, cloudpickle, mock, portalocker, fvcore, future, pydot, detectron2
Running setup.py develop for detectron2
Successfully installed cloudpickle-1.6.0 detectron2 future-0.18.2 fvcore-0.1.2.post20200912 mock-4.0.2 portalocker-2.0.0 pydot-1.4.1 tabulate-0.8.7 yacs-0.1.8
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/Detectron2_liuhao/detectron2-master$
pip show detectron2
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~$ pip show detectron2
Name: detectron2
Version: 0.2.1
Summary: Detectron2 is FAIR's next-generation research platform for object detection and segmentation.
Home-page: https://github.com/facebookresearch/detectron2
Author: FAIR
Author-email: None
License: UNKNOWN
Location: /home/liuhao/PycharmProjects/DeepLearning_liuhao/Detectron2_download/detectron2-master
Requires: termcolor, Pillow, yacs, tabulate, cloudpickle, matplotlib, mock, tqdm, tensorboard, fvcore, pycocotools, future, pydot
Required-by:
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~$
#在/Detectron2_download/detectron2-master文件夹下面打开终端
#在mydetectron2_python3.7.3环境中
source ~/anaconda3/bin/activate mydetection_python3.7.3
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/Detectron2_liuhao/detectron2-master$ python3 ./demo/demo.py -h
usage: demo.py [-h] [--config-file FILE] [--webcam]
[--video-input VIDEO_INPUT] [--input INPUT [INPUT ...]]
[--output OUTPUT] [--confidence-threshold CONFIDENCE_THRESHOLD]
[--opts ...]
Detectron2 demo for builtin models
optional arguments:
-h, --help show this help message and exit
--config-file FILE path to config file
--webcam Take inputs from webcam.
--video-input VIDEO_INPUT
Path to video file.
--input INPUT [INPUT ...]
A list of space separated input images; or a single
glob pattern such as 'directory/*.jpg'
--output OUTPUT A file or directory to save output visualizations. If
not given, will show output in an OpenCV window.
--confidence-threshold CONFIDENCE_THRESHOLD
Minimum score for instance predictions to be shown
--opts ... Modify config options using the command-line 'KEY
VALUE' pairs
(mydetection_python3.7.3) liuhao@liuhao-Lenovo:~/PycharmProjects/DeepLearning_liuhao/Detectron2_liuhao/detectron2-master$
在/maskrcnn-benchmark-models/文件夹里面
在/model_zoo/文件夹里面
#必须要使用yaml文件,里面还有其他设置
#===========================================================================
#1.执行一下下面命令,立马结束,会生成/home/liuhao/.torch/fvcore_cache/detectron2/ImageNetPretrained/MSRA/文件夹
python3 ./demo/demo.py --config-file ./configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input ../detectron2_liuhao/input/huaxue.jpg
#2.
#在/home/liuhao/.torch/fvcore_cache/detectron2/ImageNetPretrained/MSRA/下面执行
ln -s /home/liuhao/PycharmProjects/DeepLearning_liuhao/Detectron2_download/maskrcnn-benchmark-models/R-50.pkl ./
注意/Detectron2_download/detectron2-master/detectron2/data/datasets/builtin_meta.py里面的COCO_CATEGORIES
#===========================================================================
#1 目标检测
#这种方式才会在/home/liuhao/.torch/fvcore_cache/detectron2/生成对应文件夹,并拷贝对应权重文件到这个文件夹
python3 ./demo/demo.py --config-file=./configs/COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml --input=../detectron2_liuhao/input/input.jpg --opts MODEL.WEIGHTS detectron2://COCO-Detection/faster_rcnn_R_50_FPN_3x/137257794/model_final_280758.pkl
#这种方式不会生成文件夹
python3 ./demo/demo.py --config-file=./configs/COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml --input=../code_liuhao/input/input.jpg --confidence-threshold=0.8 --opts MODEL.WEIGHTS ../../Detectron2_download/model_zoo/model_final_280758.pkl
python3 ./demo/demo.py --config-file=./configs/COCO-Detection/faster_rcnn_R_50_FPN_3x.yaml --input=../code_liuhao/input/1.jpg --confidence-threshold=0.8 --opts MODEL.WEIGHTS ../../Detectron2_download/model_zoo/model_final_280758.pkl
#===========================================================================
#2 实例分割
#这种方式才会在/home/liuhao/.torch/fvcore_cache/detectron2/生成对应文件夹,并拷贝对应权重文件到这个文件夹
python3 ./demo/demo.py --config-file=./configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input=../detectron2_liuhao/input/input.jpg --opts MODEL.WEIGHTS detectron2://COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x/137849600/model_final_f10217.pkl
#这种方式不会生成文件夹
python3 ./demo/demo.py --config-file=./configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input=../code_liuhao/input/input.jpg --confidence-threshold=0.8 --opts MODEL.WEIGHTS ../../Detectron2_download/model_zoo/model_final_f10217.pkl
python3 ./demo/demo.py --config-file=./configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input=../code_liuhao/input/1.jpg --confidence-threshold=0.8 --opts MODEL.WEIGHTS ../../Detectron2_download/model_zoo/model_final_f10217.pkl
#===========================================================================
#3 关键点检测
#这种方式才会在/home/liuhao/.torch/fvcore_cache/detectron2/生成对应文件夹,并拷贝对应权重文件到这个文件夹
python3 ./demo/demo.py --config-file=./configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x.yaml --input=../detectron2_liuhao/input/input.jpg --opts MODEL.WEIGHTS detectron2://COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x/137849621/model_final_a6e10b.pkl
#这种方式不会生成文件夹
python3 ./demo/demo.py --config-file=./configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x.yaml --input=../code_liuhao/input/input.jpg --confidence-threshold=0.8 --opts MODEL.WEIGHTS ../../Detectron2_download/model_zoo/model_final_a6e10b.pkl
python3 ./demo/demo.py --config-file=./configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x.yaml --input=../code_liuhao/input/1.jpg --confidence-threshold=0.8 --opts MODEL.WEIGHTS ../../Detectron2_download/model_zoo/model_final_a6e10b.pkl
#===========================================================================
#4 全景分割
#这种方式才会在/home/liuhao/.torch/fvcore_cache/detectron2/生成对应文件夹,并拷贝对应权重文件到这个文件夹
python3 ./demo/demo.py --config-file=./configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_3x.yaml --input=../detectron2_liuhao/input/input.jpg --opts MODEL.WEIGHTS detectron2://COCO-PanopticSegmentation/panoptic_fpn_R_50_3x/139514519/model_final_c10459.pkl
#这种方式不会生成文件夹
python3 ./demo/demo.py --config-file=./configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_3x.yaml --input=../code_liuhao/input/input.jpg --confidence-threshold=0.8 --opts MODEL.WEIGHTS ../../Detectron2_download/model_zoo/model_final_c10459.pkl
python3 ./demo/demo.py --config-file=./configs/COCO-PanopticSegmentation/panoptic_fpn_R_50_3x.yaml --input=../code_liuhao/input/1.jpg --confidence-threshold=0.8 --opts MODEL.WEIGHTS ../../Detectron2_download/model_zoo/model_final_c10459.pkl
#摄像头
将--input ../code_liuhao/input/huaxue.jpg换成--webcam
python3 ./demo/demo.py --config-file=./configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --webcam --confidence-threshold=0.8 --opts MODEL.WEIGHTS ../../Detectron2_download/model_zoo/model_final_f10217.pkl
#视频
将--input=../code_liuhao/input/huaxue.jpg换成--video-input=../detectron2_liuhao/input/road.mp4
python3 ./demo/demo.py --config-file=./configs/COCO-Keypoints/keypoint_rcnn_R_50_FPN_3x.yaml --video-input=../../科比0.4秒绝杀热火.mp4 --confidence-threshold=0.8 --opts MODEL.WEIGHTS ../../Detectron2_download/model_zoo/model_final_a6e10b.pkl
#=======================================================
#检测图片1.jpg
python3 ./demo/demo.py --config-file=./configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input=../code_liuhao/input/1.jpg --confidence-threshold=0.8 --output=../code_liuhao/output/result_1 --opts MODEL.WEIGHTS ../../Detectron2_download/model_zoo/model_final_f10217.pkl
#=======================================================
#检测图片input.jpg
python3 ./demo/demo.py --config-file=./configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input=../code_liuhao/input/input.jpg --confidence-threshold=0.8 --output=../code_liuhao/output/result_input --opts MODEL.WEIGHTS ../../Detectron2_download/model_zoo/model_final_f10217.pkl
#=======================================================
#检测图片huaxue.jpg
python3 ./demo/demo.py --config-file=./configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input=../code_liuhao/input/huaxue.jpg --confidence-threshold=0.8 --output=../code_liuhao/output/result_huaxue --opts MODEL.WEIGHTS ../../Detectron2_download/model_zoo/model_final_f10217.pkl
#=======================================================
#检测图片liuhao01.jpeg
python3 ./demo/demo.py --config-file=./configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input=../code_liuhao/input/liuhao01.jpeg --confidence-threshold=0.8 --output=../code_liuhao/output/result_liuhao01 --opts MODEL.WEIGHTS ../../Detectron2_download/model_zoo/model_final_f10217.pkl
#=======================================================
#检测图片liuhao02.jpeg
python3 ./demo/demo.py --config-file=./configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input=../code_liuhao/input/liuhao02.jpeg --confidence-threshold=0.8 --output=../code_liuhao/output/result_liuhao02 --opts MODEL.WEIGHTS ../../Detectron2_download/model_zoo/model_final_f10217.pkl
#=======================================================
#检测图片liuhao03.jpeg
python3 ./demo/demo.py --config-file=./configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input=../code_liuhao/input/liuhao03.jpeg --confidence-threshold=0.8 --output=../code_liuhao/output/result_liuhao03 --opts MODEL.WEIGHTS ../../Detectron2_download/model_zoo/model_final_f10217.pkl
#用pycharm打开/Detectron2_liuhao/detectron2_liuhao/文件夹
#使用mydetectron2_python3.7.3环境
python3 ./demo脚本说明.py
Detectron2安装测试(这里面包含了代码测试)
https://blog.csdn.net/happyday_d/article/details/103484213
#用pycharm打开/Detectron2_liuhao/detectron2_liuhao/文件夹
#使用mydetectron2_python3.7.3环境
python3 ./demo自己写的脚本.py
detectron2(目标检测框架)无死角玩转-00:目录
https://blog.csdn.net/weixin_43013761/article/details/104006026
接下来,我会为大家无死角的解析detectron2(基于pytorch的目标检测框架),之前的文章,如下(以下是我工作的所有项目,每一个项目都是,我都做了百分百的详细解读,随着项目增多,为了方便不臃肿,所以给出以下链接)
视觉工作项目-为后来的你,提供一份帮助!
我相信,关于detectron2(基于pytorch的目标检测框架)的讲解,我的这一系列博客或许不是国内最早的,但是肯定是最详细的,废话就不多说了,我们直接开始吧!
(01)detectron2(目标检测框架)无死角玩转-01:框架安装,以及demo测试:https://blog.csdn.net/weixin_43013761/article/details/104022615
(02)detectron2(目标检测框架)无死角玩转-02:训练,测试coco数据:https://blog.csdn.net/weixin_43013761/article/details/104027656
(03)detectron2(目标检测框架)无死角玩转-03:配置config解析-实时更新:https://blog.csdn.net/weixin_43013761/article/details/104030359
(04)detectron2(目标检测框架)无死角玩转-04:训练自己的数据:https://blog.csdn.net/weixin_43013761/article/details/104032429
(05)detectron2(目标检测框架)无死角玩转-05:源码详解(1)-总体架构分析:https://blog.csdn.net/weixin_43013761/article/details/104043605
(06)detectron2(目标检测框架)无死角玩转-06:源码详解(2)-Trainer继承关系,Hook:https://blog.csdn.net/weixin_43013761/article/details/104092658
(07)detectron2(目标检测框架)无死角玩转-07:源码详解(3)-模型构建-RetinaNet为例:https://blog.csdn.net/weixin_43013761/article/details/104098263
(08)detectron2(目标检测框架)无死角玩转-08:源码详解(4)-数据预处理,数据增强:https://blog.csdn.net/weixin_43013761/article/details/104106792
(09)detectron2(目标检测框架)无死角玩转-09:源码详解(5)-anchor生成:https://blog.csdn.net/weixin_43013761/article/details/104194978
(10)detectron2(目标检测框架)无死角玩转-10:源码详解(6)-anchor的使用,loss计算:https://blog.csdn.net/weixin_43013761/article/details/104714022
#======================================================================================
detectron2(目标检测框架)无死角玩转-01:框架安装,以及demo测试(winds + linux)
https://blog.csdn.net/weixin_43013761/article/details/104022615
#在/detectron2-master文件夹下面打开终端
source ~/anaconda3/bin/activate mydetectron2_python3.7.3
python3 ./demo/demo.py --config-file ./configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input ../code_liuhao/input/input1.jpg --opts MODEL.WEIGHTS ../../Detectron2_download/model_zoo/model_final_f10217.pkl