mask2former-swin-base-IN21k-cityscapes-instance:基于Swin骨干的Cityscapes实例分割模型

Mask2Former模型,采用Swin骨干,在Cityscapes数据集上训练,适用于实例分割任务,通过多尺度可变形注意力Transformer提升性能与效率。【此简介由AI生成】

分支1Tags0
文件最后提交记录最后更新时间
initial commit3 年前
Create README.md3 年前
Upload Mask2FormerForUniversalSegmentation3 年前
Adding safetensors variant of this model (#2) - Adding safetensors variant of this model (17e4009066d38a72e46d20dfc78f47d4d7b4dca5) Co-authored-by: Safetensors convertbot <SFconvertbot@users.noreply.huggingface.co> 2 年前
Update preprocessor_config.json (#1) - Update preprocessor_config.json (0de7cb751ac9cc55531367ac9a5ca874d27b0ef8) Co-authored-by: Shivalika Singh <shivi@users.noreply.huggingface.co> 3 年前
Upload Mask2FormerForUniversalSegmentation3 年前

license: other tags:


Mask2Former

Mask2Former模型基于Cityscapes实例分割数据集训练(base-IN21k版本,Swin主干网络)。该模型由论文Masked-attention Mask Transformer for Universal Image Segmentation提出,并首次发布于此代码库

免责声明:Mask2Former发布团队未提供本模型的模型卡,本文档由Hugging Face团队编写。

模型描述

Mask2Former采用统一范式处理实例分割、语义分割和全景分割任务:通过预测一组掩码及对应标签来实现。因此,所有三项任务均被视作实例分割处理。该模型在性能和效率上均超越前代SOTA模型MaskFormer,其创新包括:(i) 采用更先进的多尺度可变形注意力Transformer替代像素解码器;(ii) 通过引入掩码注意力机制的Transformer解码器提升性能且不增加计算量;(iii) 通过对采样点而非完整掩码计算损失来提升训练效率。

模型结构图

适用范围与限制

该特定检查点可用于实例分割任务。欢迎访问模型中心探索其他针对特定任务的微调版本。

使用方法

使用本模型的方式如下:

import requests
import torch
from PIL import Image
from transformers import AutoImageProcessor, Mask2FormerForUniversalSegmentation


# load Mask2Former fine-tuned on Cityscapes instance segmentation
processor = AutoImageProcessor.from_pretrained("facebook/mask2former-swin-base-IN21k-cityscapes-instance")
model = Mask2FormerForUniversalSegmentation.from_pretrained("facebook/mask2former-swin-base-IN21k-cityscapes-instance")

url = "http://images.cocodataset.org/val2017/000000039769.jpg"
image = Image.open(requests.get(url, stream=True).raw)
inputs = processor(images=image, return_tensors="pt")

with torch.no_grad():
    outputs = model(**inputs)

# model predicts class_queries_logits of shape `(batch_size, num_queries)`
# and masks_queries_logits of shape `(batch_size, num_queries, height, width)`
class_queries_logits = outputs.class_queries_logits
masks_queries_logits = outputs.masks_queries_logits

# you can pass them to processor for postprocessing
result = processor.post_process_instance_segmentation(outputs, target_sizes=[image.size[::-1]])[0]
# we refer to the demo notebooks for visualization (see "Resources" section in the Mask2Former docs)
predicted_instance_map = result["segmentation"]

如需更多代码示例,请参阅文档

项目介绍

Mask2Former模型,采用Swin骨干,在Cityscapes数据集上训练,适用于实例分割任务,通过多尺度可变形注意力Transformer提升性能与效率。【此简介由AI生成】

定制我的领域

下载使用量

0

项目总下载次数(含Clone、Pull、 zip 包及 release 下载),每日凌晨更新