摘要:近日,開源了和的實現(xiàn)基準(zhǔn)。是商湯和港中文近日聯(lián)合開源的基于的開源目標(biāo)檢測工具包。你也可以配置你自己的到數(shù)據(jù)集的路徑。
近日,F(xiàn)acebook AI Research 開源了 Faster R-CNN 和 Mask R-CNN 的 PyTorch 1.0 實現(xiàn)基準(zhǔn):MaskRCNN-Benchmark。相比 Detectron 和 mmdetection,MaskRCNN-Benchmark 的性能相當(dāng),并擁有更快的訓(xùn)練速度和更低的 GPU 內(nèi)存占用。
項目地址:https://github.com/facebookresearch/maskrcnn-benchmark
MaskRCNN-Benchmark 目標(biāo)檢測示例。
Detectron 和 mmdetection
Detectron 是 Facebook AI Research 實現(xiàn)頂尖目標(biāo)檢測算法(包括 Mask R-CNN)的軟件系統(tǒng)。該系統(tǒng)是基于 Python 和深度學(xué)習(xí)框架 Caffe 2 而構(gòu)建的。Detectron 目前包含以下目標(biāo)檢測算法的實現(xiàn):Mask R-CNN 、RetinaNet、Faster R-CNN、RPN、Fast R-CNN、R-FCN。
mmdetection 是商湯和港中文近日聯(lián)合開源的基于 PyTorch 的開源目標(biāo)檢測工具包。該工具包支持 Mask R-CNN 等多種流行的檢測框架,讀者可在 PyTorch 環(huán)境下測試不同的預(yù)訓(xùn)練模型及訓(xùn)練新的檢測分割模型。和 Detectron 對比,mmdetection 的性能稍高、訓(xùn)練速度稍快、所需顯存稍小。
mmdetection 第一個版本中實現(xiàn)了 RPN、Fast R-CNN、Faster R-CNN、Mask R-CNN,近期還計劃放出 RetinaNet 和 Cascade R-CNN。但更重要的是,基于 PyTorch 和基于 Caffe2 的 code 相比,易用性是有代差的。成功安裝 Detectron 的時間,大概可以裝好一打的 mmdetection。
MaskRCNN-Benchmark 項目亮點:
PyTorch 1.0:相當(dāng)或者超越 Detectron 準(zhǔn)確率的 RPN、Faster R-CNN、Mask R-CNN 實現(xiàn);
非??欤河?xùn)練速度是 Detectron 的兩倍,是 mmdection 的 1.3 倍。
節(jié)省內(nèi)存:在訓(xùn)練過程中使用的 GPU 內(nèi)存比 mmdetection 少大約 500MB;
使用多 GPU 訓(xùn)練和推理;
批量化推理:可以在每 GPU 每批量上使用多張圖像進(jìn)行推理;
支持 CPU 推理:可以在推理時間內(nèi)于 CPU 上運行。
提供幾乎所有參考 Mask R-CNN 和 Faster R-CNN 配置的預(yù)訓(xùn)練模型,具有 1x 的 schedule。
MaskRCNN-Benchmark Model Zoo 基線模型性能數(shù)據(jù)
地址:https://github.com/facebookresearch/maskrcnn-benchmark/blob/master/MODEL_ZOO.md
硬件
8 NVIDIA V100 GPUs
軟件:
PyTorch version: 1.0.0a0+dd2c487
CUDA 9.2
CUDNN 7.1
NCCL 2.2.13-1
端到端 Mask R-CNN 和 Faster R-CNN 基線模型
所有的基線模型都使用了和 Detectron 相同的實驗設(shè)置,檢測模型權(quán)重使用 Caffe2 中的 ImageNet 權(quán)重初始化,這和 Detectron 是一樣的。預(yù)訓(xùn)練模型通過下表中的 model id 鏈接獲取。
和 Detectron、mmdetection 的性能對比
訓(xùn)練速度
下表中的數(shù)據(jù)單位是秒/迭代,越低越好。(mmdetection 中備注的硬件和 maskrcnn_benchmark 是不同的)
訓(xùn)練內(nèi)存(越低越好)
推理準(zhǔn)確率(越高越好)
Webcam 和 Jupyter notebook demo
該項目提供了一個簡單的 webcam demo,展示如何使用 maskrcnn_benchmark 進(jìn)行推理:
cd demo# by default, it runs on the GPU# for best results, use min-image-size 800
python webcam.py --min-image-size 800# can also run it on the CPU
python webcam.py --min-image-size 300 MODEL.DEVICE cpu# or change the model that you want to use
python webcam.py --config-file ../configs/caffe2/e2e_mask_rcnn_R_101_FPN_1x_caffe2.py --min-image-size 300 MODEL.DEVICE cpu# in order to see the probability heatmaps, pass --show-mask-heatmaps
python webcam.py --min-image-size 300 --show-mask-heatmaps MODEL.DEVICE cpu
安裝
教程地址:https://github.com/facebookresearch/maskrcnn-benchmark/blob/master/INSTALL.md
安裝要求:
PyTorch 1.0 的每日測試版本,安裝說明:https://pytorch.org/get-started/locally/
torchvision
cocoapi
yacs
(可選)OpenCV(用于 webcam demo)
# maskrnn_benchmark and coco api dependencies
pip install ninja yacs cython
# follow PyTorch installation in https://pytorch.org/get-started/locally/# we give the instructions for CUDA 9.0
conda install pytorch-nightly -c pytorch
# install torchvisioncd ~/github
git clone [email protected]:pytorch/vision.gitcd vision
python setup.py install
# install pycocotoolscd ~/github
git clone [email protected]:cocodataset/cocoapi.gitcd cocoapi/PythonAPI
python setup.py build_ext install
# install PyTorch Detectioncd ~/github
git clone [email protected]:facebookresearch/maskrcnn-benchmark.gitcd maskrcnn-benchmark# the following will install the lib with# symbolic links, so that you can modify# the files if you want and won"t need to# re-build it
python setup.py build develop
通過幾行代碼進(jìn)行推理
該項目提供了一個 helper 類來簡化編寫使用預(yù)訓(xùn)練模型進(jìn)行推理的流程,只要在 demo 文件夾下運行以下代碼:
from maskrcnn_benchmark.config import cfgfrom predictor import COCODemo
config_file = "../configs/caffe2/e2e_mask_rcnn_R_50_FPN_1x_caffe2.yaml"# update the config options with the config file
cfg.merge_from_file(config_file)# manual override some options
cfg.merge_from_list(["MODEL.DEVICE", "cpu"])
coco_demo = COCODemo(
? ? cfg,
? ? min_image_size=800,
? ? confidence_threshold=0.7,
)# load image and then run prediction
image = ...
predictions = coco_demo.run_on_opencv_image(image)
在 COCO 數(shù)據(jù)集上執(zhí)行訓(xùn)練
為了運行以下示例,你首先需要安裝 maskrcnn_benchmark。你還需要下載 COCO 數(shù)據(jù)集,推薦按以下方式符號鏈接 COCO 數(shù)據(jù)集的路徑到 datasets/。我們使用來自 Detectron 的 GitHub 的 minival 和 valminusminival 集合。
# symlink the coco datasetcd ~/github/maskrcnn-benchmark
mkdir -p datasets/coco
ln -s /path_to_coco_dataset/annotations datasets/coco/annotations
ln -s /path_to_coco_dataset/train2014 datasets/coco/train2014
ln -s /path_to_coco_dataset/test2014 datasets/coco/test2014
ln -s /path_to_coco_dataset/val2014 datasets/coco/val2014
你也可以配置你自己的到數(shù)據(jù)集的路徑。為此,你需要讓 maskrcnn_benchmark/config/paths_catalog.py 指向你的數(shù)據(jù)集保存的位置。你也可以創(chuàng)建一個新的 paths_catalog.py 文件,其實現(xiàn)了相同的兩個類,并在訓(xùn)練過程中將它作為一個配置參數(shù) PATHS_CATALOG 傳遞。
單 GPU 訓(xùn)練
python /path_to_maskrnn_benchmark/tools/train_net.py --config-file "/path/to/config/file.yaml"
多 GPU 訓(xùn)練
該項目使用內(nèi)部的 torch.distributed.launch 以啟動多 GPU 訓(xùn)練。這個來自 PyTorch 的效用函數(shù)可以產(chǎn)生我們想要使用 GPU 數(shù)目的 Python 進(jìn)程,并且每個 Python 進(jìn)程只需要使用一個 GPU。
export NGPUS=8
python -m torch.distributed.launch --nproc_per_node=$NGPUS /path_to_maskrcnn_benchmark/tools/train_net.py --
添加你自己的數(shù)據(jù)集
該項目添加了對 COCO 類型數(shù)據(jù)集的支持,為在新數(shù)據(jù)集上訓(xùn)練添加支持可以通過以下方法實現(xiàn):
from maskrcnn_benchmark.structures.bounding_box import BoxList
class MyDataset(object):
? ? def __init__(self, ...):
? ? ? ? # as you would do normallydef __getitem__(self, idx):
? ? ? ? # load the image as a PIL Image
? ? ? ? image = ...# load the bounding boxes as a list of list of boxes# in this case, for illustrative purposes, we use# x1, y1, x2, y2 order.
? ? ? ? boxes = [[0, 0, 10, 10], [10, 20, 50, 50]]
? ? ? ? # and labels
? ? ? ? labels = torch.tensor([10, 20])
? ? ? ? # create a BoxList from the boxes
? ? ? ? boxlist = Boxlist(boxes, size=image.size, mode="xyxy")
? ? ? ? # add the labels to the boxlist
? ? ? ? boxlist.add_field("labels", labels)
? ? ? ? if self.transforms:
? ? ? ? ? ? image, boxlist = self.transforms(image, boxlist)
? ? ? ? # return the image, the boxlist and the idx in your datasetreturn image, boxlist, idx
? ? def get_img_info(self, idx):
? ? ? ? # get img_height and img_width. This is used if# we want to split the batches according to the asp
就這樣。你可以添加額外的字段到 boxlist,例如 segmentation masks(使用 structures.segmentation_mask.SegmentationMask),或甚至是你自己的實例類型。如果想了解 COCO 數(shù)據(jù)集實現(xiàn)的完整過程,可以查看:https://github.com/facebookresearch/maskrcnn-benchmark/blob/master/maskrcnn_benchmark/data/datasets/coco.py
聲明:文章收集于網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系小編及時處理,謝謝!
歡迎加入本站公開興趣群商業(yè)智能與數(shù)據(jù)分析群
興趣范圍包括各種讓數(shù)據(jù)產(chǎn)生價值的辦法,實際應(yīng)用案例分享與討論,分析工具,ETL工具,數(shù)據(jù)倉庫,數(shù)據(jù)挖掘工具,報表系統(tǒng)等全方位知識
QQ群:81035754
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/4816.html
摘要:現(xiàn)在,官方版開源代碼終于來了。同時發(fā)布的,是這項研究背后的一個基礎(chǔ)平臺。是的物體檢測平臺,今天宣布開源,它基于,用寫成,這次開放的代碼中就包含了的實現(xiàn)。說,將平臺開源出來,是想要加速世界各地實驗室的研究,推動物體檢測的進(jìn)展。 等代碼吧。從Mask R-CNN論文亮相至今的10個月里,關(guān)于它的討論幾乎都會以這句話收尾?,F(xiàn)在,官方版開源代碼終于來了。同時發(fā)布的,是這項研究背后的一個基礎(chǔ)平臺:De...
摘要:這個像素級別的圖像分割問題被等科學(xué)家解決,這個框架被稱為。由于圖像分割需要做到像素級,這與邊框分割不同,所以必然導(dǎo)致不準(zhǔn)確。 作者:chen_h微信號 & QQ:862251340微信公眾號:coderpai簡書地址:https://www.jianshu.com/p/867... 自從?Alex Krizhevsky, Geoff Hinton, and Ilya Sutskeve...
摘要:昨天,研究院開源了,業(yè)內(nèi)較佳水平的目標(biāo)檢測平臺。項目地址是實現(xiàn)頂尖目標(biāo)檢測算法包括的軟件系統(tǒng)。因此基本上已經(jīng)是最目前包含最全與最多目標(biāo)檢測算法的代碼庫了。 昨天,F(xiàn)acebook AI 研究院(FAIR)開源了 Detectron,業(yè)內(nèi)較佳水平的目標(biāo)檢測平臺。據(jù)介紹,該項目自 2016 年 7 月啟動,構(gòu)建于 Caffe2 之上,目前支持大量機(jī)器學(xué)習(xí)算法,其中包括 Mask R-CNN(何愷...
摘要:從標(biāo)題上可以看出,這是一篇在實例分割問題中研究擴(kuò)展分割物體類別數(shù)量的論文。試驗結(jié)果表明,這個擴(kuò)展可以改進(jìn)基準(zhǔn)和權(quán)重傳遞方法。 今年10月,何愷明的論文Mask R-CNN摘下ICCV 2017的較佳論文獎(Best Paper Award),如今,何愷明團(tuán)隊在Mask R-CNN的基礎(chǔ)上更近一步,推出了(以下稱Mask^X R-CNN)。這篇論文的第一作者是伯克利大學(xué)的在讀博士生胡戎航(清華...
摘要:自從和在年贏得了的冠軍,卷積神經(jīng)網(wǎng)絡(luò)就成為了分割圖像的黃金準(zhǔn)則。事實上,從那時起,卷積神經(jīng)網(wǎng)絡(luò)不斷獲得完善,并已在挑戰(zhàn)上超越人類。現(xiàn)在,卷積神經(jīng)網(wǎng)絡(luò)在的表現(xiàn)已超越人類。 卷積神經(jīng)網(wǎng)絡(luò)(CNN)的作用遠(yuǎn)不止分類那么簡單!在本文中,我們將看到卷積神經(jīng)網(wǎng)絡(luò)(CNN)如何在圖像實例分割任務(wù)中提升其結(jié)果。自從 Alex Krizhevsky、Geoff Hinton 和 Ilya Sutskever ...
閱讀 2735·2021-11-11 17:21
閱讀 627·2021-09-23 11:22
閱讀 3591·2019-08-30 15:55
閱讀 1651·2019-08-29 17:15
閱讀 583·2019-08-29 16:38
閱讀 921·2019-08-26 11:54
閱讀 2517·2019-08-26 11:53
閱讀 2763·2019-08-26 10:31