nielsr HF staff commited on
Commit
30d44fb
1 Parent(s): d1b2ea2

Add model card

Browse files
Files changed (1) hide show
  1. README.md +91 -0
README.md ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - object-detection
5
+ datasets:
6
+ - coco
7
+ ---
8
+
9
+ # DETR (End-to-End Object Detection) model with ResNet-50 backbone (dilated C5 stage)
10
+
11
+ DEtection TRansformer (DETR) model trained end-to-end on COCO 2017 object detection (118k annotated images). It was introduced in the paper [End-to-End Object Detection with Transformers](https://arxiv.org/abs/2005.12872) by Carion et al. and first released in [this repository](https://github.com/facebookresearch/detr).
12
+
13
+ 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.
14
+
15
+ ## Model description
16
+
17
+ 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.
18
+
19
+ 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.
20
+
21
+ ## Intended uses & limitations
22
+
23
+ You can use the raw model for object detection. See the [model hub](https://huggingface.co/models?search=facebook/detr) to look for all available DETR models.
24
+
25
+ ### How to use
26
+
27
+ Here is how to use this model:
28
+
29
+ ```python
30
+ from transformers import DetrFeatureExtractor, DetrForObjectDetection
31
+ from PIL import Image
32
+ import requests
33
+
34
+ url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
35
+ image = Image.open(requests.get(url, stream=True).raw)
36
+
37
+ feature_extractor = DetrFeatureExtractor.from_pretrained('facebook/detr-resnet-50-dc5')
38
+ model = DetrForObjectDetection.from_pretrained('facebook/detr-resnet-50-dc5')
39
+
40
+ inputs = feature_extractor(images=image, return_tensors="pt")
41
+ outputs = model(**inputs)
42
+
43
+ # model predicts bounding boxes and corresponding COCO classes
44
+ logits = outputs.logits
45
+ bboxes = outputs.pred_boxes
46
+ ```
47
+
48
+ Currently, both the feature extractor and model support PyTorch.
49
+
50
+ ## Training data
51
+
52
+ The DETR model was trained on [COCO 2017 object detection](https://cocodataset.org/#download), a dataset consisting of 118k/5k annotated images for training/validation respectively.
53
+
54
+ ## Training procedure
55
+
56
+ ### Preprocessing
57
+
58
+ The exact details of preprocessing of images during training/validation can be found [here](https://github.com/google-research/vision_transformer/blob/master/vit_jax/input_pipeline.py).
59
+
60
+ 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).
61
+
62
+ ### Training
63
+
64
+ 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).
65
+
66
+ ## Evaluation results
67
+
68
+ This model achieves an AP (average precision) of **43.3** on COCO 2017 validation. For more details regarding evaluation results, we refer to table 1 of the original paper.
69
+
70
+ ### BibTeX entry and citation info
71
+
72
+ ```bibtex
73
+ @article{DBLP:journals/corr/abs-2005-12872,
74
+ author = {Nicolas Carion and
75
+ Francisco Massa and
76
+ Gabriel Synnaeve and
77
+ Nicolas Usunier and
78
+ Alexander Kirillov and
79
+ Sergey Zagoruyko},
80
+ title = {End-to-End Object Detection with Transformers},
81
+ journal = {CoRR},
82
+ volume = {abs/2005.12872},
83
+ year = {2020},
84
+ url = {https://arxiv.org/abs/2005.12872},
85
+ archivePrefix = {arXiv},
86
+ eprint = {2005.12872},
87
+ timestamp = {Thu, 28 May 2020 17:38:09 +0200},
88
+ biburl = {https://dblp.org/rec/journals/corr/abs-2005-12872.bib},
89
+ bibsource = {dblp computer science bibliography, https://dblp.org}
90
+ }
91
+ ```