Open wenjun2022 opened 2 years ago
Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)
always happened by different packages conflict. Could you run any code in MMSegmentation? If not, you can create another new conda environment follow here.
Another possible cause (which I encountered today) is that you're trying to read/write a file which is open. In this case, simply closing the file and rerunning the script solved the issue.
from here. Do you open demo.png
when implementing demo.py
?
MAC os Pycharm 源码: from mmseg.apis import inference_segmentor, init_segmentor import mmcv import torch
print(torch.version.cuda) config_file = r'/Users/wenjun/pythonProject/mmsegmentation-master/configs/setr/setr_vit-large_pup_8x1_768x768_80k_cityscapes.py' checkpoint_file = '/Users/wenjun/pythonProject/mmsegmentation-master/checkpoints/setr_pup_vit-large_8x1_768x768_80k_cityscapes_20211122_155115-f6f37b8f.pth'
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
从一个 config 配置文件和 checkpoint 文件里创建分割模型
model = init_segmentor(config_file, checkpoint_file, device=device)
测试一张样例图片并得到结果
img = r'/Users/wenjun/pythonProject/mmsegmentation-master/demo/demo.png' # 或者 img = mmcv.imread(img), 这将只加载图像一次. result = inference_segmentor(model, img)
在新的窗口里可视化结果
model.show_result(img, result, show=True)
或者保存图片文件的可视化结果
您可以改变 segmentation map 的不透明度(opacity),在(0, 1]之间。
model.show_result(img, result, out_file='result.jpg', opacity=0.5)
Run: /Users/wenjun/miniconda3/envs/open-mmlaba/bin/python /Users/wenjun/pythonProject/mmsegmentation-master/demo/test.py None
Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)