SAVRN
Search Contact SAVRN

Open-weight model · Image segmentation

detr-resnet-50-panoptic

by AI at Meta facebook/detr-resnet-50-panoptic

DEtection TRansformer (DETR) model trained end-to-end on COCO 2017 panoptic (118k annotated images). It was introduced in the paper End-to-End Object Detection with Transformers by Carion et al. and first released in this repository.

Parameters
Context1,024
Weights172.2 MB
Licenseapache-2.0
AccessOpen weights
Monthly Downloads19.4k

Model Card

By AI at Meta, published under apache-2.0, revision d53b52a79940.

DEtection TRansformer (DETR) model trained end-to-end on COCO 2017 panoptic (118k annotated images). It was introduced in the paper End-to-End Object Detection with Transformers by Carion et al. and first released in this repository. Disclaimer: The team releasing DETR did not write a model card for this model so this model card has been written by the Hugging Face team. The DETR model is an encoder-decoder transformer with a convolutional backbone. Two heads are added on top of the decoder outputs in order to perform object detection: a linear layer for the class labels and a MLP (multi-layer perceptron) for the bounding boxes. The model uses so-called object queries to detect objects in…

Read AI at Meta's full model card

DETR (End-to-End Object Detection) model with ResNet-50 backbone

DEtection TRansformer (DETR) model trained end-to-end on COCO 2017 panoptic (118k annotated images). It was introduced in the paper End-to-End Object Detection with Transformers by Carion et al. and first released in this repository.

Disclaimer: The team releasing DETR did not write a model card for this model so this model card has been written by the Hugging Face team.

Model description

The DETR model is an encoder-decoder transformer with a convolutional backbone. Two heads are added on top of the decoder outputs in order to perform object detection: a linear layer for the class labels and a MLP (multi-layer perceptron) for the bounding boxes. The model uses so-called object queries to detect objects in an image. Each object query looks for a particular object in the image. For COCO, the number of object queries is set to 100.

The model is trained using a "bipartite matching loss": one compares the predicted classes + bounding boxes of each of the N = 100 object queries to the ground truth annotations, padded up to the same length N (so if an image only contains 4 objects, 96 annotations will just have a "no object" as class and "no bounding box" as bounding box). The Hungarian matching algorithm is used to create an optimal one-to-one mapping between each of the N queries and each of the N annotations. Next, standard cross-entropy (for the classes) and a linear combination of the L1 and generalized IoU loss (for the bounding boxes) are used to optimize the parameters of the model.

DETR can be naturally extended to perform panoptic segmentation, by adding a mask head on top of the decoder outputs.

Intended uses & limitations

You can use the raw model for panoptic segmentation. See the model hub to look for all available DETR models.

How to use

Here is how to use this model:

import io
import requests
from PIL import Image
import torch
import numpy

from transformers import DetrFeatureExtractor, DetrForSegmentation
from transformers.models.detr.feature_extraction_detr import rgb_to_id

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

feature_extractor = DetrFeatureExtractor.from_pretrained("facebook/detr-resnet-50-panoptic")
model = DetrForSegmentation.from_pretrained("facebook/detr-resnet-50-panoptic")

# prepare image for the model
inputs = feature_extractor(images=image, return_tensors="pt")

# forward pass
outputs = model(**inputs)

# use the `post_process_panoptic` method of `DetrFeatureExtractor` to convert to COCO format
processed_sizes = torch.as_tensor(inputs["pixel_values"].shape[-2:]).unsqueeze(0)
result = feature_extractor.post_process_panoptic(outputs, processed_sizes)[0]

# the segmentation is stored in a special-format png
panoptic_seg = Image.open(io.BytesIO(result["png_string"]))
panoptic_seg = numpy.array(panoptic_seg, dtype=numpy.uint8)
# retrieve the ids corresponding to each mask
panoptic_seg_id = rgb_to_id(panoptic_seg)

Currently, both the feature extractor and model support PyTorch.

Training data

The DETR model was trained on COCO 2017 panoptic, a dataset consisting of 118k/5k annotated images for training/validation respectively.

Training procedure

Preprocessing

The exact details of preprocessing of images during training/validation can be found here.

Images are resized/rescaled such that the shortest side is at least 800 pixels and the largest side at most 1333 pixels, and normalized across the RGB channels with the ImageNet mean (0.485, 0.456, 0.406) and standard deviation (0.229, 0.224, 0.225).

Training

The model was trained for 300 epochs on 16 V100 GPUs. This takes 3 days, with 4 images per GPU (hence a total batch size of 64).

Evaluation results

This model achieves the following results on COCO 2017 validation: a box AP (average precision) of 38.8, a segmentation AP (average precision) of 31.1 and a PQ (panoptic quality) of 43.4.

For more details regarding evaluation results, we refer to table 5 of the original paper.

BibTeX entry and citation info

@article{DBLP:journals/corr/abs-2005-12872,
  author    = {Nicolas Carion and
               Francisco Massa and
               Gabriel Synnaeve and
               Nicolas Usunier and
               Alexander Kirillov and
               Sergey Zagoruyko},
  title     = {End-to-End Object Detection with Transformers},
  journal   = {CoRR},
  volume    = {abs/2005.12872},
  year      = {2020},
  url       = {https://arxiv.org/abs/2005.12872},
  archivePrefix = {arXiv},
  eprint    = {2005.12872},
  timestamp = {Thu, 28 May 2020 17:38:09 +0200},
  biburl    = {https://dblp.org/rec/journals/corr/abs-2005-12872.bib},
  bibsource = {dblp computer science bibliography, https://dblp.org}
}

Configuration

Architecture
DetrForSegmentation
Context length (tokens)
1,024
Layers
6
Model type
detr

Identity and Version

Repository
facebook/detr-resnet-50-panoptic
Publisher
AI at Meta
Task
Image segmentation
Modality
Image
Library
transformers
Parameters
Not stated by the source
Languages
Not stated by the source
Revision
d53b52a799403a8867920f82c869e40732b47037
First published
2022-03-02
Last updated
2024-04-10

Files and Weights

5 files, 172.3 MB in total. The weights are 1 file totalling 172.2 MB in bin.

Weights1 file · 172.2 MB
Configuration2 files · 11.9 KB
Documentation1 file · 5.9 KB
Repository1 file · 690 B
Every file
FileTypeSizeSHA-256
pytorch_model.binWeights172.2 MB 3f8024c47444
config.jsonConfiguration11.6 KB
preprocessor_config.jsonConfiguration289 B
README.mdDocumentation5.9 KB
.gitattributesRepository690 B

License and Download

License
apache-2.0
Access
Open weights, no gate
Download size
172.2 MB
Download from AI at Meta

Released by AI at Meta through its official repository on Hugging Face. Read the license.

Built From

Memory Requirements

PrecisionWeights in memory
As published172.2 MB

Weights only, from the published parameter count; the key-value cache and runtime add to this.

Questions About detr-resnet-50-panoptic

Can I use detr-resnet-50-panoptic commercially?

Yes. detr-resnet-50-panoptic is released under Apache License 2.0. The Apache License 2.0 is a permissive open-source license. It permits commercial use, modification and redistribution. It requires keeping the license and copyright notices and any NOTICE file, stating significant changes, and it includes an express patent grant from contributors.

What is detr-resnet-50-panoptic's context length?

1,024 tokens, from the maximum position embeddings in its published configuration.

Similar Models

Model · Image segmentation

segformer-b2-finetuned-ade-512-512

NVIDIA

SegFormer model fine-tuned on ADE20k at resolution 512x512. It was introduced in the paper SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers by Xie et al. and first released in this repository. Disclaimer: The team releasing SegFormer did not write a model card for this model so this model card has been written by the Hugging Face team. SegFormer consists of a hierarchical Transformer encoder and a lightweight all-MLP decode head to achieve great results on semantic segmentation benchmarks such as ADE20K and Cityscapes. The hierarchical Transformer is first pre-trained on ImageNet-1k, after which a decode head is added and fine-tuned altogether on a…

Open weights other transformers

Model · Image segmentation

segformer-b3-finetuned-ade-512-512

NVIDIA

SegFormer model fine-tuned on ADE20k at resolution 512x512. It was introduced in the paper SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers by Xie et al. and first released in this repository. Disclaimer: The team releasing SegFormer did not write a model card for this model so this model card has been written by the Hugging Face team. SegFormer consists of a hierarchical Transformer encoder and a lightweight all-MLP decode head to achieve great results on semantic segmentation benchmarks such as ADE20K and Cityscapes. The hierarchical Transformer is first pre-trained on ImageNet-1k, after which a decode head is added and fine-tuned altogether on a…

Open weights other transformers

Model · Image segmentation

oneformer_ade20k_swin_large

SHI Labs

OneFormer model trained on the ADE20k dataset (large-sized version, Swin backbone). It was introduced in the paper OneFormer: One Transformer to Rule Universal Image Segmentation by Jain et al. and first released in this repository. OneFormer is the first multi-task universal image segmentation framework. It needs to be trained only once with a single universal architecture, a single model, and on a single dataset, to outperform existing specialized models across semantic, instance, and panoptic segmentation tasks. OneFormer uses a task token to condition the model on the task in focus, making the architecture task-guided for training, and task-dynamic for inference, all with a single…

Open weights mit transformers

Model · Image segmentation

segformer-b1-finetuned-ade-512-512

NVIDIA

SegFormer model fine-tuned on ADE20k at resolution 512x512. It was introduced in the paper SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers by Xie et al. and first released in this repository. Disclaimer: The team releasing SegFormer did not write a model card for this model so this model card has been written by the Hugging Face team. SegFormer consists of a hierarchical Transformer encoder and a lightweight all-MLP decode head to achieve great results on semantic segmentation benchmarks such as ADE20K and Cityscapes. The hierarchical Transformer is first pre-trained on ImageNet-1k, after which a decode head is added and fine-tuned altogether on a…

Open weights other transformers

Model · Image segmentation

segformer-b0-finetuned-ade-512-512

Joshua

https://huggingface.co/nvidia/segformer-b0-finetuned-ade-512-512 with ONNX weights to be compatible with Transformers.js. If you haven't already, you can install the Transformers.js JavaScript library from NPM using: Example: Image segmentation with Xenova/segformer-b0-finetuned-ade-512-512. You can visualize the outputs with: Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using Optimum and structuring your repo like this one (with ONNX weights located in a subfolder named onnx).

Open weights transformers.js

Model · Image segmentation

DelineateAnything

Mykola Lavreniuk

Delineate Anything v2 extends Delineate Anything into a globally representative, resolution-agnostic foundation model that scales agricultural field boundary detection to a planetary level from any imagery source. Trained on FBIS-73M, a massive 73-million-instance dataset spanning 61 countries with diverse imagery sources ranging from 0.25m to 10m resolution, built through a resolution-specific curation pipeline that solves the parcel-versus-field mismatch, Delineate Anything v2 sets a new state-of-the-art in global zero-shot delineation. It delivers a +103.3% relative gain in [email protected] over Delineate Anything while maintaining extreme efficiency, mapping all of Ukraine (603,000 km²) in 5.4…

Open weights agpl-3.0 ultralytics