LARGAL: Learning Latent Representation of Radio Galaxies for Efficient Compression and Improved Classification
ABSTRACT
LARGAL is a novel computer vision system that detects, extracts and classifies radio galaxies from survey images. LARGAL’s hybrid machine learning architecture combines the representative power of neural networks with the discriminative power of gradient boosted decision trees. At its core is a Variational Auto Encoder (VAE) with attention layers that learns to represent radio galaxies in a rich yet compact latent vector representation that could be used for a range of data analysis tasks. This work demonstrates that the learned representation has sufficient discriminative power that downstream tasks, such as classification, can still achieve state of the art results of a 61.7% mAP. The latent vector representation reduces the size of radio galaxy datasets by 99% (two orders of magnitude), enabling efficient storage and processing of data collected by large-scale radio telescope surveys. The source code is available at: https://github.com/Pymaster3119/LARGAL.
INTRODUCTION.
A radio galaxy is a type of galaxy that emits exceptionally strong radio waves, often forming enormous regions that extend far beyond the galaxy’s visible and infrared structure. While many radio galaxies may initially appear as small, compact, circular sources, more sensitive radio observations reveal that they can have complex, extended structures composed of multiple components, each exhibiting its own peak radio emission [1].
Modern radio surveys, like LOFAR [2] and SKA [3], are revolutionizing astronomy by mapping millions of extragalactic radio sources. LOFAR, operating primarily at low frequencies, uses a distributed array of antennas across Europe to achieve high angular resolution, enabling studies of radio galaxy evolution. Meanwhile, SKA, designed to be the world’s largest and most sensitive radio telescope, will operate across a broader frequency range of 50MHz to 15GHz in South Africa. It is designed to work quickly and to provide extremely precise measurements of radio galaxy populations. However, these surveys are expected to produce vast amounts of data throughout their operation. For example, the LOFAR survey is expected to produce a total of 5 petabytes of science data per year, and the SKA survey is expected to produce 700 petabytes of science data per year [4].
Systems for detecting radio galaxies start with cleaned and calibrated radio maps from large surveys. Traditional tools such as PyBDSF [5] then scan these images to identify bright sources and separate extended radio structures. More recent work, such as the RadioGalaxyNET GAL-DINO model [1] or the ClaRAN system [6], introduces machine-learning models that can automatically recognize radio-galaxy shapes and distinguish them from other sources. LARGAL builds upon these approaches by leveraging a Variational Auto Encoder (VAE) [7] enhanced with self-attention [8] to learn a latent representation of radio galaxies that captures key features useful for supervised tasks such as classification, unsupervised tasks such as anomaly detection, and the creation of novel instances.
MATERIALS AND METHODS.
LARGAL is a hybrid system that combines deep learning with a traditional tree-based classifier. LARGAL’s pipeline includes the object detection model YOLOv8s [8], a VAE [7] enhanced with self-attention layers [9], and two size-specific Histogram Gradient Boosting models (based on LightGBM [10]) to produce classifications, as shown in Figure 1.

Dataset.
LARGAL was trained with data from the RadioGalaxyNET dataset [1], which includes 2,800 postprocessed images (Figure 2) of radio galaxies from the EMU-PS survey [11] featuring 4,155 instances of extended radio galaxies. Each image contains three channels of information. The first channel contains 8 bits of infrared data, and the second and third channels together contain sixteen bits of radio data. The dataset is made up of 13% FR-I, 48% FR-II, 14% FR-x, and 25% R sources. FR-I and FR-II radio galaxies are classified based on the morphologies described in Fanaroff-Riley classification [12]: FR-I sources have dark edges, while FR-II sources have brighter edges compared to the central host galaxy. FR-X classification was used when there were uncertainties in determining total extent and peak flux positions. R type radio galaxies include resolved sources with extended emissions but no clear peaks apart from the infrared source. The dataset has been divided into three splits: 70% training data, 15% testing data, and 15% validation data. Though each image is 450×450 pixels, the majority of this dataset is composed of images of radio galaxies with an area between 24 and 48 square pixels.

Detection.
In order to automatically detect radio galaxies in images, LARGAL uses YOLOv8s [8], a lightweight yet high-performance deep learning model developed by Ultralytics. YOLOv8s is a state-of-the-art object detection model, known for its extreme speed and accuracy. The model’s design leverages modern improvements in convolutional neural networks (CNNs), including CSPDarknet-based backbones [13] and dynamic label assignment [14], enabling robust feature extraction from complex radio imagery. The “s” variant, with its smaller parameter count, eliminates the overfitting experienced by larger versions.
Transfer learning was applied to domain adapt YOLOv8s to radio galaxy images. A model pretrained on the COCO dataset was fine-tuned on images from the RadioGalaxyNET by training for 50 epochs on images resized to 640x640x3 (scaled up from the original 450x450x3 to meet YOLO requirements). Interpolation preserves large scale structural features like the shape, orientation and relative sizes of objects. Since the focus of this work is morphological analysis and not precision photometry, interpolation does not affect model prediction. The trained YOLO model outputs bounding boxes for galaxies without regard for galaxy type. It was trained with a learning rate of 0.001 with a batch size of 64. Finetuning of this model took 53 minutes on an NVIDIA GeForce GTX 1080.
The model was trained to minimize box loss [15], distribution focal loss [16] (made for accurate prediction of bounding box coordinates), and classification loss. Throughout its training cycle, it showed a continuous downwards trend in each of these values on the validation set, as seen in Fig. S1, indicating no overfitting.
Variational Autoencoder.
A self-attention enhanced VAE architecture [7,9] was used to condense the extracted radio galaxies into 128-dimension latent vectors. As shown in Figure 1, galaxy images detected by YOLOv8s are extracted and resized to 64x64x3 using cubic interpolation. Because most radio galaxies are not square, a naïve scaling algorithm will alter the aspect ratio and destroy important morphological information. Therefore, this work uses a scale-to-fit algorithm based on the longest edge to ensure the aspect ratio is preserved. Cubic interpolation, while computationally expensive, avoids artifacts from other methods such as bilinear interpolation, which this study noted caused a drop in VAE reconstruction quality.
As shown in Figure 3, the scaled images are input to the VAE’s encoder which quickly expands it to a high-dimensional feature space using initial convolutions [17], residual blocks [18], and a series of strided convolutions that downsample while increasing channel depth up to 512. Then, it applies a self-attention block [9] and normalization before projecting the representation into a low-dimensional latent space via small convolutions and two linear heads that output the mean and log-variance vectors. The mean and log-variance vectors are then sampled using a standard VAE resampling formula, where μ represents the mean and σ represents the log-variance:
\[Sample=\ N\left(\mu,\ {0.5}^\sigma\right)\tag{1}\]
The decoder inverts the above process by mapping the latent vector through a linear layer into a small spatial feature map, expanding channels with an initial convolution to 512, then using residual blocks, self-attention block, and multiple upsampling stages that gradually reduce channels depth back to 128 while increasing spatial resolution. After final normalization and activation, a 3×3 convolution produces the reconstructed 3-channel RGB output. The model has 13 million and 22 million trainable weights in the encoder and decoder respectively.

During training, the VAE used data augmentations to improve its robustness and prevent overfitting. These augmentations included random horizontal and vertical flips, rotation between 0-360 degrees, and affine transformations. Each augmentation has a 50% probability of being applied to any given sample and significantly helps prevent overfitting in the model.
This VAE was trained over 40 epochs with a learning rate of with the Adam optimizer [19]. The addition of attention layers allowed the model to create more accurate reconstructions than a model without attention. This model was trained to optimize the mean squared error of its reconstructions (multiplied by 0.005) and KL Divergence Loss [20], ensuring that the model achieved generalization and continual improvement throughout its training, as seen in the loss curves in Fig. S2. Though the VAE’s decoder is not used during classification in LARGAL, it could be used to generate novel radio galaxy samples through sampling or to recreate the radio galaxy from the saved latent representation for visualization.
Histogram Gradient Boosting.
Two Histogram Gradient Boosting [10] models were trained on the 128-dimensional latent representation sampled from VAE encoder outputs. While one Histogram Gradient Boosting model was trained exclusively on “small” samples (those with an area of under 576 pixels2), the other was trained on “medium” and “large” samples (those with an area greater than 576 pixels2). This algorithm was selected for its efficiency in handling continuous numerical data and its ability to model complex, non-linear relationships through an ensemble of decision trees. The best-performing configuration of hyperparameters was found to use a learning rate of 0.1, no restriction on the maximum tree depth (allowing the model to fully expand trees as needed), and a total of 300 boosting iterations. This combination provided a strong balance between model complexity and generalization performance, outperforming other classifiers, as shown in Tables S1 and S2.
RESULTS.
Though the VAE reduces the input’s size by 95.8% when creating its latent representation, it has achieved a mean squared error in its reconstruction of 159.35, showing its ability to recreate the core details of each radio galaxy through its reconstructions in Figure 4.

Figure 5 is a t-SNE [21] plot of reduced-dimension latent vectors of all validation samples. It demonstrates that the VAE learnt a representation that inherently separates the classes of galaxies by type, proving its potential for a wide range of downstream tasks such as unsupervised learning, detecting anomalies, and generating novel instances.
T-distributed Stochastic Neighbor Embedding (t-SNE) was used to analyze the structure of the learned latent space. T-SNE is a dimensionality reduction technique that projects high-dimensional vectors into two dimensions while preserving similarity relationships. Vectors that are close together in latent space are also close together in the reduced two dimensional space. Figure 5 shows the resulting projection of the validation dataset encoded by the VAE.

The small histogram gradient boosting model [10], when given the VAE’s latent vectors as input, has achieved a 76.43% accuracy on validation data and 81.38% accuracy on testing data. Meanwhile, the model trained on medium and large samples achieved an accuracy of 77.19% on validation data, and 78.64% on testing data. This data also shows that the histogram gradient boosting models outperformed other models, as seen in Table S1 and S2.
Metrics.
To evaluate detection performance, mean Average Precision (mAP) [22] is computed over all object classes. For each class, predicted bounding boxes are sorted by confidence and matched to ground-truth boxes using an IoU threshold \(\tau\). The Intersection-over-Union between a predicted box \(B_p\)and ground-truth box \(B_{gt}\) is:
\[IoU\left(B_P,B_{gt}\right)=\ \frac{\left|B_p\cap B_{gt}\right|}{\left|B_p\cup B_{gt}\right|}\tag{2}\]
A prediction is counted as a true positive if \( IoU\geq\ \tau\); otherwise it is a false positive (FP). From the ranked list, precision and recall at each detection index k are defined as
\[Precision\left(k\right)=\frac{TP\left(k\right)}{TP\left(k\right)+FP\left(k\right)}\tag{3}\]
\[Recall\left(k\right)=\frac{TP\left(k\right)}{N_{gt}}\tag{4}\]
where \(N_{gt}\) is the number of ground-truth objects for that class. Average Precision (AP) is computed as the area under the precision–recall curve:
\[AP=\ \int_{0}^{1}P\left(R\right)dR\tag{5}\]
approximated by summing over discrete recall levels. The overall mAP is then the mean of AP across all C classes:
\[mAP=\ \frac{1}{C}\sum_{c=1}^{C}{AP}_i\tag{6}\]
Results.
The full pipeline achieved an mAP score of 61.7% at an IoU threshold of 0.5 and an mAP score of 60% at an IoU threshold of 0.75, surpassing the current state-of-the-art Gal-DINO model described in RadioGalaxyNET [1], as shown in Table 1. LARGAL’s average mAP score taken over IoU intervals of 0.05 to 0.95 was 53.5%, paralleling the GAL-DINO model.
In addition to these measurements, it is important to note the model’s performance on varying object sizes. In order to do this, the dataset has been split into three components: small objects with an area less than 576 pixels2 (denoted with the “s” subscript) medium objects with an area between 576 and 2304 pixels2 (denoted with the “m” subscript) and large objects with an area greater than 2304 pixels2 (denoted with the “l” subscript). LARGAL parallels Gal-DINO for small objects and outperforms Gal-DINO for medium and large objects. Performance scores shown in Table 1, for models other than LARGAL, are as reported in RadioGalaxyNET [1].
| Table 1. mAP scores of various models for object detection across varying IoU threshold and object sizes. | ||||||
| Model | mAP0.05:0.95 | mAP0.5 | mAP0.75 | APs | APm | APl |
| Gal-DETR | 22.6% | 38.1% | 26.2% | 16.3% | 24.8% | 19.8% |
| Gal-Deformable DETR | 40.2% | 52.1% | 45.9% | 37.7% | 39.9% | 22.2% |
| Gal-DINO | 53.7% | 60.2% | 58.9% | 41.5% | 56.9% | 35.2% |
| Our Method (LARGAL) | 53.5% | 61.7% | 60% | 40.9% | 71.9% | 63.4% |
Based on these results, LARGAL was able to meet or exceed the performance of many leading models throughout various IoU thresholds. LARGAL achieves this high accuracy while compressing the dataset by 99.1% from 247.7 MB to 2.12 MB, as outlined in Table 2.
| Table 2. Compression Factor (Total Dataset Figures Highlighted) | |||
| Data Split | Original Size | Compressed Size | Compression factor |
| Train | 173.4 MB | 1.5 MB | 99.1% |
| Test | 37.1 MB | 0.31 MB | 99.2% |
| Validation | 37.2 MB | 0.32 MB | 99.2% |
| Total dataset | 247.7 MB | 2.12 MB | 99.1% |
DISCUSSION AND CONCLUSION.
The results demonstrate that combining a YOLOv8s-based [8] detection stage with an attention-augmented VAE [7,9] enables both accurate and highly efficient analysis of radio galaxies. The strong detection performance indicates that the YOLOv8s model effectively distinguishes extended radio sources even when trained on a relatively small dataset, validating the hypothesis that a lightweight architecture can perform at state-of-the-art levels with fine-tuning.
The latent space learned by the VAE shows clear structure and class separation, as visualized in the t-SNE plot. This suggests that the attention layers improved the network’s ability to encode the morphological diversity of radio galaxies, capturing shape and intensity features relevant to classification without supervision. The relatively low reconstruction error confirms that the latent representation preserves key spatial information while achieving 99% compression efficiency.
This result demonstrates that the unsupervised latent representation contains sufficient discriminative information for downstream classification. Compared to traditional convolutional classifiers that must be retrained on each dataset, this modular approach generalizes more flexibly, enabling re-use of the latent vectors across multiple analysis tasks such as anomaly detection or clustering of new radio galaxy morphologies.
However, several limitations remain. The dataset’s moderate size and imbalance between FR classes constrained the model’s ability to generalize to rare morphologies. In addition, reconstruction loss could be further reduced by incorporating perceptual loss functions [23].
ACKNOWLEDGMENTS.
This project was inspired by an article published in Sky & Telescope magazine on Odd Radio Circles (ORCs) [24]. The author of this paper independently conducted the ideation, data analysis, algorithm and experiment design, and execution of the research. The author thanks the Inspirit AI+X program for providing a structured research framework that included guidelines and templates for literature review, documentation, and experiment tracking. Grateful acknowledgement is made to the Inspirit AI mentorship team for their valuable feedback and validation during check-ins. This research utilized the RadioGalaxyNET dataset published by CSIRO Space & Astronomy [1].
SUPPORTING INFORMATION.
Supporting information includes Figures S1-S2 for validation loss curves for the YOLOv8s model (covering classification loss, box loss, distribution focal loss, and mAP values in detection over time) and a validation loss curve for the VAE. It also includes Tables S1 and S2 for a more detailed comparison between several candidate Scikit-Learn classifiers trained on the latent dimensions between the two different size clusters trained on (“small” and “medium” or “large”) that were trained and utilized in LARGAL.
REFERENCES.
- N. Gupta, Z. Hayder, R. P. Norris, M. Huynh, L. Petersson, RadioGalaxyNET: Dataset and novel computer vision algorithms for the detection of extended radio galaxies and infrared hosts. Publ. Astron. Soc. Aust. 41, e001 (2024).
- T. W. Shimwell et al., The LOFAR Two-metre Sky Survey (LoTSS). Astron. Astrophys. 598, A104 (2017).
- A. Raccanelli et al., Cosmological applications of SKA radio galaxy surveys. Mon. Not. R. Astron. Soc. 469, 656–672 (2017).
- I. Labadie-García et al., 3D radio data visualisation in open science platforms for next-generation observatories. arXiv:2503.16237 (2025).
- M. M. Boyce et al., Hydra II: Characterisation of Aegean, Caesar, ProFound, PyBDSF, and Selavy source finders. Publ. Astron. Soc. Aust. 40, e027 (2023).
- C. Wu et al., ClaRAN: A deep-learning classifier for radio morphologies. Mon. Not. R. Astron. Soc. 482, 1211–1223 (2019).
- D. P. Kingma and M. Welling, Auto-Encoding Variational Bayes. arXiv:1312.6114 (2013).
- M. Yaseen, What is YOLOv8: an in-depth exploration of the internal features of the next-generation object detector. arXiv:2408.15857 (2024).
- A. Vaswani et al., Attention Is All You Need. Adv. Neural Inf. Process. Syst. 30 (2017).
- G. Ke et al., LightGBM: A highly efficient gradient boosting decision tree. Adv. Neural Inf. Process. Syst. 30 (2017).
- R. P. Norris et al., The Evolutionary Map of the Universe—EMU Pilot Survey (EMU-PS). Publ. Astron. Soc. Aust. 38, 46 (2021).
- B. L. Fanaroff and J. M. Riley, The morphology of extragalactic radio sources of high and low luminosity. Mon. Not. R. Astron. Soc. 167, 31–36 (1974).
- A. Bochkovskiy, C.-Y. Wang, and H.-Y. Liao, YOLOv4: Optimal Speed and Accuracy of Object Detection. arXiv:2004.10934 (2020).
- Z. Ge et al., OTA: Optimal Transport Assignment for Object Detection. Proc. IEEE/CVPR (2021).
- H. Rezatofighi et al., Generalized Intersection over Union: A Metric and a Loss for Bounding Box Regression. Proc. IEEE/CVPR, 658–666 (2019).
- X. Li et al., Generalized Focal Loss: Learning Object Detector with Gaussian Quality Estimation. Adv. Neural Inf. Process. Syst. 33 (2020).
- Y. LeCun, L. Bottou, Y. Bengio, and P. Haffner, Gradient-based learning applied to document recognition. Proc. IEEE 86, 2278–2324 (1998).
- K. He, X. Zhang, S. Ren, and J. Sun, Deep Residual Learning for Image Recognition. Proc. IEEE/CVPR 2016, 770–778 (2016).
- D. P. Kingma and J. Ba, Adam: A method for stochastic optimization. Int. Conf. Learn. Represent. (2015).
- S. Kullback and R. A. Leibler, Ann. Math. Statist. 22, 79–86 (1951).
- L. van der Maaten and G. Hinton, J. Mach. Learn. Res. 9, 2579–2605 (2008).
- T.-Y. Lin et al., Microsoft COCO: Common objects in context. Proc. Eur. Conf. Comput. Vis., 740–755 (2014).
23. J. Johnson, A. Alahi, and L. Fei-Fei, Perceptual losses for real-time style transfer and super-resolution. Proc. Eur. Conf. Comput. Vis., 694–711 (2016). - M. Young, Odd Radio Circles. Sky & Telescope. 149 (2025), pp. 34-40.
Posted by buchanle on Friday, June 12, 2026 in May 2026.
Tags: AI, Astronomy, Machine learning, Radio Galaxies, Variational Autoencoder
