DEV Community

jinghao-ai
jinghao-ai

Posted on

Hunting Einstein Rings: Achieving 0.994 mAP in Deep-Space Detection with RT-DETR

1.Introduction: The Needle in a Haystack

Detecting Strong Gravitational Lensing(e.g., Einstein Rings) is a quintessential "needle-in-a-haystack" problem in astrophysics. Traditional methods are either computationally expensive or prone to high false-positive rates due to complex cosmic backgrounds.

In this project, I deployed the RT-DETR (Real-Time Detection Transformer) **architecture to automate this process, achieving a near-perfect **0.994 mAP@50 and a 1.00 Confusion Matrix score across 1001 unseen deep-space samples.

2.Mathematical Optimization: GloU Loss
One major challenge was the sparity of lensing arcs. During early training, predicted anchors often had zero overlap with ground truth, leading to vanishing gradients in standard loU.

I implemented **Generalized loU(GloU) **to provide continuous gradients even for non-overlapping boxes:

GIoU = IoU - (|C \ (A ∪ B)|) / |C|
Enter fullscreen mode Exit fullscreen mode

This geometric penalty was the cornerstone for stabilizing the regression loss at ~0.1.

3.Architectural Advantages: Global Self-Attention

why RT-DETR? Unlike traditional CNNs with limited local receptive fields, the Hybrid Encoder in RT-DETR utilizes Self-Attention to captures long-range spatial dependencies.

Attention(Q, K, V) = Softmax( (QK^T) / sqrt(d_k) ) * V
Enter fullscreen mode Exit fullscreen mode

This allows the model to correlate the central lens galaxy with peripheral arcs simultaneously, ensuring robust detection even when the lensing signals are extremely faint.

4.Scaling to 1001 Samples

To prove the model's reliability for actual sky surveys, I developed an automated pipeline to process 1001 unseen samples. The results were remarkable: zero false positives and a consistant detection confidence exceeding 0.96. This level of precision is critical for minimizing "ghost signals" in astronomical research.

5. Conclusion & Open Source

This project bridges the gap between state-of-the-art Computer Vision and Astronomical Observation. I have open-sorced the full pipeline, including the mathmatical derivations and training logs, on my Github.

*Github chain: https://github.com/jinghao-ai/Lensing-Detection-RTDETR
*

Top comments (1)

Collapse
 
jinghaoai profile image
jinghao-ai

All the code, training weights (hosted on LFS), and more detailed mathematical derivations (on Wiki) of this project have been open-sourced on GitHub. Friends who are interested in astronomical object detection and the RT-DETR architecture are welcome to join in the discussion! I also hope to keep making progress.😊