目標檢測|安裝 mmdetection

  • github:https://github.com/open-mmlab/mmdetection
  • paper:https://arxiv.org/abs/1906.07155

一、簡介

  • mmdetetion是香港中文大學 MMLab實驗室開源的目標檢測框架, 是一款基於pytorch 深度學習框架搭建的目標檢測庫,包含很多主流的算法,包括anchor、anchor-free, one-stage,two-stage。

二、安裝

  • 官方安裝教程:https://github.com/jmu201521121021/mmdetection/blob/master/docs/INSTALL.md

  • 不過官方教程還是有些坑, 有些細節需要注意,比如cuda、pytorch版本。本博客主要安裝版本如下, 所有包可以看最後conda的包。

    • ubuntu16.04
    • cuda9.0
    • pytorch1.1
    • python3.7
  • 具體步驟
    1、安裝cudaAnaconda,可以參考:https://blog.csdn.net/jmu201521121021/article/details/78323032
    2、 安裝nccl 2

 sudo apt install libnccl2=2.4.8-1+cuda9.0 libnccl-dev=2.4.8-1+cuda9.0

3、 新建虛擬環境(所有conda 或pip安裝都需要在這個環境下)

conda create -n open-mmlab python=3.7 -y
source activate open-mmlab

4、安裝 pytorch

conda install pytorch torchvision cudatoolkit=9.0 -c pytorch

5、安裝依賴包

pip install mmcv
pip install matplotlib  
pip install seaborn

6、 mmdetection

git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
python setup.py develop
# or "pip install -v -e ."

7、test
在demo文件下新建 test_retinaNet_res50.py

from mmdet.apis import init_detector, inference_detector, show_result
import mmcv

config_file = '../configs/retinanet_r50_fpn_1x.py'
checkpoint_file = '../checkpoints/retinanet_r50_fpn_1x_20181125-7b0c2548.pth'

# build the model from a config file and a checkpoint file
model = init_detector(config_file, checkpoint_file, device='cuda:0')

# test a single image and show the results
img = 'demo.jpg'  # or img = mmcv.imread(img), which will only load it once
result = inference_detector(model, img)
# visualize the results in a new window
show_result(img, result, model.CLASSES)
# or save the visualization results to image files
show_result(img, result, model.CLASSES, out_file='result.jpg')

在這裏插入圖片描述

三、conda list

#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
addict                    2.2.1                     <pip>
blas                      1.0                         mkl  
ca-certificates           2019.5.15                     1  
certifi                   2019.6.16                py37_1  
cffi                      1.12.3           py37h2e261b9_0  
chardet                   3.0.4                     <pip>
cuda90                    1.0                  h6433d27_0    pytorch
cudatoolkit               9.0                  h13b8566_0  
cycler                    0.10.0                   py37_0  
Cython                    0.29.13                   <pip>
dbus                      1.13.6               h746ee38_0  
decorator                 4.4.0                     <pip>
expat                     2.2.6                he6710b0_0  
fontconfig                2.13.0               h9420a91_0  
freetype                  2.9.1                h8a8886c_1  
glib                      2.56.2               hd408876_0  
gst-plugins-base          1.14.0               hbbd80ab_1  
gstreamer                 1.14.0               hb453b48_1  
icu                       58.2                 h9c2bf20_1  
idna                      2.8                       <pip>
imagecorruptions          1.0.0                     <pip>
imageio                   2.5.0                     <pip>
intel-openmp              2019.4                      243  
jpeg                      9b                   h024ee3a_2  
kiwisolver                1.1.0            py37he6710b0_0  
libedit                   3.1.20181209         hc058e9b_0  
libffi                    3.2.1                hd88cf55_4  
libgcc-ng                 9.1.0                hdf63c60_0  
libgfortran-ng            7.3.0                hdf63c60_0  
libpng                    1.6.37               hbc83047_0  
libstdcxx-ng              9.1.0                hdf63c60_0  
libtiff                   4.0.10               h2733197_2  
libuuid                   1.0.3                h1bed415_2  
libxcb                    1.13                 h1bed415_1  
libxml2                   2.9.9                hea5a465_1  
matplotlib                3.1.1            py37h5429711_0  
mkl                       2019.4                      243  
mkl-service               2.0.2            py37h7b6447c_0  
mkl_fft                   1.0.14           py37ha843d7b_0  
mkl_random                1.0.2            py37hd81dba3_0  
mmcv                      0.2.13                    <pip>
mmdet                     1.0rc0+c5c7ef9            <pip>
ncurses                   6.1                  he6710b0_1  
networkx                  2.3                       <pip>
ninja                     1.9.0            py37hfd86e86_0  
numpy                     1.16.4           py37h7e9f1db_0  
numpy-base                1.16.4           py37hde5b4d6_0  
olefile                   0.46                     py37_0  
opencv-python             4.1.1.26                  <pip>
openssl                   1.1.1c               h7b6447c_1  
pandas                    0.25.1                    <pip>
pcre                      8.43                 he6710b0_0  
pillow                    6.1.0            py37h34e0f95_0  
pip                       19.2.2                   py37_0  
pycocotools               2.0.0                     <pip>
pycparser                 2.19                     py37_0  
pyparsing                 2.4.2                      py_0  
pyqt                      5.9.2            py37h05f1152_2  
python                    3.7.4                h265db76_1  
python-dateutil           2.8.0                    py37_0  
pytorch                   1.1.0           py3.7_cuda9.0.176_cudnn7.5.1_0    pytorch
pytz                      2019.2                     py_0  
PyWavelets                1.0.3                     <pip>
PyYAML                    5.1.2                     <pip>
qt                        5.9.7                h5867ecd_1  
readline                  7.0                  h7b6447c_5  
requests                  2.22.0                    <pip>
scikit-image              0.15.0                    <pip>
scipy                     1.3.1                     <pip>
seaborn                   0.9.0                     <pip>
setuptools                41.0.1                   py37_0  
sip                       4.19.8           py37hf484d3e_0  
six                       1.12.0                   py37_0  
sqlite                    3.29.0               h7b6447c_0  
tk                        8.6.8                hbc83047_0  
torchvision               0.3.0           py37_cu9.0.176_1    pytorch
tornado                   6.0.3            py37h7b6447c_0  
urllib3                   1.25.3                    <pip>
wheel                     0.33.4                   py37_0  
xz                        5.2.4                h14c3975_4  
zlib                      1.2.11               h7b6447c_3  
zstd                      1.3.7                h0b5b093_0  

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章