从零开始搭建并运行mmsegmentation

安装:

Step 1:创建Conda 环境并激活之

复制代码
conda create --name openmmlab python=3.8 -y
conda activate openmmlab

Step 2:CUDA版本选择,及安装Pytorch

关于设备GPU的cuda版本,根据如下的选择原则:

  • 对于Ampere架构的NVIDIA的GPU,例如GeForce 30系列核NVIDIA A100,必须安装CUDA11。
  • 对于旧版的NVIDIA GPUS,CUDA 11 是向下兼容的,但是 CUDA10.2会更轻量化并且表现更好的性能

确定好cuda版本后,进入Torch官网选择对应版本的Pytorch进行安装

Step 3:安装 MMCV using MIM.

复制代码
pip install -U openmim
mim install mmengine
mim install "mmcv>=2.0.0"

Step 4:安装 MMSegmentation.

复制代码
git clone -b main https://github.com/open-mmlab/mmsegmentation.git
cd mmsegmentation
pip install -v -e .
# '-v' means verbose, or more output
# '-e' means installing a project in editable mode,
# thus any local modifications made to the code will take effect without reinstallation.

验证:

Step 1. We need to download config and checkpoint files.下载config和checkpoint 文件

复制代码
mim download mmsegmentation --config pspnet_r50-d8_4xb2-40k_cityscapes-512x1024 --dest .

Step 2. Verify the inference demo.验证推理demo

Option (a). If you install mmsegmentation from source, just run the following command.

方式(a)如果你从源码安装mmsegmentation,只需要运行下面的命令

复制代码
python demo/image_demo.py demo/demo.png configs/pspnet/pspnet_r50-d8_4xb2-40k_cityscapes-512x1024.py pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth --device cuda:0 --out-file result.jpg

You will see a new image result.jpg on your current folder, where segmentation masks are covered on all objects.

你如果看到了一个新图片result.jpg在你当前文件夹,说明安装成功了。(运行时,可能会有一些warning,但不影响结果的生成)

相关推荐
RobinDevNotes10 分钟前
24GB Mac 做数字人:声音放本地,画面租云端
人工智能·python·macos·开发工具
user4465117917911 小时前
Agent 也能「过安检」:AgentScope 权限系统设计拆解
人工智能
烟小栀1 小时前
Windows下的深度学习环境配置参考及配置教程
人工智能
tellmewhoisi2 小时前
深度学习0:数学知识:最大似然推导过程
人工智能·深度学习·概率论
oil欧哟2 小时前
从产品经理视角拆解 DeepSeek Super-agent:双层路由与异步调度架构
人工智能
张张123y2 小时前
个人助手型 Agent 的六个工程细节:Hermes 与 OpenClaw 的审批、委派、上下文与调度
网络·人工智能·开源·后端开发·ai agent
Dawson Zhu2 小时前
【模型量化⑦】W4A8与GPTQ-Int4:极限压缩与MLC-LLM部署实战
人工智能·语言模型·架构·aigc·agi
千寻技术帮3 小时前
50055_基于AI的互帮互助小程序(源码+文档+数据库脚本+部署教程)
数据库·人工智能·小程序·毕业设计·springboot·课程设计
天树星智源3 小时前
KV 剪枝的同一个误差,模型确定时只改 1.4% 的 token,不确定时改 65%:接上不确定性,AIME25 端到端快 1.27 倍
人工智能·大模型
AI英德西牛仔3 小时前
PC 用户的效率革命:腾讯元宝导出 Word 指令与“AI 导出鸭”的底层逻辑
人工智能·word·excel·deepseek·ai导出鸭