segment-anything安装教程

一. segment-anything安装教程

官网安装说明:https://github.com/facebookresearch/segment-anything

  1. anaconda下新建一个环境

    conda create -n sam python=3.8
    

    在这里插入图片描述

  2. 激活新建的环境

    conda activate sam
    

在这里插入图片描述

  1. 更换conda镜像源

    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
    conda config --set show_channel_urls yes
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
    

    在这里插入图片描述

  2. 安装pytorch

    conda install pytorch==1.11.0 torchvision==0.12.0 torchaudio==0.11.0 cudatoolkit=11.3
    

    在这里插入图片描述

  3. 克隆官方代码

    git clone git@github.com:facebookresearch/segment-anything.git
    

    在这里插入图片描述

  4. 进入下载好的文件夹,打开cmd,激活安装好的环境,运行以下代码

    pip install -e . -i https://mirrors.aliyun.com/pypi/simple/
    

    在这里插入图片描述
    在这里插入图片描述

  5. 安装所需python库

    pip install opencv-python pycocotools matplotlib onnxruntime onnx flake8 isort black mypy -i https://mirrors.aliyun.com/pypi/simple/
    

    在这里插入图片描述

  6. 从官网下载模型,并复制到源代码下
    在这里插入图片描述
    在这里插入图片描述

  7. 运行以下代码
    1.png为放置在源代码下的图像

    python scripts/amg.py --checkpoint sam_vit_b_01ec64.pth --model-type vit_b --input 1.jpg --output result
    

    在这里插入图片描述

    生成的图像掩码在这里插入图片描述

  • 21
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AoDeLuo

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值