windows10裝detectron2-0.6,并運(yùn)行fasterrcnn
本文包含以下幾個(gè)內(nèi)容:detectron2環(huán)境配置(像個(gè)包的安裝),測(cè)試demo運(yùn)行,具體訓(xùn)練fasterrcnn代碼。作者水平有限,可能會(huì)存在一些理解錯(cuò)誤,歡迎討論指教。
便捷安裝方法一:
根據(jù)b站視頻:【實(shí)錄】win10配置Detectron2環(huán)境
https://www.bilibili.com/video/BV1j34y1Z7y9/?spm_id_from=333.999.0.0&vd_source=06f1bcf60c2e87fe8079a7c3e5ee6794
具體操作打開anaconda prompt
conda create -n detectron2 python=3.6
conda activate detectron2
conda install numpy matplotlib
pip install opencv-python
pip install pillow cython
以下語句二選一,第一句適應(yīng)于高算力GPU
Conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch?
Conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch
?
Python
Import torch
Torch.cuda.is_available()
若返回True即gpu可用
Exit()
?
從https://github.com/philferriere/cocoapi下載cocoapi-master,普通下載的cocoapi不適用于windows
Cd進(jìn)入cocoapi-master\PythonAPI路徑下(注意-e后面有個(gè)點(diǎn)"."
Cocoapi :pip install -e.
除了ninja和fvcore在這步盡量為必須步,其他步可嘗試可做可不做,出問題再改也可以
修改環(huán)境問題:
Conda install ninja ?一般為必備,需要緊跟cocoapi
pip install fvcore ?需求高,可跟ninja
以下三個(gè)文件具體路徑可從網(wǎng)上搜索
Cast.h: explicit operator type&() { return ((type)this->value); }
Cpp_extension.py: match = re.search(r’(\d+).(\d+).(\d+)’, compiler_info.decode(’ gbk’).strip()
Argument_spec.h: static const size_t ARG_SPEC_DEPTH_LIMIT = 128
從https://github.com/facebookresearch/detectron2下載detectron2-0.6
Cd進(jìn)入detectron2-0.6
Setup:pip install -e.
驗(yàn)證方法一:pip list查找是否有detectron2. 方法二:進(jìn)入python輸入import detectron2
復(fù)雜安裝方法二:
該方法過于復(fù)雜,成功難度較大,一般作為了解該架構(gòu)的補(bǔ)充,盡量使用第一種方法。
前置工作
安裝gcc,解決g++問題
下載tdm-gcc: https://jmeubank.github.io/tdm-gcc/download/
能解決“Microsoft Visual C++ 14.0 is required.”
conda install libpython m2w64-toolchain -c msys2
安裝vs2019桌面版中有關(guān)c++選項(xiàng),在開始菜單欄中的vs2019能找到x64 Native Tools Command Prompt for VS 2019即為成功
啟動(dòng)win+r,cmd測(cè)試cl.exe,若不存在則從vs2019中取出路徑并設(shè)置環(huán)境變量
正式配置
Conda create -n detectron2 python =3.6
Conda activate detectron2
Conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
Conda install cython gdal -c conda-forge
Pip install fvcore opencv-python
跟方法一一樣安裝cocoapi-master
其中代碼可為python setup.py build_ext --inplace
Python setup.py build_ext install
也可pip install pycocotools
出現(xiàn)錯(cuò)誤可嘗試conda install libpython
Conda install ninja
若有多個(gè)vs版本 set DISTUTILS_USE_SDK=1
找到之前提到的菜單欄vs2019 中的x64 native tools 右鍵找位置,直接復(fù)制位置信息可在代碼中執(zhí)行
Cd detectron2-0.6 執(zhí)行python setup.py build develop
?
Demo運(yùn)行
思路一:直接根據(jù)網(wǎng)絡(luò)資料新建demo在根目錄下,進(jìn)行測(cè)試
新建demo.py在pycharm中打開輸入一下代碼,并放入測(cè)試圖片test1.jpg運(yùn)行
?
思路二:利用官方給出的demo/demo.py修改配置并運(yùn)行。
Get_parser中參數(shù)修改
Config-file選擇任務(wù)配置,如maskrcnn分割,或fasterrcnn檢測(cè)
Input傳入圖片組
Output設(shè)置為輸出文件夾,否則默認(rèn)彈窗
Confidence-threshold置信度閾值
Opts 傳入鍵值對(duì),必為偶數(shù)數(shù)組,前為鍵后為值,例如:傳入權(quán)重,也可傳入運(yùn)行設(shè)備
Fasterrcnn具體代碼
1、裝包
2、注冊(cè)數(shù)據(jù)集
3、可視化訓(xùn)練集(標(biāo)準(zhǔn)的標(biāo)簽檢驗(yàn))
保存3張圖片到指定目錄下
4、訓(xùn)練網(wǎng)絡(luò)
5、通過驗(yàn)證集驗(yàn)證結(jié)果并輸出ap指標(biāo)
6、可視化預(yù)測(cè)結(jié)果,在實(shí)際圖片標(biāo)注框
?
?
參考網(wǎng)站
在GitHub上搜索detectron2排名第二的有教如何在windows上配置環(huán)境
Detectron2入門代碼教程——以Faster RCNN在自定義數(shù)據(jù)集上目標(biāo)檢測(cè)為例
https://blog.csdn.net/qq_43406895/article/details/125859062
如何在win10上運(yùn)行Faster R-CNN
https://www.jianshu.com/p/ff0fda1e8e2f
Detectron2入門代碼教程——以Faster RCNN在自定義數(shù)據(jù)集上目標(biāo)檢測(cè)為例
https://blog.csdn.net/qq_43406895/article/details/125859062
Detectron2訓(xùn)練自己的目標(biāo)檢測(cè)數(shù)據(jù)集
https://blog.csdn.net/weixin_43229348/article/details/120177569
Facebook detectron2訓(xùn)練faster rcnn
https://blog.csdn.net/Exploer_TRY/article/details/114407551
VOC和COCO數(shù)據(jù)集講解
https://blog.csdn.net/a15608445683/article/details/126648977
GitHub上訓(xùn)練棋子目標(biāo)檢測(cè)
https://github.com/TannerGilbert/Object-Detection-and-Image-Segmentation-with-Detectron2/blob/master/Detectron2_Detect_Chess_Detection.ipynb
找不到 cl.exe 解決辦法
https://blog.csdn.net/HaoZiHuang/article/details/125795675
Windows11安裝Detectron2(附詳細(xì)操作指南)https://blog.csdn.net/iracer/article/details/125755029
Window10下安裝detectron2(0.6版本)
https://zhuanlan.zhihu.com/p/501819672
detectron2安裝在win10并運(yùn)行測(cè)試--嘔心瀝血教程https://blog.csdn.net/qq_51882416/article/details/122060993
detecrton2、detectron+win10——個(gè)人配置經(jīng)驗(yàn)
https://blog.csdn.net/zxm_jimin/article/details/121253391
關(guān)于cpp_extension的那些bug
https://blog.csdn.net/weixin_42990464/article/details/109294332
在win10上編譯detectron2的坎坷路
https://zhuanlan.zhihu.com/p/425631249
深度學(xué)習(xí):利用Detectron2訓(xùn)練自己的數(shù)據(jù)集之模型評(píng)估——解決AP=0問題
https://blog.csdn.net/weixin_42565090/article/details/114533436