mask2former-swin-tiny-cityscapes-panoptic:基于Swin骨干的Cityscapes全景分割模型

采用Masked-attention Mask Transformer架构,以Swin为骨干,在Cityscapes数据集上训练,高效处理全景分割任务,性能与效率优于前代SOTA。【此简介由AI生成】

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

license: other tags:


Mask2Former

此模型为基于 Cityscapes 全景分割数据集训练的 Mask2Former(微型版本,采用 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 panoptic segmentation
processor = AutoImageProcessor.from_pretrained("facebook/mask2former-swin-tiny-cityscapes-panoptic")
model = Mask2FormerForUniversalSegmentation.from_pretrained("facebook/mask2former-swin-tiny-cityscapes-panoptic")

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_panoptic_segmentation(outputs, target_sizes=[image.size[::-1]])[0]
# we refer to the demo notebooks for visualization (see "Resources" section in the Mask2Former docs)
predicted_panoptic_map = result["segmentation"]

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

项目介绍

采用Masked-attention Mask Transformer架构,以Swin为骨干,在Cityscapes数据集上训练,高效处理全景分割任务,性能与效率优于前代SOTA。【此简介由AI生成】

定制我的领域

下载使用量

0

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