File size: 4,189 Bytes
f2ac517
177588a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f2ac517
177588a
 
 
 
 
 
 
 
 
 
 
 
 
248fee3
 
 
 
177588a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
---

language: en
license: mit
tags:
  - gan
  - cgan
  - keras
  - tensorflow
  - computer-vision
  - image-processing
  - astronomy
  - galaxy-morphology
  - image-segmentation
pipeline_tag: image-to-image
library_name: keras
datasets:
  - desi-legacy-survey
---


# Galaxy Image Simplification using Generative AI

This repository hosts the pretrained models for **Galaxy Image Simplification using Generative AI**, a pipeline that converts complex galaxy images into simplified, skeletonized representations suitable for quantitative morphology analysis.

The pipeline combines:

- A **ResNet-based classifier** to select **spiral galaxies**
- A **conditional GAN (cGAN)** to produce initial arm masks
- A **post-processing cGAN** to smooth and connect broken arm segments

These models were trained on images from the **DESI Legacy Survey** with manually annotated spiral arms.

<p align="center">
  <img src="graphical_abstract.jpg" width="500">
</p>

---

## Model Sources

- **Code & full project:**  
  https://github.com/SaiTeja-Erukude/galaxy-image-simplification-using-genai

---

## Files in this repository

| File name                        | Type          | Description                                                       |
|----------------------------------|---------------|-------------------------------------------------------------------|
| `models/galaxy_classifier_resnet50.h5`  | Keras model   | ResNet-based binary classifier: spiral vs. non-spiral galaxy      |
| `models/galaxy_simplifier_cgan.h5`      | Keras model   | Conditional GAN: galaxy RGB image ➜ initial arm-highlighted image |
| `models/postprocess_cgan.h5`            | Keras model   | Conditional GAN: initial mask ➜ refined, smooth/connected mask    |
| `predict.py`                            | Python script | Full inference pipeline (classification ➜ simplifier cGAN ➜ post-cGAN) |
| `graphical_abstract.jpg`                | Image         | Graphical abstract / high-level overview of the Galaxy Simplifier pipeline |
| `requirements.txt`                      | Text file     | Python dependencies needed for running inference            |
| `README.md`	                          | Markdown	  | Model card and usage instructions (this file) |

---

## Intended Use

### What this model does

Given an optical galaxy image (RGB, 256×256):

1. **ResNet classifier (`galaxy_classifier_resnet50.h5`)**
   - Predicts whether the galaxy is a **spiral**.
   - Outputs a 2-class softmax:  
     - class `0` – non-spiral / other  
     - class `1` – spiral  
   - Typical usage: apply a confidence threshold on the spiral class (e.g. `p_spiral > 0.65`) before running the GAN pipeline.

2. **Skeletonization cGAN (`galaxy_simplifier_cgan.h5`)**
   - Input: original RGB galaxy image (normalized to `[-1, 1]`).
   - Output: image where **white lines** track the spiral arms (initial skeleton-like mask).

3. **Post-processing cGAN (`postprocess_cgan.h5`)**

   - Input: initial cGAN output.

   - Output: refined mask with **smoother and better-connected arm structures**.

   - This can be further processed with classical image processing (thresholding, skeletonization, dilation) to produce final binary masks.



### Primary use cases



- Large-scale **spiral galaxy selection** and morphology analysis

- Measuring arm geometry, pitch angles, and other structural properties

- Building catalogs of simplified galaxy images from wide-field surveys



### Not intended for



- General-purpose image generation outside the astronomy domain

- High-fidelity photometric modeling or pixel-perfect reconstruction of galaxies



---



## How to use



You can either:



- use your **own inference script**, or  

- use the provided minimalistic `inference.py`.



---



## Citation

If you use this code, models, or catalog in your research, please cite:



```bibtex

@article{erukude2025galaxy,

  title={Galaxy image simplification using Generative AI},

  author={Erukude, Sai Teja and Shamir, Lior},

  journal={Astronomy and Computing},

  pages={100990},

  year={2025},

  publisher={Elsevier}

}

```