Simulation-Based Inference for Probabilistic Galaxy Detection and Deblending Ismael Mendoza, Derek Hansen, Runjing Liu, Zhe Zhao, Ziteng Pang, Axel Guinot, Camille Avestruz, Jeffrey Regier, The LSST Dark Energy Science Collaboration Abstract Stage-IV dark energy wide-field surveys, such as the Vera C. Rubin Observatory Legacy Survey of Space and Time (LSST), will observe an unprecedented number density of galaxies. As a result, the majority of imaged galaxies will visually overlap, a phenomenon known as blending. Blending is expected to be a leading source of systematic error in astronomical measurements. To mitigate this systematic, we propose a new probabilistic method for detecting, deblending, and measuring the properties of galaxies, called the Bayesian Light Source Separator (BLISS). Given an astronomical survey image, BLISS uses convolutional neural networks to produce a probabilistic astronomical catalog by approximating the posterior distribution over the number of light sources, their centroids’ locations, and their types (galaxy vs. star). BLISS additionally includes a denoising autoencoder to reconstruct unblended galaxy profiles. As a first step towards demonstrating the feasibility of BLISS for cosmological applications, we apply our method to simulated single-band images whose properties are representative of year-10 LSST coadds. First, we study each BLISS component independently and examine its probabilistic output as a function of SNR and degree of blending. Then, by propagating the probabilistic detections from BLISS to its deblender, we produce per-object flux posteriors. Using these posteriors yields a substantial improvement in aperture flux residuals relative to deterministic detections alone, particularly for highly blended and faint objects. These results highlight the potential of BLISS as a scalable, uncertainty-aware tool for mitigating blending-induced systematics in next-generation cosmological surveys. 1 Introduction The distribution of matter in the universe reflects the underlying cosmology that governs its evolution. We can probe the matter distribution through cosmic shear, in which foreground matter coherently distorts background galaxies due to weak gravitational lensing. Cosmic shear is a powerful probe that can be used to constrain cosmology ( 40 ; 44 ) and has been applied successfully in cosmological surveys, including the Sloan Digital Sky Survey (SDSS; 38 ), Dark Energy Survey (DES; 85 ; 3 ; 94 ), Subaru Hyper Suprime-Cam (HSC; 20 ; 52 ), and Kilo-Degree Survey (KiDS; 5 ). Stage-IV dark energy surveys, such as the Vera C. Rubin Observatory Legacy Survey of Space and Time (LSST; 54 ; 42 ), will observe an unprecedented number density of sources because of their greater depth than earlier wide-field surveys. State-of-the-art surveys such as LSST, through analyses of cosmological probes such as cosmic shear, will enable unprecedented precision and accuracy in estimates of cosmological parameters. However, cosmological constraints remain limited by systematics arising from astrophysical processes and measurement procedures ( 93 ; 60 ) . In cosmological analyses based on galaxy catalogs derived from optical surveys, a leading systematic is blending ( 61 ) . Blending refers to the visual overlap of light sources in astronomical images, which biases and degrades galaxy detection and measurement of their properties. For example, blending can impact the distribution of measured galaxy shapes ( 36 ) and photometry ( 37 ) , the selection function of sources ( 33 ) , and the estimated redshift distribution of galaxies n(z) ( 58 ) . Blending already represents a significant source of systematic error in weak lensing measurements in current ground-based Stage-III surveys ( 58 , e.g.,) , and it is expected to become more dominant in Stage-IV surveys, given their greater depth and smaller statistical uncertainties. Simulations suggest that between 62\% of galaxies in the LSST will be blended to some degree ( 82 ) and between 15\% and 30\% of galaxies will be unrecognized blends, in which two or more light sources are identified as one ( 21 ; 91 ) . Unrecognized blends can significantly affect weak-lensing and cosmological measurements. 25 finds that introducing a distribution of faint galaxies in a simulation of Euclid VIS images creates a multiplicative shear bias of at least a few times 10^{-3} . 67 uses simulations to forecast the effect of unrecognized blends on the derived structured growth parameter S_{8} for LSST. They find that blending introduces a bias greater than the 2\sigma statistical error in estimates of this parameter. Deblending methods, also known as “deblenders”, aim to mitigate this important systematic. “Deblender” can refer to methods that perform one of the following functions on an astronomical image containing blended light sources: 1. Detection : Determine the number of light sources in an astronomical image and their centroids. 2. Deblended Measurement : For each identified source in a blend, estimate the properties of that source while attempting to remove the contributions from nearby sources. 3. Segmentation : For each identified source in a blend, estimate the flux contribution to each pixel in the image. From this information, individual galaxy properties, such as total flux or shape, can also be estimated. One of the most widely used tools for identifying light profiles in an image is SourceExtractor (SExtractor) ( 11 ) , which uses a model-independent image thresholding technique to detect objects ( 57 ) . It can also perform basic segmentation based on a multiple isophotal analysis technique ( 10 , based on) . One major limitation of SExtractor is that each pixel can belong to only one object. The SDSS Photo pipeline ( 56 ) expands upon SourceExtractor, allows for overlap between objects, and estimates the portion of flux in a pixel belonging to each object. Neither SourceExtractor nor the SDSS pipeline can account for multiband information. Deblenders developed during the last decade, such as MuSCADeT ( 43 ) and its successor Scarlet ( 62 ) , build joint nonparametric models of multiband image data. Here, the light sources are not specified using a parametric model, such as a Sérsic fit, but rather by an algorithm that enforces constraints on the light distribution. In particular, Scarlet can impose an arbitrary number of constraints on each source (e.g., symmetry and monotonicity with respect to a source’s centroid), enabling modeling of aspects such as distinct stellar populations in galaxies. More recently, machine-learning-based deblenders have demonstrated high reconstruction accuracy on simulated datasets ( 4 ; 12 ; 81 ; 70 ) . Most deblenders are deterministic and do not account for the inherent uncertainty in the properties of a blended source. To overcome this limitation, we introduce a new probabilistic deblender: the Bayesian Light Source Separator (BLISS). BLISS builds on recent ideas in deep generative modeling and variational inference ( 13 ; 48 ) to quantify blending uncertainty. Propagating this uncertainty to downstream cosmological analyses has the potential to mitigate blending systematics. BLISS uses simulation-based inference (SBI) to approximate a posterior distribution of deblended galaxy properties (see Section 3 ). 1 1 1 As explained in Section 3 , the galaxy deblending component of BLISS is deterministic and uses an autoencoder architecture (Section 3.4 ). Despite this, BLISS can produce posterior distributions of galaxy properties that capture detection uncertainty using the procedure described in Section 4.6 . BLISS extends the approach from StarNet ( 53 ) , which uses SBI to detect and measure stars in crowded starfields, to process images containing both stars and galaxies. Algorithmically, inference involves three encoders and a decoder, as illustrated in Figure 1 . After training these models, inference can be performed rapidly on a GPU, in just seconds for megapixel images. In this work, we train and evaluate BLISS on simulated single-band images that are representative of typical year-10 LSST wide-field coadd images used for cosmological analyses. In Section 2 , we describe the image simulations we used to train and evaluate our model. In Section 3 , we describe each component of the BLISS pipeline and explain how it is trained using SBI. In Section 4 , we evaluate the BLISS framework using our simulations. Each component is first evaluated separately; then, in Section 4.6 , we present results on combining the probabilistic detection and deblending capabilities of BLISS. Finally, we conclude in Section 5 . Figure 1: BLISS inference pipeline outline . Schematic demonstrating the procedure for detecting, deblending, and reconstructing galaxies with BLISS. The procedure begins with an astronomical image of a galaxy blend, which is split into padded tiles (orange border) and passed through the detection encoder. The detection encoder outputs centroid locations for each detected galaxy that can be used to center each padded tile on its corresponding source. The centered padded tiles are then passed to the classification and deblending encoder. Finally, the outputs of each encoder can be used to construct a posterior catalog of the galaxy blend, and a corresponding noiseless reconstruction of the original image. For more details on each of the steps (blue circles) in this outline, see Section 3 . 2 Simulated Images We designed our dataset of simulated images to mimic year-10 LSST single-band coadds. The galaxies and stars in our image simulations are modeled using parametric light profiles. The source density is taken from previous LSST simulation work ( 18 ; 55 ) , and we do not model clustering. All our images are simulated using the GalSim Python package ( 80 ) . 2 2 2 https://github.com/GalSim-developers/GalSim 2.1 Survey Settings Our studies target a single band, the i -band, at the LSST survey pixel scale of 0.2 arcseconds. We use the same parametric point spread function (PSF) model \pi for all our galaxy images, which consists of an atmospheric Kolmogorov component and an optical obscured Airy pattern. We use a FWHM of 0.79 for the atmospheric component, corresponding to the median zenith seeing for this filter ( 41 ) . We add Gaussian noise to our images, assuming the background-dominated limit, so that their SNR resembles that of LSST year-10 images produced by coaddition. The added noise corresponds to a sky level b , which is chosen to be the average expected sky level for LSST year 10. However, the sky level is not added directly to the images; all simulated images are background-subtracted. Our setup closely resembles the simulations used in previous blending work focused on LSST ( 82 ) . The exact survey parameters are sourced from the LSST module of SurveyCodex . 3 3 3 SurveyCodex is a Python library designed to archive the parameters of various surveys with references. Many of its parameters were obtained from the WeakLensingDeblending package ( 83 ) , in some cases with corrections. This library can be found in the following URL: https://github.com/LSSTDESC/surveycodex 2.2 Galaxy Properties The galaxy properties for our image simulations come from a galaxy catalog produced with CatSim , an early version of an end-to-end LSST simulation framework ( 18 ) . The galaxies produced by this framework cover the redshift range of 00.5 , and a star otherwise. 17 17 17 The optimal choice for this probability cut will depend on the specific application. The performance demonstrated in Figure 5 can be tuned by modifying this value as needed. The precision for galaxies (stars) in this context corresponds to the number of correctly classified galaxies (stars) divided by the total number of sources the model classified as galaxies. The recall for galaxies (stars) is then the number of correctly classified galaxies (stars) divided by the total number of galaxies. The F_{1} score is computed as in Equation 17 . These quantities are binned and plotted in Figure 5 based on the true SNR of the sources. We exclude the faintest sources with \text{SNR}<10 from this figure. In the left plot, we can see that all of the galaxy metrics are above 90\% for all relevant SNRs. This is expected given our highly unbalanced dataset. The precision decreases rapidly from around 98\% to 93\% at the SNR roughly corresponding to the vertical strip in Figure 4 . The recall increases as the SNR decreases as the model defaults to the prior and classifies most objects as galaxies. Meanwhile, we see that all the star metrics are monotonic as a function of SNR. This is consistent with Figure 4 as the purple dots consistently move from the top to the bottom as the SNR increases. Our model becomes more uncertain when classifying low SNR sources, as expected. However, for very low SNR, the prior dominates, and a significant number of stars are classified as galaxies with high confidence. One way to make progress could be to incorporate additional prior information into the network that takes into account the model of stars (i.e., the PSF). For example, using the spread model estimator ( 65 , e.g.,) . Figure 4: 2D Histogram of classification probability and SNR. In these plots we show a 2D histogram of the classification probability of a given source being a galaxy and its true SNR, for every galaxy (left) and star (right) in the testing dataset-blend . This probability is the output from the binary encoder conditioned on true counts and centroids of every source. For more details on this figure, see Section 4.3 . Figure 5: Classification performance as a function of SNR for galaxies and stars. This figure shows the precision (green), recall (purple), and F_{1} score (pink) as a function of true SNR obtained by applying the binary encoder to our testing dataset-blend of galaxies and star blends. The SNR bins in each case are chosen so that there are an equal number of light sources on each bin. We condition the binary encoder on the true counts and centroids of every source in this dataset. For more details on this figure, see Section 4.3 . 4.4 Deblending evaluation In this section, we evaluate the deblending encoder independently from the rest of the encoders. We again use dataset-blend and investigate the accuracy of the corresponding galaxy reconstructions. We evaluate fluxes measured with aperture photometry, using an aperture of 5 pixels. The size and ellipticities come from the adaptive moments routine in GalSim . 18 18 18 We use the galsim.hsm module: https://galsim-developers.github.io/GalSim/_build/html/hsm.html The size is defined as T\equiv|\det\bm{M}|^{1/4} , where \bm{M} is the second-moments matrix. The ellipticity uses the distortion ( e ) definition from GalSim . 19 19 19 The definition can be found in: https://galsim-developers.github.io/GalSim/_build/html/shear.html Measurements are made on residual images of each galaxy obtained as follows: 1. For each galaxy in each blend of dataset-blend , we use the deblending encoder to encode this galaxy conditioned on its true centroid. The decoder part of the autoencoder then uses this encoding to create a reconstruction of this galaxy (Section 3.4 ). 2. Each individually reconstructed galaxy from the decoder is centered on a stamp the size of a padded tile. We use GalSim to interpolate 20 20 20 We use the default settings for interpolating on GalSim , which uses a “quintic” 2 D interpolation for images. See this page for details: https://galsim-developers.github.io/GalSim/_build/html/interpolant.html each galaxy to its true location within the padded tile. These padded tiles can be used to create a full reconstruction of the galaxy blend in the original image. 3. For each galaxy in a given blend, we use these interpolated reconstructed images to subtract the contribution from all galaxies in the blend except this one. We also remove the contributions from galaxies in the padding and from all stars in the image using their true models. These are the residual images for every galaxy in the dataset. 4. Finally, we perform aperture photometry flux measurements and moments, as described above, using the true centroid of each galaxy as input. We use these residual images for measurements rather than the reconstructed images directly because they contain unphysical artifacts in the tails of galaxies, which can have a large effect on measured moments. See Section 4.5 for additional discussion. We plot the residuals for fluxes, sizes, and ellipticities obtained using this procedure on every galaxy in our dataset as a function of true SNR and blendedness in Figure 6 (purple curves). The green curves (“No deblending”) show these measurements on the same images using true centroids, but no galaxy reconstructions are subtracted before the measurement. All galaxies and stars in the image padding are still subtracted. Finally, the true values of every galaxy measurement are computed by subtracting every other source in the image using the true individual images. We see from this figure that the scatter in measurements of all quantities is significantly reduced from the deblending. In the case of the flux and size measurements, we see that deblending unbiases the residual across all SNR and blendedness bins. In the case of no deblending, we see that the flux and sizes medians are always positive, and there is no negative scatter. This is expected, as the flux and size measurements of galaxies can only get larger when flux is added to the image. This figure shows that our deblender is capable of reconstructing galaxies accurately, but the biases and errors shown here will be too optimistic as it ignores detection effects. We investigate the impact of detection on flux and moments measurements in the upcoming sections. Figure 6: Residual galaxy measurements as a function of SNR and blendedness. In this plot we show the median residual flux, size, and ellipticity from measurements on galaxy blended images using true galaxy centroids. The flux ( f ) measurement is performed via aperture photometry with an aperture of size 5 pixels. The size ( T=|\det\bm{M}|^{1/4} ) and ellipticities ( e_{1} , e_{2} ) are measured using the GalSim adaptive moments routine. The green color curves corresponds to the measurements with no deblending performed, but using the true centroid of each galaxy. The purple color curves use the reconstructed models from the deblending encoder to remove every other galaxy in the image before performing the measurement. The shaded regions correspond to quantiles of the 1\sigma deviation from a Gaussian distribution (i.e., 0.159 and 0.841 respectively). For more details on this figure, see Section 4.4 . 4.5 Example probabilistic output as a function of distance In this section, we present examples of the probabilistic output of BLISS on a pair of example galaxies at varying separations. We note that the exact output of the BLISS encoders on any given galaxy blend can be highly dependent on the images’ noise realization. Thus, the goal of the results and figures presented in this section is to illustrate aspects of the models’ output rather than to draw general conclusions on their performance. Our setup consists of two elliptical exponential galaxies with SNRs of approximately 120 and 70 with a variable separation between them as shown in Figure 7 . 21 21 21 These relatively high SNR galaxies are chosen to isolate the impact of blending from that of missed detections of low SNR sources. The left galaxy, denoted “Galaxy 1” and labeled with a green 1 in this figure, is fixed at the center of the image. The right galaxy, denoted “Galaxy 2” and labeled with a purple 2 in this figure, shifts horizontally between 0 and 20 pixels from the center of the image in intervals of 0.1 pixels. These results are based on 200 images, each 103\times 103 pixels, with the same Gaussian noise realization added to all images. The specific properties of these galaxies can be found in Table 1 . Property Galaxy 1 Galaxy 2 f 2\times 10^{5} 1\times 10^{5} SNR 120 70 a_{d} 1.5 1.0 q_{d} 0.7 0.7 \beta \pi/4 6\pi/4 Table 1: The true galaxy parameters of the galaxies in the pair blend from Figure 7 . Both galaxy light profiles are exponential. The symbols are as follows: f is the flux, a_{d} is the semi-major axis of the disk, q_{d} is the ratio of the semi-major and semi-minor axes, and \beta is the inclination angle. In Figure 7 , we show the image of the galaxy pair at three different separations ( 5 , 10 , and 15 pixels) in the first column. The second column contains the noiseless reconstruction from the BLISS deblending encoder (using the predicted centroid as input), and the third column shows the residual image. We also overplot the true centroids and the predictions from SEP and the BLISS detection encoder (using the centroid posterior mean). The figure shows that the detection encoder correctly identifies the total number of galaxies, even at small pixel separations when they visually look like a single blob. As the separation between the objects increases, we see that detection accuracy also increases, as expected. The SEP settings used in this figure are the same as those in Section 4.2 and are listed in Table 2 . Figure 7: Image residuals and detections on galaxy pairs at three separations. In this plot we show the pair of example galaxies used throughout Section 4.5 at three different separations: 5 , 10 , and 15 pixels. The galaxy on the left (labeled with “ 1 ”, in green) is fixed at the center of the image. The galaxy on the right (labeled with “ 2 ”, in purple) is shifted horizontally at different separations from Galaxy 1. In the first column, we see the true noisy image at each separation with the true centroid of each galaxy in red and the predicted centroid from BLISS in blue. The SEP prediction for centroids is also shown with an orange circle as a reference. The second column shows the noiseless reconstruction from BLISS with the same centroids plotted as in the first column. The last column shows the residual image in units of the noise standard deviation \sqrt{b} . Next, in terms of reconstructions and residuals, the third column shows image residuals (in units of the noise standard deviation) improving as the separations increase. At the lowest separations, BLISS misestimates the flux from both galaxies as well as the total flux of the system. This may be because the deblending encoder’s reconstructions for each tile are computed independently, without any constraint to preserve the total flux of the blend; when galaxies are severely blended, the deblender might include or remove too much flux from each independent prediction. Finally, we note that all noiseless reconstructions in the second column have noticeable non-physical features, especially in the tails of galaxies. The deblending encoder does not impose any particular galaxy model or physical constraints on its reconstructions, which could explain these unphysical features. This effect does not impact our conclusions significantly since we perform measurements only on images with noise added (see Section 4.4 ), which buries these features. Both of these observations suggest avenues for future work in the deblender (Section 5 ). Next in Figure 8 , we show the detection probability as a function of the separation between two galaxies. The detection probability for each galaxy is obtained by taking the output of the detection encoder for the tile containing the true centroid of that galaxy. We see that the detection probability for Galaxy 1 remains relatively stable and does not drop below approximately 0.85 . However, the detection probability of Galaxy 2 varies in more interesting ways. There are peaks and valleys roughly corresponding with the center and boundaries (dashed lines) of tiles, respectively. The second galaxy’s detection probability can drop below 0.5 depending on how close its centroid is to the tile boundary, which is an undesirable artifact of our tiling approach. However, the overall probability curve increases as the two sources become more separated, as expected. This effect seems to artificially reduce the detection probability regardless of the brightness of the source, and could cause detectable sources to go undetected by our algorithm. We discuss possible mitigation strategies in Section 5 . Figure 8: Detection probability of each galaxy as a function of separation. This plot shows the detection probability that BLISS assigns to the tile containing Galaxy 1 (green) and 2 (purple) as a function of the separation between them (as described in Figure 7 ). The dashed vertical lines correspond to the separations at which Galaxy 2’s centroid lands in a tile boundary. See Section 4.5 for more details on this figure. In Appendix D , we also explore the quality of centroid predictions from the detection encoder on these images. In the next section, we jointly evaluate the detection and deblending encoders in the context of flux measurements on a large sample of blended galaxies. 4.6 Joint Detection and Deblending Uncertainty One advantage of BLISS over traditional approaches is the ability to combine probabilistic detection with source deblending. BLISS could be particularly powerful in the context of unrecognized blends, where the total number of sources is ambiguous. In this section, we quantify the improvements in photometric measurements achieved by this approach using a large dataset of simulated blended galaxies. We created a new dataset, dataset-central (Section 2 ), comprising 10 k images for this experiment. This dataset is equivalent to the one used in Sections 4.2 through 4.4 , except that no stars are included in the simulation, and, in every image, the central 5\times 5 tile always contains exactly a single galaxy with an i -band magnitude brighter than 25.3 . The image size in this dataset is slightly smaller ( 73\times 73 pixels) than in dataset-blend . We only evaluate the flux recovery of this central galaxy. We excluded stars from this simulation to simplify the setup, but the binary encoder could have also been sampled to identify stars. We also force the central galaxy to be exactly in the middle of the central tile, which mitigates the effect of multiple sources being present in the same tile (Section 3.1 ), and reduces the boundary effect discussed in Section 4.5 . These simulation choices were made to explore potential improvements to flux measurement via the BLISS probabilistic output while mitigating issues in our current model that will be addressed in future work. Note, however, that we do not completely eliminate these artifacts as other galaxies in the image could land in the same tile or have their centroid close to a tile boundary. Finally, we set a magnitude limit on the central galaxy to ensure its detectability and reduce computational time. We compare aperture photometry measurements of the central galaxy in each image using the detection and deblending output from BLISS in three different ways. The first way, denoted “MAP”, uses the most likely BLISS detections to reconstruct the light profile of sources and for flux measurement. These detections correspond to those with a tile detection probability larger than 0.5 , and whose location is the mean of the predicted centroid posterior distribution. The second approach (“SEP”) uses SEP (using the same settings as in Section 4.2 ) for detections instead of BLISS, but deblending is still performed using the BLISS deblending encoder. For the third way, denoted “Samples”, we draw 100 samples from the BLISS predicted distributions for counts and centroids to obtain a flux distribution by repeating the deblending procedure 100 times per image. This flux posterior distribution approximately captures the corresponding detection uncertainty in flux measurements. We use the mean of this flux posterior distribution as our new point estimator for comparison with the MAP and SEP flux predictions. For each image, we use the same deblending procedure for aperture flux measurement as in Section 4.4 , where detected galaxies besides the central one are removed using noiseless reconstructions from the deblending encoder. The key difference with the previous set of deblending results is that we use the predicted galaxy centroids rather than true centroids for both removing sources and to center the aperture for flux measurement. In all cases, flux is only measured when a predicted detection is less than 2 pixels away from the central galaxy. We exclude from the results below the small number (approximately 0.2\% ) of images where at least one of the approaches does not detect and match the central galaxy. 22 22 22 In the case of the “Samples” approach, this means that none of the 100 detection samples matched the central galaxy. Our results are summarized as a function of the blendedness of the central galaxy in Figure 9 . We choose a total of 20 blendedness bins, where 18 of them are in the range [3.80\times 10^{-4},3.76\times 10^{-1}] and are set to ensure an equal number of objects in each. Objects with values lower than 3.76\times 10^{-4} or higher than 3.56\times 10^{-1} are placed in the first and last bin, respectively. The upper bound was chosen to ensure enough statistics on high blendedness examples. Each bin contains at least 400 corresponding images used to obtain residuals. The curves represent the (fractional) median residual in each blendedness bin from each method, where the “Samples” approach uses the average of the flux measured across the samples to compute its residual. The shaded regions correspond to the 1\sigma bootstrap errors on the median obtained by resampling the residuals on each bin. In this figure, we see that the sampling approach to measure photometry significantly outperforms the point estimations from both “MAP” and “SEP” approaches across blendedness bins. The gap in the median residuals increases with blendedness and is particularly large for the last bin, where the residual jumps from approximately 16\% to about 160\% for the MAP and about 400\% for SEP. In Figure 10 , we show the flux residual results as a function of the true SNR of the central source of each image. As before, the curves represent the median fractional flux residual and the shading their bootstrap error for the same three methods. The SNR bins are chosen to ensure an equal number of images in each, resulting in more than 600 images per bin. This figure shows that the sampling approach outperforms the other two methods across the entire SNR range. The residual of all methods increases as the SNR decreases, and the two deterministic methods (SEP and MAP) perform similarly to each other throughout. The difference in the magnitude of median residuals between Figure 9 and 10 comes from the fact that the median blendedness across all SNR bins is below 0.085 . We hypothesize that these improvements are driven by the large number of objects undetected by the “MAP” or “SEP” approach when the blendedness level is high or the SNR is low. Undetected objects will not be removed from the image through deblending, and would thus lead to flux overestimation. On the other hand, the sampling approach has the potential to detect more sources as no hard cutoff is used for detection probability. Samples corresponding to sources in the image that are difficult to detect could, on average, reduce the flux residual. It is also possible that the sampling approach is less sensitive to the tile boundary artifact, as the probability of a source close to a boundary appears to be shared between the corresponding tiles ( 53 ) . However, the comparison using SEP detections indicates that this cannot be the sole source of improvement, as the SEP algorithm does not employ a tiling procedure. Overall, this result demonstrates the potential of our method to mitigate photometric biases in blended systems. Figure 9: Flux measurement in BLISS using probabilistic detections as a function of blendedness. In this figure, we compare the (fractional) absolute median flux residual for three different approaches to flux measurement using BLISS in the dataset dataset-central . In all three cases, the flux is measured on the central galaxy of each image using aperture photometry after deblending is performed using the same BLISS deblending encoder, but different detections are used. Detections are matched within 2 pixels of the true galaxy centroid at the center of the image. If no matches with the central galaxy, no flux measurement is performed for that set of detections. In the first case (MAP), the most likely detections (above 50\% probability) from the BLISS detection encoder are used for deblending and aperture photometry. In the second case (SEP), detections from SEP are used instead. Finally, in “Samples”, we draw 100 detection samples from the BLISS detection encoder and use these as input to the deblending encoder. We take the mean over these measured fluxes as the flux estimator for each image. See Section 4.6 for more discussion of this figure. Figure 10: Flux measurement in BLISS using probabilistic detections as a function of SNR. This figure presents the same results as Figure 3 , but residuals are split into SNR bins based on the true SNR of the central source of each image. The bins are chosen so that each of them contains the same number of galaxies. The median blendedness value in each bin is <0.08 , which explains the significantly smaller residual values compared to Figure 3 . See Section 4.6 for additional discussion. 5 Discussion and Summary In this work, we introduce the Bayesian Light Source Separator (BLISS), a novel simulation-based inference method for detection, deblending, and measurement of astronomical light sources. We have presented the components of BLISS and illustrated its performance on LSST-like simulated images of galaxy blends. Our key result is that combining probabilistic detection with AE deblending yields substantial improvements in aperture flux measurements for high-blendness systems (Section 4.6 ). Our other results are as follows: • To enable inference of light source parameters for arbitrarily large images, we split our images into overlapping padded tiles. Our tiling scheme forces the neural network to learn only the details local to each light source. For more details, see Section 3.1 . • We thoroughly evaluate the point estimates from each of our neural networks. For our particular SEP settings (Appendix C ), we find that the detection encoder recovers a larger fraction of very faint and high blendedness sources (Section 4.2 ). Our classification encoder achieves an F_{1} score in excess of 70\% when classifying stars with SNR larger than 12 , and in excess of 95\% for galaxies with SNR larger than 10 (Section 4.3 ). Finally, our deblender significantly improves the recovered flux and morphology of blended galaxies when the true centroid is known (Section 4.4 ). • We carefully examine the probabilistic output of our method in the context of a simple simulation of a pair of galaxies. BLISS is capable of detecting sources even at very low source separations. Detection probabilities overall increase as sources become more separated, as expected. However, detection probability can be degraded when sources get too close to tile boundaries. Finally, we find that individual galaxy reconstructions improve as the separation increases. See Section 4.5 . • The inference step of the BLISS pipeline is fast. Once trained using a single GPU, BLISS can perform inference on megapixel images containing galaxy and star blends in seconds. We use an autoencoder (AE) trained on parametric simulated galaxies as our galaxy model. This model enables the training of the deblending encoder and the reconstruction of galaxies (Section 3.4 ). This approach follows a growing body of work on using deep neural networks for galaxy image modeling. Recent work on using deep learning for galaxy modeling commonly uses generative adversarial networks (GANs) and variational autoencoders (VAEs), and, more recently, score-based models ( 73 ; 23 ; 28 ; 76 ; 51 ; 4 ; 35 ; 89 ; 12 ; 81 ) . We used an AE in BLISS since autoencoders are generally more stable in training than GANs ( 48 ) and have been shown to perform galaxy image reconstruction accurately ( 51 ; 4 ) . 51 used VAEs to build deep generative models that can recreate realistic galaxy images using data from the HST COSMOS catalog ( 59 ) . VAEs have also been used successfully for deblending ( 4 ) . These types of methods have the potential to mitigate the model bias often incurred by more standard parametric galaxy models, as demonstrated by 77 . Currently, we do not fully leverage the modeling capabilities of deep generative models in BLISS, as our AE is deterministic and is trained exclusively on parametric galaxies. However, we plan to incorporate realistic galaxy profiles and use a VAE to capture the full uncertainty of galaxy properties in future work. BLISS includes a detection encoder (Section 3.3 ) that is capable of outputting a posterior distribution for the centroids of stars and galaxies in astronomical images. Traditional detection approaches are based on peak finding or thresholding, such as the popular algorithm SExtractor ( 11 ; 9 ) . However, classical approaches to cataloging cannot characterize uncertainty in the number of sources found and are known to result in a significant number of ambiguously blended sources ( 21 ) . Probabilistic approaches for detection relying on MCMC have been proposed for deblending crowded starfields, such as in 27 , and predicting point estimates and uncertainties of star fluxes and centroids. However, these approaches are computationally expensive because they rely on MCMC. In this work, we evaluated BLISS point (deterministic) predictions of source detections and found comparable performance with the chosen SourceExtractor configuration (Section 4.2 ). However, in this study, we discarded the probabilistic information from the BLISS detection encoder by using thresholds. In a later section, we show an example of how this additional information can be used (Section 4.6 ). BLISS also includes a classification encoder (Section 3.3 ) that outputs a probability that a detected source is either a galaxy or a star. Approaches to star-galaxy separation have thus far often involved neural networks, such as the one used in SExtractor ( 11 ) . This neural network differs from ours in that it does not use the images directly but rather 10 carefully chosen numerical features and a feedforward architecture. More recent approaches to star-galaxy classification include convolutional neural networks such as BLISS and avoid the need to extract features carefully ( 45 ; 29 ) . Other approaches have used low-dimensional embeddings of optical images and Gaussian processes for classification ( 31 ; 66 ) . The CNN architecture used in BLISS could enable the use of information from multiple bands or exposures for a given light source. These approaches will become more important as new surveys observe fainter objects, where the increase in blending of smaller galaxies makes classification difficult ( 88 ) . BLISS performs deblending using its deterministic deblending encoder (Section 3.4 ), which takes as input samples from the detection and classification encoders. The deblending encoder consists of a neural network that learns to target the galaxy at the center of an image, while removing the flux of surrounding galaxies. This approach to deblending is similar to DebVAdEr ( 4 ) and MADNESS ( 12 ) . Other deblenders, such as Scarlet ( 62 ) , use constrained optimization to deblend light sources without deep learning. In future work, we also plan to conduct an extensive comparison of BLISS with these and other deblenders using the BlendingToolKit package ( 63 ) . As explored in Section 4.5 , our tiling procedure (Section 3.1 ) has potential drawbacks. We found that detection probability correlates strongly with distance from the source to the tile boundary. This makes the detection probability drop below 0.5 even for detectable and isolated sources. This effect could be impacting the results of Section 4.2 , degrading detections and reducing the BLISS recall across all SNR and blendedness bins. In a precursor paper to BLISS, which uses a similar detection encoder architecture ( 53 ) , the authors find that the probability is “shared” between tiles when the source becomes too close to the tile boundary. This suggests that drawing samples from the detection encoder might be more robust to the tile boundary effect, as all tiles with significant assigned probabilities can contribute. Other ways to mitigate this artifact include allowing neighboring tiles to overlap, or modifying the variational distribution (Equation 1 ) to encode dependencies between neighboring tiles ( 75 ) . Future work will involve a more in-depth analysis of tile boundary effects and exploring these and other mitigation strategies. In Section 4.6 , we quantified the effect on photometric measurements of combining the probabilistic detection and deblending capabilities of BLISS. We generate aperture flux posterior distributions of individual deblended galaxies by repeatedly sampling galaxy centroids from the detection encoder and using these samples as input to the deterministic deblender encoder. These flux posterior distributions primarily capture the contribution from the detection uncertainty of the target and nearby sources. This procedure could be applied to produce posteriors for any measurable galaxy property, although we only explored improvements to aperture fluxes in this work. Future work will replace the deblender encoder with a VAE to better approximate the full uncertainty present in blended galaxy systems. We find that using these deblended flux posteriors can drastically reduce the median flux residual for highly blended galaxies in our slightly simplified dataset-central simulations (Figure 9 ). While out of scope for this paper due to our use of single-band image simulations, future work using multi-band images could investigate downstream applications to improve color and redshift estimation by deriving their corresponding posteriors. Previous work has already shown that a machine learning deblender can be used to improve photometric redshift estimation in simulations ( 64 ) . Future work on BLISS will focus on preparing this algorithm for use with real astronomical data and supporting cosmological analyses from stage-IV optical surveys such as LSST. Specifically, we plan to: (1) Extend BLISS so that processing multi-band data becomes possible. This might enable propagating our predicted flux posteriors (Section 4.6 ) to photo-z estimation. (2) Accommodate data with spatially variable PSFs ( 70 ) and background, as well as other effects present in real survey images. (3) Relatedly, training and testing our models using more realistic LSST-like image simulations such as the LSST DESC DC2 simulations ( 55 ; 24 ) and the OpenUniverse 2024 simulations ( 68 ) . (4) Training and testing our encoders using images of galaxies with realistic morphology. For instance, we could consider combining deep fields and space observations from other cosmological surveys to build a more realistic model of galaxy morphology. In this work, we have used only parametric galaxies, which may introduce model biases in real survey data. (5) Test and validate our method using a specific set of science-driven metrics. For example, use BLISS detection samples to explore whether shear detection biases could be mitigated. (6) Address potential biases related to the tiling procedure and corresponding independence assumptions in BLISS (Section 4.5 ). This includes the fact that we allow at most one source centroid per tile. (7) Understand how robust BLISS is to significant and relevant differences between the training and test data. (8) Finally, develop a general methodology that can be used to propagate BLISS predicted uncertainties to downstream cosmological analyses. Author Contributions IM wrote the manuscript text, developed and maintained the BLISS software version used for this paper, created and co-designed all results figures and the outline figure, implemented star/galaxy classification and galaxy deblending functionality in the codebase, and created datasets for training and evaluation using GalSim . DH developed and helped maintain the codebase throughout the analysis and provided feedback on the results. RL refactored parts of the codebase, provided guidance on extending StarNet, and offered feedback on the results. ZP refactored parts of the codebase to ease development and fine-tuned the detection network to improve performance. ZZ developed the initial unit tests for the codebase and helped develop a framework for training machine-learning models using PyTorch Lightning. AG provided guidance on the simulations used, co-designed results figures, and reviewed the manuscript. CA edited the paper, provided significant comments and suggestions during writing, brainstormed paper organization, and suggested ways to present results. JR conceived of the project, guided code development, refactored the codebase, edited the manuscript, and provided feedback on it. All coauthors regularly discussed BLISS software development and performance evaluation. Data Availability The code to reproduce all experiments is available in a public GitHub repository: https://github.com/prob-ml/bliss/tree/desc-oja . The software is also available in Zenodo at https://zenodo.org/records/18164685 . Appendix A Appendix A: Bayesian framework for probabilistic cataloging We describe the Bayesian framework that underpins the problem of probabilistic inference of catalogs from astronomical images. Given an image containing blended galaxies and stars, \mathcal{X} , we want to obtain a probability distribution over catalog \mathcal{Z} . A catalog corresponds to the set of all galaxy and star parameters that characterize the mean intensity of a given image. Our goal is then to obtain the posterior distribution, P(\mathcal{Z}|\mathcal{X}) , defined as, P(\mathcal{Z}|\mathcal{X})=\frac{P(\mathcal{Z})P(\mathcal{X}|\mathcal{Z})}{P(\mathcal{X})}. (18) Here, P(\mathcal{Z}) is the prior distribution, P(\mathcal{X}|\mathcal{Z}) is the conditional likelihood, and P(\mathcal{X}) is the evidence or marginal likelihood. The prior P(\mathcal{Z}) corresponds to an expected distribution of light source parameters before taking any particular astronomical image into account. This distribution could come from astronomical catalogs of precursor surveys or from cosmological knowledge. In our case, the prior over full images P(\mathcal{Z}) is defined implicitly by our choice of galaxy and star catalogs (see Section 2 ). The conditional likelihood P(\mathcal{X}|\mathcal{Z}) corresponds to the probability that we have observed a specific astronomical image, \mathcal{X} , given a corresponding catalog \mathcal{Z} . The catalog \mathcal{Z} describes the source centroid locations and the mean intensity of stars and galaxies (from the flux and shape entries in the catalog). The combination of the catalog, the PSF, and the background determines the mean intensity of every pixel in the astronomical image. Using the normal approximation to the independent Poisson noise at every pixel of the image, the conditional likelihood reduces to a normal distribution that factorizes over each pixel, where the mean and variance are the mean intensity \tilde{\mathcal{X}} determined by the catalog: P(\mathcal{X}|\mathcal{Z})=\prod_{p\in\rm pixels}\mathcal{N}(\mathcal{X}_{p};\tilde{\mathcal{X}}_{p},\tilde{\mathcal{X}}_{p}). (19) Though the conditional likelihood is known and tractable to evaluate in our context, we do not use it in our methodology for the detection and classification encoder. We use only the negative log conditional likelihood as the loss function for the galaxy autoencoder and deblending encoder (see Section 3.4 ). Traditionally, Bayesian inference for astronomical catalogs might use the conditional likelihood paired with Markov chain Monte Carlo (MCMC) sampling ( 84 ; 72 ; 27 ) . Given the light source counts in an image and a parametric source model, one can run an MCMC chain over all sources and source parameters targeting the conditional likelihood P(\mathcal{X}|\mathcal{Z}) to output a joint posterior distribution of the sources’ parameters. Although this fully Bayesian approach promises exact posterior samples upon convergence, MCMC sampling is less computationally tractable over larger parameter spaces and data volumes compared with a variational inference approach ( 13 ) . Finally, the evidence, also known as the marginal likelihood and P(\mathcal{X}) , is the marginal probability distribution of the pixel values in a given image. P(\mathcal{X}) is intractable for our case. We can rewrite this term as P(\mathcal{X})=\int P(\mathcal{Z})P(\mathcal{X}|\mathcal{Z})d\mathcal{Z}, (20) where the integral is over all possible catalogs. Intuitively, the marginal likelihood is the probability of a given astronomical image without reference to a specific corresponding catalog. Hypothetically, it would be the probability of obtaining a given set of pixels (an image) when pointing the telescope at infinite random realizations of the sky. The pixels in \mathcal{X} are correlated due to the effect of the PSF and the existence of extended sources, so the probability P(\mathcal{X}) does not factorize. This distribution reflects two sources of uncertainty: (1) the uncertainty over catalogs from the prior and (2) the noise in the image. This integral is intractable because the number of catalogs we need to consider to perform this integral is arbitrarily large for a given image \mathcal{X} . For example, a given set of pixel values in an image might be degenerate between any number of faint sources buried under noise, or any number of sources that sufficiently overlap for that resolution. Appendix B Appendix B: Variational loss function derivation In this appendix, we derive the loss function used in BLISS corresponding to Equation 10 in Section 3.2 . We start with the FAVI loss function (Equation 8 ): L(\bm{\phi})=\mathbb{E}_{\mathcal{X}\sim P(\mathcal{X})}D_{\rm KL}(P(\mathcal{Z}|\mathcal{X})\,\|\,Q_{\bm{\phi}}(\mathcal{Z})), (21) where P(\mathcal{Z}|\mathcal{X}) is the true posterior, Q_{\bm{\phi}} for Q_{\bm{\phi}}(\mathcal{Z}) is the variational distribution, \mathcal{Z} are the light source parameters (Equation 7 ), \mathcal{X} is an astronomical image, and D_{\rm KL}(\cdot\,\|\,\cdot) is the KL divergence. The goal is to find the neural network weights \bm{\phi}^{\star} that minimize this loss. We can formulate this mathematically as follows: \bm{\phi}^{\star}=\argmin_{\bm{\phi}}\mathbb{E}_{\mathcal{X}\sim P(\mathcal{X})}D_{\rm KL}(P\,\|\,Q_{\bm{\phi}}), (22) where P and Q_{\bm{\phi}} are shorthand for P(\mathcal{Z},\mathcal{X}) and Q_{\bm{\phi}}(\mathcal{Z}) , respectively. We can now expand the KL divergence using the definition to obtain: \displaystyle\bm{\phi}^{\star} \displaystyle=\argmin_{\bm{\phi}}\mathbb{E}_{\mathcal{X}\sim P(\mathcal{X})}\int P\log\left(\frac{P}{Q_{\bm{\phi}}}\right) (23) \displaystyle=\argmin_{\bm{\phi}}\mathbb{E}_{\mathcal{X}\sim P(\mathcal{X})}\int P\log P-\mathbb{E}_{\mathcal{X}\sim P(\mathcal{X})}\int P\log Q_{\bm{\phi}}. (24) The first term can be ignored since it does not depend on \bm{\phi} and thus will not affect optimization. This gives: \displaystyle\bm{\phi}^{\star} \displaystyle=\argmin_{\bm{\phi}}-\mathbb{E}_{\mathcal{X}\sim P(\mathcal{X})}\int P(\mathcal{Z}|\mathcal{X})\log Q_{\bm{\phi}} (25) \displaystyle=\argmax_{\bm{\phi}}\mathbb{E}_{\mathcal{X}\sim P(\mathcal{X})}\mathbb{E}_{\mathcal{Z}\sim P(\mathcal{Z}|\mathcal{X})}\log Q_{\bm{\phi}}(\mathcal{Z}). (26) We can combine the two expectations to obtain: \displaystyle\bm{\phi}^{\star} \displaystyle=\argmax_{\bm{\phi}}\mathbb{E}_{\mathcal{X,Z}\sim P(\mathcal{X,Z})}\log Q_{\bm{\phi}}(\mathcal{Z}) (27) \displaystyle=\argmax_{\bm{\phi}}\mathbb{E}_{\mathcal{X,Z}\sim P(\mathcal{X,Z})}\sum_{t=1}^{T}\log Q_{\bm{\phi}}(\mathcal{Z}_{t}). (28) Next, using the rules of conditional probability for the variational distribution with each light source parameter, we get: Q_{\bm{\phi}}(\mathcal{Z}_{t})=Q_{\bm{\phi}}(n_{t})Q_{\bm{\phi}}(\bm{\ell}_{t}|n_{t})Q_{\bm{\phi}}(b_{t}|n_{t},\bm{\ell}_{t}). (29) Finally, plugging this into Equation 28 we recover the loss used in BLISS for the detection and classification encoders (Section 3.3 ) and obtain: \displaystyle L^{\prime}(\bm{\phi}) \displaystyle=\mathbb{E}_{\mathcal{X,Z}\sim P(\mathcal{X,Z})}\sum_{t=1}^{T}\log Q_{\bm{\phi}}(n_{t})+\log Q_{\bm{\phi}}(\bm{\ell}_{t}|n_{t}) \displaystyle+\log Q_{\bm{\phi}}(f_{t}|n_{t},\bm{\ell}_{t},b_{t})+\log Q_{\bm{\phi}}(b_{t}|n_{t},\bm{\ell}_{t}), (30) which corresponds to Equation 10 . Appendix C Appendix C: Settings for SourceExtractor in Python We use SExtractor in Python (SEP) v 1.4.1 ( 9 ) . The convolution kernel (FILTER) corresponds to a Gaussian profile in a 3\times 3 array of pixel values with a width of 2.0 pixels ( 0.4 arcsec). The specific arguments used for detection through the sep.extract function are listed in Table C . We aim to match the SExtractor ( 11 ) settings used in 82 as much as possible. Argument Value thresh 1.5 min_area 5 deblend_nthresh 32 deblend_cont 0.005 Table 2: Arguments passed into the sep.extract function, which roughly corresponds to classical SExtractor settings. See Appendix C for details. Appendix D Appendix D: Centroid prediction for pair blend In this appendix, we show the quality of the centroid predictions of the detection encoder in the pair blend example of Section 4.5 . In Figure 11 , top row, we see the residual between the true centroid and mean of the centroid posterior that BLISS predicts for the tile containing “Galaxy 1” (green) and “Galaxy 2” (purple). In the bottom row, we see the uncertainty in the centroid predicted by BLISS for the tile containing each source. Both the residuals and uncertainties are significantly noisy, but all seem to decrease with increased separation between the sources. We also see spikes in all the curves at separations corresponding to tile boundaries, which were also observed for the detection probabilities in Figure 8 . Figure 11: Detection residuals and errors as a function of separation between galaxies. In this plot, we show the centroid location residual, and BLISS predicted uncertainties in the x and y directions for the pair of galaxies in Section 4.5 . Specifically, the top row shows the difference between the mean centroid predicted by the detection encoder for the tile containing each galaxy and the true centroid as a function of separation. The bottom row shows the predicted uncertainty on the centroid as a function of separation.