xiuqhou commited on
Commit
eb8051e
1 Parent(s): 6ddaca2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +72 -158
README.md CHANGED
@@ -8,176 +8,108 @@ language:
8
  pipeline_tag: object-detection
9
  ---
10
 
11
- # Model Card for Model ID
12
-
13
- <!-- Provide a quick summary of what the model is/does. -->
14
-
15
-
16
 
17
  ## Model Details
18
 
19
  ### Model Description
20
 
21
- <!-- Provide a longer summary of what this model is. -->
22
-
23
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
24
-
25
- - **Developed by:** [More Information Needed]
26
- - **Funded by [optional]:** [More Information Needed]
27
- - **Shared by [optional]:** [More Information Needed]
28
- - **Model type:** [More Information Needed]
29
- - **Language(s) (NLP):** [More Information Needed]
30
- - **License:** [More Information Needed]
31
- - **Finetuned from model [optional]:** [More Information Needed]
32
-
33
- ### Model Sources [optional]
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
  <!-- Provide the basic links for the model. -->
36
 
37
- - **Repository:** [More Information Needed]
38
- - **Paper [optional]:** [More Information Needed]
39
- - **Demo [optional]:** [More Information Needed]
40
-
41
- ## Uses
42
-
43
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
44
-
45
- ### Direct Use
46
-
47
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
48
-
49
- [More Information Needed]
50
-
51
- ### Downstream Use [optional]
52
-
53
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
54
-
55
- [More Information Needed]
56
-
57
- ### Out-of-Scope Use
58
-
59
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
60
-
61
- [More Information Needed]
62
-
63
- ## Bias, Risks, and Limitations
64
-
65
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
66
-
67
- [More Information Needed]
68
-
69
- ### Recommendations
70
-
71
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
72
-
73
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
74
 
75
  ## How to Get Started with the Model
76
 
77
  Use the code below to get started with the model.
78
 
79
- [More Information Needed]
80
-
81
- ## Training Details
82
-
83
- ### Training Data
84
 
85
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
 
86
 
87
- [More Information Needed]
 
88
 
89
- ### Training Procedure
 
90
 
91
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
92
 
93
- #### Preprocessing [optional]
 
94
 
95
- [More Information Needed]
96
 
 
 
 
 
 
 
97
 
98
- #### Training Hyperparameters
99
-
100
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
101
 
102
- #### Speeds, Sizes, Times [optional]
 
 
 
 
 
 
103
 
104
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
105
 
106
- [More Information Needed]
107
 
108
  ## Evaluation
109
 
110
- <!-- This section describes the evaluation protocols and provides the results. -->
111
-
112
- ### Testing Data, Factors & Metrics
113
-
114
- #### Testing Data
115
-
116
- <!-- This should link to a Dataset Card if possible. -->
117
-
118
- [More Information Needed]
119
 
120
- #### Factors
121
 
122
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
123
 
124
- [More Information Needed]
125
 
126
- #### Metrics
127
 
128
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
129
-
130
- [More Information Needed]
131
-
132
- ### Results
133
-
134
- [More Information Needed]
135
-
136
- #### Summary
137
-
138
-
139
-
140
- ## Model Examination [optional]
141
-
142
- <!-- Relevant interpretability work for the model goes here -->
143
-
144
- [More Information Needed]
145
-
146
- ## Environmental Impact
147
-
148
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
149
-
150
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
151
-
152
- - **Hardware Type:** [More Information Needed]
153
- - **Hours used:** [More Information Needed]
154
- - **Cloud Provider:** [More Information Needed]
155
- - **Compute Region:** [More Information Needed]
156
- - **Carbon Emitted:** [More Information Needed]
157
-
158
- ## Technical Specifications [optional]
159
-
160
- ### Model Architecture and Objective
161
-
162
- [More Information Needed]
163
-
164
- ### Compute Infrastructure
165
-
166
- [More Information Needed]
167
-
168
- #### Hardware
169
-
170
- [More Information Needed]
171
-
172
- #### Software
173
-
174
- [More Information Needed]
175
-
176
- ## Citation [optional]
177
-
178
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
179
-
180
- **BibTeX:**
181
 
182
  ```
183
  @misc{hou2024relationdetrexploringexplicit,
@@ -191,24 +123,6 @@ Carbon emissions can be estimated using the [Machine Learning Impact calculator]
191
  }
192
  ```
193
 
194
- **APA:**
195
-
196
- [More Information Needed]
197
-
198
- ## Glossary [optional]
199
-
200
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
201
-
202
- [More Information Needed]
203
-
204
- ## More Information [optional]
205
-
206
- [More Information Needed]
207
-
208
- ## Model Card Authors [optional]
209
-
210
- [More Information Needed]
211
-
212
- ## Model Card Contact
213
 
214
- [More Information Needed]
 
8
  pipeline_tag: object-detection
9
  ---
10
 
11
+ # Relation DETR model with ResNet-50 backbone
 
 
 
 
12
 
13
  ## Model Details
14
 
15
  ### Model Description
16
 
17
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/66939171e3a813f3bb10e804/kNzBZZ2SFq6Wgk2ki_c5t.png)
18
+
19
+ > This paper presents a general scheme for enhancing the convergence and performance of DETR (DEtection TRansformer).
20
+ > We investigate the slow convergence problem in transformers from a new perspective, suggesting that it arises from
21
+ > the self-attention that introduces no structural bias over inputs. To address this issue, we explore incorporating
22
+ > position relation prior as attention bias to augment object detection, following the verification of its statistical
23
+ > significance using a proposed quantitative macroscopic correlation (MC) metric. Our approach, termed Relation-DETR,
24
+ > introduces an encoder to construct position relation embeddings for progressive attention refinement, which further
25
+ > extends the traditional streaming pipeline of DETR into a contrastive relation pipeline to address the conflicts
26
+ > between non-duplicate predictions and positive supervision. Extensive experiments on both generic and task-specific
27
+ > datasets demonstrate the effectiveness of our approach. Under the same configurations, Relation-DETR achieves a
28
+ > significant improvement (+2.0% AP compared to DINO), state-of-the-art performance (51.7% AP for 1x and 52.1% AP
29
+ > for 2x settings), and a remarkably faster convergence speed (over 40% AP with only 2 training epochs) than existing
30
+ > DETR detectors on COCO val2017. Moreover, the proposed relation encoder serves as a universal plug-in-and-play component,
31
+ > bringing clear improvements for theoretically any DETR-like methods. Furthermore, we introduce a class-agnostic detection
32
+ > dataset, SA-Det-100k. The experimental results on the dataset illustrate that the proposed explicit position relation
33
+ > achieves a clear improvement of 1.3% AP, highlighting its potential towards universal object detection.
34
+ > The code and dataset are available at [this https URL](https://github.com/xiuqhou/Relation-DETR).
35
+
36
+ - **Developed by:** [Xiuquan Hou]
37
+ - **Shared by:** Xiuquan Hou
38
+ - **Model type:** Relation DETR
39
+ - **License:** Apache-2.0
40
+
41
+ ### Model Sources
42
 
43
  <!-- Provide the basic links for the model. -->
44
 
45
+ - **Repository:** [https://github.com/xiuqhou/Relation-DETR](https://github.com/xiuqhou/Relation-DETR)
46
+ - **Paper:** [Relation DETR: Exploring Explicit Position Relation Prior for Object Detection](https://arxiv.org/abs/2407.11699)
47
+ <!-- - **Demo [optional]:** [More Information Needed] -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
  ## How to Get Started with the Model
50
 
51
  Use the code below to get started with the model.
52
 
53
+ ```python
54
+ import torch
55
+ import requests
 
 
56
 
57
+ from PIL import Image
58
+ from transformers import RelationDetrForObjectDetection, RelationDetrImageProcessor
59
 
60
+ url = 'http://images.cocodataset.org/val2017/000000039769.jpg'
61
+ image = Image.open(requests.get(url, stream=True).raw)
62
 
63
+ image_processor = RelationDetrImageProcessor.from_pretrained("PekingU/rtdetr_r50vd")
64
+ model = RelationDetrForObjectDetection.from_pretrained("PekingU/rtdetr_r50vd")
65
 
66
+ inputs = image_processor(images=image, return_tensors="pt")
67
 
68
+ with torch.no_grad():
69
+ outputs = model(**inputs)
70
 
71
+ results = image_processor.post_process_object_detection(outputs, target_sizes=torch.tensor([image.size[::-1]]), threshold=0.3)
72
 
73
+ for result in results:
74
+ for score, label_id, box in zip(result["scores"], result["labels"], result["boxes"]):
75
+ score, label = score.item(), label_id.item()
76
+ box = [round(i, 2) for i in box.tolist()]
77
+ print(f"{model.config.id2label[label]}: {score:.2f} {box}")
78
+ ```
79
 
80
+ This should output
 
 
81
 
82
+ ```python
83
+ cat: 0.96 [343.8, 24.9, 639.52, 371.71]
84
+ cat: 0.95 [12.6, 54.34, 316.37, 471.86]
85
+ remote: 0.95 [40.09, 73.49, 175.52, 118.06]
86
+ remote: 0.90 [333.09, 76.71, 369.77, 187.4]
87
+ couch: 0.90 [0.44, 0.53, 640.44, 475.54]
88
+ ```
89
 
90
+ ## Training Details
91
 
92
+ Relation DEtection TRansformer (Relation DETR) model is trained on [COCO 2017 object detection](https://cocodataset.org/#download) (118k annotated images) for 12 epochs (aka 1x schedule).
93
 
94
  ## Evaluation
95
 
96
+ | Model | Backbone | Epoch | mAP | AP<sub>50 | AP<sub>75 | AP<sub>S | AP<sub>M | AP<sub>L |
97
+ | ------------------- | -------------------- | :---: | :---: | :-------: | :-------: | :------: | :------: | :------: |
98
+ | Relation DETR | ResNet50 | 12 | 51.7 | 69.1 | 56.3 | 36.1 | 55.6 | 66.1 |
99
+ | Relation DETR | Swin-L<sub>(IN-22K) | 12 | 57.8 | 76.1 | 62.9 | 41.2 | 62.1 | 74.4 |
100
+ | Relation DETR | ResNet50 | 24 | 52.1 | 69.7 | 56.6 | 36.1 | 56.0 | 66.5 |
101
+ | Relation DETR | Swin-L<sub>(IN-22K) | 24 | 58.1 | 76.4 | 63.5 | 41.8 | 63.0 | 73.5 |
102
+ | Relation-DETR<sup>† | Focal-L<sub>(IN-22K) | 4+24 | 63.5 | 80.8 | 69.1 | 47.2 | 66.9 | 77.0 |
 
 
103
 
104
+ means finetuned model on COCO after pretraining on Object365.
105
 
106
+ ## Model Architecture and Objective
107
 
108
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/66939171e3a813f3bb10e804/UMtLjkxrwoDikUBlgj-Fc.png)
109
 
110
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/66939171e3a813f3bb10e804/MBbCM-zQGgUjKUmwB0yje.png)
111
 
112
+ ## Citation and BibTeX
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
 
114
  ```
115
  @misc{hou2024relationdetrexploringexplicit,
 
123
  }
124
  ```
125
 
126
+ ## Model Card Authors
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
 
128
+ [xiuqhou](https://huggingface.co/xiuqhou)