其它相关模型体验Mask2Former-R50全景分割
本模型使用ViT-Adapter为backbone,Mask2Former为分割头。COCO-Stuff-164k数据库上训练。当前模型暂时不支持训练及finetune。
ViT-Adapter是一个对于稠密预测(例如检测,分割)任务十分友好的backbone模块。该方法包含一个基本backbone(ViT)和自适应的vitadapter。
其中,vitadpater包含了3个模块。第一个模块是Spatial Prior Module,用于从输入图像中提取空间特征。第二个模块是Spatial Feature Injector,用于将空间的先验注入到backbone(ViT)中,第三个模块是Multi-Scale Feature Extractor,用于从backbone(ViT)中提取分层特征。
Mask2Former是一种能够解决任何图像分割任务(全景、实例或语义)的新架构。它包含了一个masked attention结构,通过将交叉注意力计算内来提取局部特征。
本模型适用范围较广,能对图片中包含的大部分感兴趣物体进行分割。
在ModelScope框架上,提供输入图片,即可通过简单的Pipeline调用来使用。
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
from modelscope.outputs import OutputKeys
from modelscope.utils.cv.image_utils import semantic_seg_masks_to_image
import cv2
segmentor = pipeline(Tasks.image_segmentation, model='damo/cv_vitadapter_semantic-segmentation_cocostuff164k')
input_url = 'https://modelscope.oss-cn-beijing.aliyuncs.com/test/images/image_semantic_segmentation.jpg'
result = segmentor(input_url)
draw_img = semantic_seg_masks_to_image(result[OutputKeys.MASKS])
cv2.imwrite('result.jpg', draw_img)
print("vitadapter DONE!")
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks,DownloadMode
from modelscope.utils.cv.image_utils import semantic_seg_masks_to_image
from modelscope.outputs import OutputKeys
from modelscope.msdatasets import MsDataset
import cv2
segmentor = pipeline(Tasks.image_segmentation, model='damo/cv_vitadapter_semantic-segmentation_cocostuff164k')
ms_ds_val = MsDataset.load("COCO_segmentation_inference", namespace="modelscope", split="validation", download_mode=DownloadMode.FORCE_REDOWNLOAD)
result = segmentor(ms_ds_val[0]["InputImage:FILE"])
draw_img = semantic_seg_masks_to_image(result[OutputKeys.MASKS])
cv2.imwrite('result.jpg', draw_img)
print("vitadapter DONE!")
测试时主要的预处理如下:
Backbone | Pretrain | aAcc | mIoU | mAcc |
---|---|---|---|---|
vitadapter | BEiT-L | 69.91 | 47.21 | 57.17 |
@article{chen2022vision,
title={Vision Transformer Adapter for Dense Predictions},
author={Chen, Zhe and Duan, Yuchen and Wang, Wenhai and He, Junjun and Lu, Tong and Dai, Jifeng and Qiao, Yu},
journal={arXiv preprint arXiv:2205.08534},
year={2022}
}