首先安装detectron2,我采用的是
python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
之后需要检查自己的电脑是否安装了nvidia驱动,20.04里面的驱动很好配置,直接在ubuntu软件和更新里改驱动就行。(完全不需要卸载那个开源的驱动)
驱动搞完以后,还需要安装nvcc(很大,要用镜像源才好)
之后需要编译detectron2:
python setup.py build develop
编译后即可运行demo.py,这里还需要下载相关的模型权重。而且我还把模型的配置文件以及模型的权重文件路径写死了(确保万无一失)
python3 demo.py \
--config-file /home/xutengfei/detectron2/configs/quick_schedules/mask_rcnn_R_50_FPN_inference_acc_test.yaml \
--input /home/xutengfei/detectron2/demo/input.jpeg --output /home/xutengfei/detectron2/demo/output.jpeg \
--opts MODEL.WEIGHTS /home/xutengfei/detectron2/model/model_final_f10217.pkl