安装mmsegmentation经验-ubuntu18.0.4

@安装mmsegmentation经验-ubuntu18.0.4

在安装mmseg过程中遇到了很多版本不兼容的问题,最后成功了,分享一点经验。

服务器状态

我使用的显卡是3090,显卡驱动是470.94,cuda版本是11.4

建立虚拟环境

建立环境不必多说,我这里使用的是python3.8

安装mmcv-full

我之前使用的torch1.8.1,在mmcv-full的版本对应表没有cuda11.4的命令(目前我的cuda是最新的)。我借鉴其他版本的mmcv-full命令,修改对应cu和torch参数后一直安装失败。

这里借鉴文章的条件和我差不多。
使用以下代码成功安装了mmcv-full

pip3 install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html
pip install mmcv-full==1.3.8 -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.8.0/index.html

安装mmsegmentation

mmsegmentation版本有多个,有mmcv-full的版本要求
进入链接https://github.com/open-mmlab/mmsegmentation/tree/master
可以在mmseg里的__init__.py查看当前代码对mmcv-full的要求,如下请添加图片描述
默认的master版本是不满足前面的mmcv-full的版本的。
点击左上角的master里的tags可以查看其他版本,这里我选择了0.13.0。

确认正常安装

1.在代码根目录新建·checkpoints文件夹
下载pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth 权重连接

2.在根目录新建新建如下脚本 test.py, 在安装虚拟环境中执行测试

from mmseg.apis import inference_segmentor, init_segmentor
import mmcv

config_file = 'configs/pspnet/pspnet_r50-d8_512x1024_40k_cityscapes.py'
checkpoint_file = 'checkpoints/pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth'

# build the model from a config file and a checkpoint file
model = init_segmentor(config_file, checkpoint_file, device='cuda:0')

# test a single image and show the results
img = 'demo/demo.png'  # or img = mmcv.imread(img), which will only load it once
result = inference_segmentor(model, img)
# visualize the results in a new window
model.show_result(img, result, show=True)
# or save the visualization results to image files
# you can change the opacity of the painted segmentation map in (0, 1].
model.show_result(img, result, out_file='result.jpg', opacity=0.5)

# test a video and show the results
#video = mmcv.VideoReader('video.mp4')
#for frame in video:
#   result = inference_segmentor(model, frame)
#   model.show_result(frame, result, wait_time=1)
python test.py

3.显示结果如下,表示正常安装
在这里插入图片描述

  • 5
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值