model.show_result()导致jupyter lab提示服务似乎挂掉,但会立刻重启

9 篇文章 0 订阅
5 篇文章 0 订阅

实验1代码,不加model.show_result:
%reload_ext autoreload
%autoreload 2
%matplotlib inline
from mmseg.apis import inference_segmentor, init_segmentor
import mmcv
import os
os.environ[“KMP_DUPLICATE_LIB_OK”]=“TRUE”
config_file = ‘mmsegmentation/configs/unet/fcn_unet_s5-d16_4x4_512x1024_160k_cityscapes.py’
checkpoint_file = ‘mmsegmentation/checkpoints/fcn_unet_s5-d16_4x4_512x1024_160k_cityscapes_20211210_145204-6860854e.pth’
model = init_segmentor(config_file, checkpoint_file, device=‘cuda:2’)
img = ‘adjust20151019205737_FK108_1_6300_180000_B1_G3__noise0.02__flipv.png’ # or img = mmcv.imread(img), which will only load it once
result = inference_segmentor(model, img)

jupyte lab正常运行!!
实验2代码:

%reload_ext autoreload
%autoreload 2
%matplotlib inline
from mmseg.apis import inference_segmentor, init_segmentor
import mmcv
import os
os.environ[“KMP_DUPLICATE_LIB_OK”]=“TRUE”
config_file = ‘mmsegmentation/configs/unet/fcn_unet_s5-d16_4x4_512x1024_160k_cityscapes.py’
checkpoint_file = ‘mmsegmentation/checkpoints/fcn_unet_s5-d16_4x4_512x1024_160k_cityscapes_20211210_145204-6860854e.pth’

model = init_segmentor(config_file, checkpoint_file, device=‘cuda:2’)
img = ‘adjust20151019205737_FK108_1_6300_180000_B1_G3__noise0.02__flipv.png’ # or img = mmcv.imread(img), which will only load it once
result = inference_segmentor(model, img)
model.show_result(img, result, show=True)
model.show_result(img, result, out_file=‘result3.jpg’, opacity=0.5)
jupyter lab提示服务似乎挂掉,但会立刻重启
实验代码3,注释掉model.show_result(img, result, show=True):
%reload_ext autoreload
%autoreload 2
%matplotlib inline
from mmseg.apis import inference_segmentor, init_segmentor
import mmcv
import os
os.environ[“KMP_DUPLICATE_LIB_OK”]=“TRUE”
config_file = ‘mmsegmentation/configs/unet/fcn_unet_s5-d16_4x4_512x1024_160k_cityscapes.py’
checkpoint_file = ‘mmsegmentation/checkpoints/fcn_unet_s5-d16_4x4_512x1024_160k_cityscapes_20211210_145204-6860854e.pth’

model = init_segmentor(config_file, checkpoint_file, device=‘cuda:2’)
img = ‘adjust20151019205737_FK108_1_6300_180000_B1_G3__noise0.02__flipv.png’ # or img = mmcv.imread(img), which will only load it once
result = inference_segmentor(model, img)
#model.show_result(img, result, show=True)
model.show_result(img, result, out_file=‘result3.jpg’, opacity=0.5)

代码运行正常,生成result3.jpg
可见model.show_result(img, result, show=True)是导致jupyter lab服务挂掉的原因

其他替代方法:show_result_pyplot
%reload_ext autoreload
%autoreload 2
%matplotlib inline
from mmseg.apis import inference_segmentor, init_segmentor,show_result_pyplot
from mmseg.core.evaluation import get_palette
import mmcv
import os
os.environ[“KMP_DUPLICATE_LIB_OK”]=“TRUE”
config_file = ‘mmsegmentation/configs/unet/fcn_unet_s5-d16_4x4_512x1024_160k_cityscapes.py’
checkpoint_file = ‘mmsegmentation/checkpoints/fcn_unet_s5-d16_4x4_512x1024_160k_cityscapes_20211210_145204-6860854e.pth’
model = init_segmentor(config_file, checkpoint_file, device=‘cuda:2’)
img = ‘adjust20151019205737_FK108_1_6300_180000_B1_G3__noise0.02__flipv.png’ # or img = mmcv.imread(img), which will only load it once
result = inference_segmentor(model, img)
model.show_result(img, result, out_file=‘result4.jpg’, opacity=0.5)
show_result_pyplot(model, img, result, get_palette(‘cityscapes’))

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值