Machine Learning

RF-DETR under the hood: Insights into actual transformer detection

In the world of computer vision, you may have heard of RF-depr, a new model for real-time object detection from roboflow. It has become the new SoTA with its impressive performance. But to truly appreciate what makes it tick, we need to look beyond the benches and get inside its DNA.

RF-DETR is not entirely new; Its story is a fascinating system of solving one problem at a time, starting with the basic limitation in the original TRR and ending with the real-time Transformer. Let us trace this evolution.

A paradigm shift in Pipelines Pipelines

In 2020 came Detect (Detection Transformer) [1]a model that has completely changed the object discovery pipeline. It was the first end-to-end detector, eliminating the need for hand-crafted elements such as anchor generation and surface tension (NMS). It achieved this by combining the CNN Backbone with a Transformer Decoder-Decoder Architecture. Despite its revolutionary design, the original DETR had major problems:

  1. Extremely slow conversion: DEDR requires a large number of training epochs to evolve, which was 10-20 times slower than similar fast r-CNN models.
  2. High computational complexity: The attention method in Transformer Encoder has a complexity of O (H2W2C) in relation to the spatial dimensions (H, W) of the feature map. This quadratic complexity made it prohibitively expensive to process high-resolution maps.
  3. Poor performance of small things: As a direct result of its high complexity, DETR could not use high-resolution maps, which are important for detecting small objects.

These problems are all focused on the way Transformer The attention of integrated images by looking at every Pixel, which was not efficient and difficult to train.

Success: Deformable Depr

To solve the problems of DETR, researchers looked back and found inspiration in Confectionery Convenulval Networks [2]. For years, CNNs have dominated computer vision. However, they have a natural limitation: they struggle to prepare for geometric changes. This is because their main building blocks, such as layering and pooling, organize geometric structures. This is where adaptive CNNs come into the scene. The main idea was remarkably simple: What if the sampling grid in CNNs were fixed?

  • A new module, visual appearancewhich enlarges the normal grid areas sampled by 2D offsets.
  • In particular, these illegal items are not fixed; of course – read From the previous feature maps through additional congloval layers.
  • This allows the sample grid to be with power deform and adapt to object shape and scale in a native, static way.
Photo by the Author

This idea of ​​a dynamic sample from physical objects was used for the Transformer attention method. The result was Deformable Depr [3].

Core Innovation is it Impaired attention module. Instead of combining the tools to focus on every pixel in the feature map, this module does something very clever:

  • It exists in a small, fixed number of sample points around a reference point.
  • As in the visual phase, the 2D offsets of these sample points are read from the query objects themselves by linear projection.
  • They bypass the need for a separate FPN architecture because its attentional mechanism has built-in processing capabilities and direct mulse-scale features.
An illustration of an impaired attention module removed from it [3]

The effectiveness of visual attention is that it “corresponds to a small set of key points” [3] around the reference area, regardless of the area size of the feature maps. The analysis of the paper shows that when this new module is used in the Encoder (when the number of questions, nbloomequal to the surface size, HW), the hardness becomes O (HWC2), corresponding to the area size. This single change makes it easier to process high-resolution maps, dramatically improving the performance of small objects.

Which makes it real time: lw-detr

Decformeble Depr fixed convergence and accuracy issues, but to compete with models like YOLO, it needed to be faster. That's it Lw-detr (DETR light weight) [4] It comes in. Its purpose was to create a Transformer-based design that is outside of the yolo models that come out of the real thing. The architecture is a simple stack: a Vision Transformer (VIT) Encoder, a projector, and a shallow DRR decoder. They removed the architecture of the encoder-decoder decor from the dentr framework and kept only the decoder part, because it can be seen in this line of code.

Photo by the Author

To achieve its speed, it incorporated several key key strategies:

  • Visual comments: The decoder directly uses the visual attention mechanism from the deformable decformer, which is very important for its performance.
  • Integrated window and global attention: Vit Encoder is expensive. To reduce its complexity, LW-DETR has replaced some of the world's most expensive attention layers with much cheaper attention layers.
  • Shallow Decoder: Standard variations of DRR typically use 6 decoder layers. LW-Dedr uses only 3, which greatly reduces latency.

The projector in the LW-Depr acts as an important bridge, connecting the Encoder of the Vision Transformer (VIT) to the Decoder of the DETR. It is designed using a C2F blockwhich is the effective block used in the yolov8 model. This block processes the features and prepares them for the decoder's Cross-Attention Mechanism. By combining the power of visual attention with these simple design options, LW-Depr has proven that a Depr-style model can be a real-time detector.

Interfacing pieces of RF-DRR

And that brings us back to rf-detr [5]. It is not a reverse breakthrough but the next step in this evolutionary process. Specifically, they created RF-DETR by combining LW-DETR with the pre-trained Dinov2 Backbone as seen in this line of code. This provides a different model to adapt to the veil domains according to the information stored in the pre-trained Dinov2. The reason for this different consistency is that Dinov2 is a set model. Unlike traditional backbones trained on imagenet with fixed labels, Dinov2 was trained on a large, unspecified dataset without human labels. It is learned by solving a “jigsaw puzzle” of sorts, forcing to develop a rich and general understanding of the texture, structure and parts of an object. When RF-detr uses this core, it is not just a feature extractor; It acquires an in-depth visual knowledge base that can be well organized through specialized tasks that work well.

Photo by the Author

The main difference with respect to the previous models is that the visual Depr uses a multi-articulation method, while the RF-DETR model extracts feature maps from the background image. Recently, the group behind the RF-DETR model, installed a separation head to provide a mask over the junction boxes, making it a suitable method for group activities. Please refer to its documentation to start using it, fine-tune or export it in Onnx format.

Lasting

The original Dedr changed the detection pipeline by removing manually designed elements such as NMS, but it could have been due to reduced volatility and quadratic complexity. Deprble Depr has provided a key Architueve, international exchange of attention to include Sampling Mechanis allowed by Deformec. LW-DETR then proved this successful real-time construction, challenging yolo's dominance. RF-Dedr represents the next logical step: It combines this highly optimized, energy-degrading construction with today's backbone, which steers backwards.

Progress

[1] End-to-end detection of transformers. Nicolas Carion et. al. 2020.

[2] Convelsulul conformal networks. Jifeng dai et. al. 2017.

[3] Deformeble Decr: Defecform Transformers are visible for end-to-end detection. Xizhou zhu et. al. 2020.

[4] LW-DETR: Transformer replacement in Yolo with original detection. Qiang Chen et. al. 2024.

[5]

Source link

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button