目标跟踪、目标检测、前景分割不分家,如SiamMask、SiamR-CNN

这篇文章针对目标框可起到很好地分割效果。

注:原代码的运行环境为Ubuntu,本文在Windows10系统下完成配置。

1、论文下载:

Interactive Object Segmentation with Inside-Outside Guidance. [paper][code]

2、代码下载:

https://github.com/shiyinzhang/Inside-Outside-Guidance

3、建立且激活虚拟环境IOG

conda create -n IOG python=3.7.0

activate IOG

4、安装torch和torchvision

pip install torch===1.4.0 -f https://download.pytorch.org/whl/torch_stable.html

pip install torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html

5、安装pycocotools和opencv-python

pip install pycocotools opencv-python

6、下载预训练模型放到工程路径

链接:https://pan.baidu.com/s/1-BViduSNAd-lwe81tMv-2A 
提取码:72sj 

7、下载PascalVOC2012数据集

Pascal VOC Dataset Mirror

只下载图中标注的数据集,然后解压即可。

8、打开mypath.py设置路径

9、打开test.py设置预训练模型路径

10、运行python test.py遇到错误

Traceback (most recent call last):
  File "test.py", line 2, in <module>
    import scipy.misc as sm
ModuleNotFoundError: No module named 'scipy'

错误原因是: 没有安装scipy,解决方法:pip install scipy

11、再次运行遇到错误

RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

if __name__ == '__main__':
                freeze_support()
                ...

The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.BrokenPipeError: [Errno 32] Broken pipe
错误原因:线程冲突,解决办法:把test.py的71行num_workers=1去掉。

11、再次运行,出现错误

Traceback (most recent call last):
  File "test.py", line 91, in <module>
    sm.imsave(os.path.join(save_dir_res_list[0], metas['image'][0] + '-' + metas['object'][0] + '.png'), result)
AttributeError: module 'scipy.misc' has no attribute 'imsave'
错误原因:scipy版本不兼容问题,解决方法:将scipy降级到1.2.1版本之下即可,pip install scipy==1.2.1

12、再次运行成功。

结果存放在run_0/Results路径下

13、测试单张图片

1)新建 inference.py

from datetime import datetime
import scipy.misc as sm
from collections import OrderedDict
import glob
import numpy as np
import socket# PyTorch includes
import torch
import torch.optim as optim
from torchvision import transforms
from torch.utils.data import DataLoader# Custom includes
from dataloaders.combine_dbs import CombineDBs as combine_dbs
import dataloaders.pascal as pascal
import dataloaders.sbd as sbd
from dataloaders import custom_transforms as tr
from networks.loss import class_cross_entropy_loss
from dataloaders.helpers import *
from networks.mainnetwork import *import matplotlib.pyplot as pltfrom PIL import Image
import cv2
import argparsedef process(image_name):# Set gpu_id to -1 to run in CPU mode, otherwise set the id of the corresponding gpugpu_id = 0device = torch.device("cuda:"+str(gpu_id) if torch.cuda.is_available() else "cpu")if torch.cuda.is_available():print('Using GPU: {} '.format(gpu_id))# Setting parametersresume_epoch = 100  # test epochnInputChannels = 5  # Number of input channels (RGB + heatmap of IOG points)# Network definitionmodelName = 'IOG_pascal'net = Network(nInputChannels=nInputChannels,num_classes=1,backbone='resnet101',output_stride=16,sync_bn=None,freeze_bn=False)# load pretrain_dictpretrain_dict = torch.load('IOG_PASCAL_SBD.pth')net.load_state_dict(pretrain_dict)# net.to(device)# Generate result of the validation imagesnet.eval()image = np.array(Image.open(image_name).convert('RGB'))im_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)roi = cv2.selectROI(im_rgb)image = image.astype(np.float32)bbox = np.zeros_like(image[..., 0])# bbox[0: 130, 220: 320] = 1 # for ponny# bbox[220: 390, 370: 570] = 1bbox[int(roi[1]):int(roi[1]+roi[3]), int(roi[0]):int(roi[0]+roi[2])] = 1void_pixels = 1 - bboxsample = {'image': image, 'gt': bbox, 'void_pixels': void_pixels}trns = transforms.Compose([tr.CropFromMask(crop_elems=('image', 'gt','void_pixels'), relax=30, zero_pad=True),tr.FixedResize(resolutions={'gt': None, 'crop_image': (512, 512), 'crop_gt': (512, 512), 'crop_void_pixels': (512, 512)},flagvals={'gt':cv2.INTER_LINEAR,'crop_image':cv2.INTER_LINEAR,'crop_gt':cv2.INTER_LINEAR,'crop_void_pixels': cv2.INTER_LINEAR}),tr.IOGPoints(sigma=10, elem='crop_gt',pad_pixel=10),tr.ToImage(norm_elem='IOG_points'), tr.ConcatInputs(elems=('crop_image', 'IOG_points')),tr.ToTensor()])tr_sample = trns(sample)inputs = tr_sample['concat'][None]# inputs = inputs.to(device)outputs = net.forward(inputs)[-1]# outputs = fine_out.to(torch.device('cpu'))pred = np.transpose(outputs.data.numpy()[0, :, :, :], (1, 2, 0))pred = 1 / (1 + np.exp(-pred))pred = np.squeeze(pred)gt = tens2image(tr_sample['gt'])bbox = get_bbox(gt, pad=30, zero_pad=True)result = crop2fullmask(pred, bbox, gt, zero_pad=True, relax=0,mask_relax=False)light = np.zeros_like(image)light[:, :, 2] = 255.alpha = 0.8blending = (alpha * light + (1 - alpha) * image) * result[..., None] + (1 - result[..., None]) * imageblending[blending > 255.] = 255cv2.imshow('resulting segmentation', cv2.cvtColor(blending.astype(np.uint8), cv2.COLOR_RGB2BGR))cv2.waitKey(0)cv2.destroyAllWindows()if __name__ == '__main__':parser = argparse.ArgumentParser(description='Run class agnostic segmentation')parser.add_argument('--image_name', type=str, default='samples/IMG-20201203-WA0023.jpg', help='path to target image')args = parser.parse_args()process(args.image_name)

2)运行python inference.py --image_name E:/Datasets/OTB2015/Lemming/img/0001.jpg

3)选取目标框后,回车

4)分割结果

CVPR2020交互式分割算法IOG的配置(Interactive Object Segmentation with Inside-Outside Guidance)相关推荐

  1. 《IOG:Interactive Object Segmentation with Inside-Outside Guidance》论文笔记

    参考代码:Inside-Outside-Guidance paper数据集:Pixel-ImageNet 1. 概述 导读:这篇文章提出了一种新的交互式分割算法,其通过inside-outside g ...

  2. 【IOG】Interactive Object Segmentation With Inside-Outside Guidance全文翻译

    Interactive Object Segmentation With Inside-Outside Guidance翻译 Abstract ​ 本文探讨了如何在最小化人类交互成本的同时获取精确的对 ...

  3. 交互式分割: Interactive Object Segmentation with Inside-Outside Guidance

    论文:https://ieeexplore.ieee.org/document/9157733 代码: https://github.com/shiyinzhang/Inside-Outside-Gu ...

  4. ICCV2021: 淘系素材制备平台中的自研交互式分割技术(含试用demo)

    还在为耗时耗力的抠图苦恼吗?只要轻松几次点击,即可分割出图像中你想要的任意目标.淘系技术"图像和美"团队联合iTag推出FAI-素材制备平台(如图1),致力于用最简单的交互获取精准 ...

  5. CVPR2020论文解析:实例分割算法

    CVPR2020论文解析:实例分割算法 BlendMask: Top-Down Meets Bottom-Up for Instance Segmentation 论文链接:https://arxiv ...

  6. 【论文汇总】CVPR2020语义分割医学图像分割paper汇总

    语义分割&医学图像分割 segmentation@CVPR2020 CVPR2020语义分割和医学图像分割文章总结 文章目录 语义分割&医学图像分割 segmentation@CVPR ...

  7. 指哪分哪:交互式分割近期发展

    ©PaperWeekly 原创 · 作者|武广 学校|合肥工业大学硕士生 研究方向|图像生成 图像分割在深度学习的加持下精度性得到不断的提高,主要的分割任务集中在全自动分割的方法下进行,然而一些特定的 ...

  8. 视频物体分割算法:如何提升复杂场景的分割精度?

    在此文章中,阿里巴巴资深算法专家为我们介绍了视频物体分割的三个研究方向,然后结合阿里文娱摩酷实验室的探索,分享了他们在视频领域的最新应用. 视频物体分割(Video Object Segmentati ...

  9. CVPR目标检测与实例分割算法解析:FCOS(2019),Mask R-CNN(2019),PolarMask(2020)

    CVPR目标检测与实例分割算法解析:FCOS(2019),Mask R-CNN(2019),PolarMask(2020) 目标检测:FCOS(CVPR 2019) 目标检测算法FCOS(FCOS: ...

最新文章

  1. 【事件流】浅谈事件冒泡事件捕获------【巷子】
  2. 史上最成功的数学预测:用狄拉克方程推导出电子自旋
  3. oracle的集函数,Oracle统计分析函数集之一(转载)
  4. SpringFramework核心技术一(IOC:命名bean)
  5. mint java_Oracle Java 12 (JDK 12)在Ubuntu、Linux Mint或Debian(使用PPA)安装配置
  6. Miniflter中 NPInstanceSetup调查
  7. 【Verilog 常见设计】(0)二进制码和格雷码互转 Verilog 实现
  8. PCHunter_32X64_2022_03最新版
  9. 91.(leaflet篇)leaflet态势标绘-进攻方向绘制
  10. rpm的安装与卸载,常用命令记载
  11. 自动发送企业微信通知,让我来教你真的超简单
  12. notifier_chain 内核通知链的学习与使用
  13. SpringBoot 实现国际化 SpringBoot配置国际化 SpringBoot 国际化 springboot实现国际化 springboot配置国际化 springboot国际化代码实现
  14. 基于隐马尔科夫模型文本相似度问题研究
  15. 强大的心理素质如何锻炼?心理素质提高五大方法
  16. 苹果新品发布会?看美维公司的小伙伴如何评论!
  17. 基于无线NRF24L01的ardunio遥控小车
  18. echarts python 教程_Echarts入门(零基础小白教程)
  19. 再续局域网arp***
  20. Android4模拟器滤镜功能,android 判断模拟器

热门文章

  1. 软件看门狗和硬件看门狗
  2. 微信商户平台配置JSAPI支付目录,vue项目,好多坑呐
  3. ES5和ES6的继承有哪些优劣?
  4. html基础之好看的header
  5. 字符串、列表、字典、元组的基本操作
  6. Hexo自动部署到阿里云(Ubantu16.04)【超详细踩坑记录】
  7. 【基础算法训练】—— 01背包 + 排序
  8. C语言项目实战:24点游戏计算器(基于结构体、指针、函数、数组、循环等知识点)
  9. ffmpeg之mp4文件解封装截取一段视频并重封装
  10. 亿道丨三防平板丨加固平板丨三防工业平板丨航空航天应用