• Detectron2环境配置加测试(Linux)


    首先 建一个干净的虚拟环境 (很重要)

    conda create -n detectron2 python=3.7

    然后进到这个环境  (detectroon2是这个环境的名字)

    conda activate detectron2

    然后 装pytorch   

    conda install pytorch torchvision torchaudio cudatoolkit=11.6 -c pytorch -c conda-forge

    (一定要注意自己的CUDA版本 我的是11.6所以用下面的代码)

    然后 安装我们需要用的包  注意opencv的版本 最好是干净的环境 一套流程走下来 以免发生版本不兼容的问题

    conda install cython opencv-python==4.2.0.34 matplotlib termcolor cloudpickle tabulate tensorboard tqdm yacs mock fvcore pydot wheel future

    失败 conda list看一下 确实没下下来 

    我们换pip

    pip install cython opencv-python==4.2.0.34 matplotlib termcolor cloudpickle tabulate tensorboard tqdm yacs mock fvcore pydot wheel future

     成功!

    然后我们要用coco数据集得下一个 pycocotools

    直接git clone失败 用git lfs clone

    一般大文件 我都会用git lfs clone 不过lfs是需要自己安装的 具体可以csdn找到

    git lfs clone https://github.com/waleedka/coco

    然后进到刚下载的包中

    cd python setup.py build_ext install

    这样pycocotools就安装好了

    然后下载detectron2

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

     进到detectron2目录

    python -m install -e detectron2  (失败!)官方的代码

    python -m install -e .    (成功!) 注意这个点. 在e后面空格 .

    然后进detectron2的github

    去model zoo里下载对应的model的checkpoints

    checkpoints上传到服务器之后 随便上传一张图片进行测试 我这里是用的 model_final_a54504.pkl

    进到detectron2文件夹中后

    python demo/demo.py --config-file configs/COCO-InstanceSegmentation/mask_rcnn_R_50_FPN_1x.yaml --input 3.jpg --opts MODEL.WEIGHTS model_final_a54504.pkl MODEL.DEVICE cpu

    我这里实验室服务器满了 所以用的cpu 有gpu的话 把MODEL.DEVICE cpu去掉就好了

     结果如下

     可能碰到的问题总结一下

    1.pytorch版本问题 这个一般很少出现 

    2.git clone lfs的问题 我加了lfs一般都能行 

    3.安装detectron2时 -e . 需要注意一下 not detectron2

  • 相关阅读:
    python与pycharm如何设置文件夹为源代码根目录
    【算法与数据结构】--算法基础--数据结构概述
    千万别再学python编程了?编程没用了?马上就要被淘汰啦?
    SpringBoot自动装配原理(简单易懂)
    基础-MVP图像处理-仿射变换
    SpringBoot 如何使用 Sleuth 进行分布式跟踪
    The 2021 ICPC Asia Nanjing Regional Contest H. Crystalfly
    Python协程
    Java知识点07——输入/输出(File类、IO流、序列化、NIO)
    【PAT(甲级)】1053 Path of Equal Weight
  • 原文地址:https://blog.csdn.net/m0_53292725/article/details/126495320