2013年12月10日 星期二

Detectron2 mask rcnn install step

Ref.
https://github.com/facebookresearch/detectron2/blob/master/INSTALL.md
https://detectron2.readthedocs.io/tutorials/index.html
https://gilberttanner.com/blog/detectron-2-object-detection-with-pytorch
http://fatalfeel.blogspot.com/2019/12/ai-with-cuda-install-step-and-yolov3-in.html

1. #preinstall python 3.7
apt install wget openssl python3-dev python3-setuptools build-essential checkinstall libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev zlib1g-dev libffi-dev

wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz
tar xvf Python-3.7.2.tar.xz
cd Python-3.7.2
./configure --enable-optimizations
make && make altinstall

(enable-optimizations will make a lot test for your system)

2. python3
ln -sf $(which python3.7) /usr/local/bin/python3
python3 --version

3. pip3
wget https://bootstrap.pypa.io/get-pip.py
python3 ./get-pip.py
pip3 --version

4.
#after install nvidia driver and cuda then make cuda link path
#preinstall cuda 10.1
ln -sf /usr/local/cuda-10.1 /usr/local/cuda

5.
preinstall pytorch 1.3
https://pytorch.org/
pip3 install torch torchvision
pip3 install cython
pip3 install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
pip3 install tabulate cloudpickle imagesize

6.
git clone https://github.com/facebookresearch/fvcore
cd fvcore
python3 ./setup.py build develop
(fvcore will make /usr/local/lib/python3.7/site-packages/fvcore.egg-link to /usr/local/lib/python3.7/dist-packages/fvcore)
(pip3 install 'git+https://github.com/facebookresearch/fvcore' will not make link)

7.
git clone https://github.com/facebookresearch/detectron2.git

8.
cd /root/projects/detectron2
python3 setup.py build develop

9.
download models
https://github.com/facebookresearch/detectron2/blob/master/MODEL_ZOO.md

mkdir samples and copy test images to /root/projects/detectron2/samples
mkdir weights and copy models to /root/projects/detectron2/weights

10. in pycharm
Run -> edit configurations
parameters: --config-file configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input samples/ch00.jpg --opts MODEL.WEIGHTS weights/model_final_f10217.pkl
working directory: /root/projects/detectron2

11. in teminal
python3 demo/demo.py --config-file configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_3x.yaml --input samples/ch00.jpg --opts MODEL.WEIGHTS weights/model_final_f10217.pkl

#if meet RuntimeError('Not compiled with GPU support#
#make sure /usr/local/cuda link to /usr/local/cuda-10.1#
ln -sf /usr/local/cuda-10.1 /usr/local/cuda
rm -R /root/projects/detectron2/build
python3 setup.py build develop


沒有留言:

張貼留言