|
--- |
|
license: apache-2.0 |
|
language: |
|
- en |
|
metrics: |
|
- accuracy |
|
library_name: keras |
|
pipeline_tag: image-classification |
|
tags: |
|
- astronomy |
|
widget: |
|
- src: https://huggingface.co/IT-Guy007/AstroVisionV1/blob/main/images/spiral-example.png |
|
output: |
|
text: one_one |
|
--- |
|
# Model Card for Model ID |
|
|
|
This model classifies RGB images to the 2 classes, Spheroid or Spiral. |
|
|
|
|
|
## Model Details |
|
|
|
### Model Description |
|
|
|
- **Developed by:** Jeroen den Otter, Michael Rutkowski |
|
- **Funded by:** NASA |
|
- **Model type:** Keras Sequential |
|
- **License:** Apache2 |
|
|
|
### Model Sources |
|
|
|
<!-- Provide the basic links for the model. --> |
|
|
|
- **Repository:** https://www.kaggle.com/c/galaxy-zoo-the-galaxy-challenge/overview |
|
|
|
## Uses |
|
|
|
The model can be used for identifying different galaxies from cutout images. It does not provide bounding boxes, so multiple galaxies in 1 image is not desired. |
|
|
|
|
|
|
|
## How to Get Started with the Model |
|
|
|
Use the code below to get started with the model. |
|
|
|
```python |
|
model = tf.keras.models.load_model('model.keras') |
|
prediction = model.predict(image) |
|
print(prediction) |
|
``` |
|
|
|
## Training Details |
|
|
|
### Training Data |
|
|
|
From the kaggle zoo challenge the classes one_one(Spheroid) 80%> and one_two(Spiral) 90%> are used. |
|
|
|
Furthermore are the image segmented for noice removal |
|
|
|
### Training Procedure |
|
|
|
```python |
|
train_ds, val_ds = image_dataset_from_directory( |
|
dataset_directory, |
|
validation_split=0.2, |
|
subset="both", |
|
seed=123, |
|
image_size=(200, 200), |
|
batch_size=32, |
|
color_mode='grayscale' |
|
) |
|
|
|
data_augmentation = tf.keras.Sequential([ |
|
tf.keras.layers.RandomFlip('horizontal'), |
|
tf.keras.layers.RandomRotation(0.2), |
|
tf.keras.layers.RandomZoom(0.2), |
|
tf.keras.layers.RandomContrast(0.2), |
|
tf.keras.layers.RandomBrightness(0.2), |
|
tf.keras.layers.GaussianNoise(0.1), |
|
]) |
|
|
|
AUTOTUNE = tf.data.AUTOTUNE |
|
train_ds = train_ds.cache().shuffle(1000).prefetch(buffer_size=AUTOTUNE) |
|
val_ds = val_ds.cache().prefetch(buffer_size=AUTOTUNE) |
|
|
|
model = tf.keras.Sequential([ |
|
data_augmentation, |
|
tf.keras.layers.Rescaling(1./255, input_shape=(200, 200, 1)), |
|
tf.keras.layers.Conv2D(32, (3, 3), activation='relu'), |
|
tf.keras.layers.MaxPooling2D(2, 2), |
|
tf.keras.layers.Conv2D(64, (3, 3), activation='relu'), |
|
tf.keras.layers.MaxPooling2D(2, 2), |
|
tf.keras.layers.Conv2D(128, (3, 3), activation='relu'), |
|
tf.keras.layers.MaxPooling2D(2, 2), |
|
tf.keras.layers.Conv2D(128, (3, 3), activation='relu'), |
|
tf.keras.layers.MaxPooling2D(2, 2), |
|
tf.keras.layers.Flatten(), |
|
tf.keras.layers.Dropout(0.5), |
|
tf.keras.layers.Dense(512, activation='relu'), |
|
tf.keras.layers.Dense(2, activation='softmax') |
|
]) |
|
|
|
model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=0.001), |
|
loss='sparse_categorical_crossentropy', |
|
metrics=['accuracy']) |
|
``` |
|
|
|
## Evaluation |
|
|
|
<!-- This section describes the evaluation protocols and provides the results. --> |
|
|
|
### Testing Data, Factors & Metrics |
|
|
|
### Model summary |
|
```text |
|
βββββββββββββββββββββββββββββββββββ³βββββββββββββββββββββββββ³ββββββββββββββββ |
|
β Layer (type) β Output Shape β Param # β |
|
β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ© |
|
β sequential (Sequential) β (None, 200, 200, 1) β 0 β |
|
βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ |
|
β rescaling (Rescaling) β (None, 200, 200, 1) β 0 β |
|
βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ |
|
β conv2d (Conv2D) β (None, 198, 198, 64) β 640 β |
|
βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ |
|
β max_pooling2d (MaxPooling2D) β (None, 99, 99, 64) β 0 β |
|
βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ |
|
β conv2d_1 (Conv2D) β (None, 97, 97, 128) β 73,856 β |
|
βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ |
|
β max_pooling2d_1 (MaxPooling2D) β (None, 48, 48, 128) β 0 β |
|
βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ |
|
β conv2d_2 (Conv2D) β (None, 46, 46, 256) β 295,168 β |
|
βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ |
|
β max_pooling2d_2 (MaxPooling2D) β (None, 23, 23, 256) β 0 β |
|
βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ |
|
β conv2d_3 (Conv2D) β (None, 21, 21, 256) β 590,080 β |
|
βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ |
|
β max_pooling2d_3 (MaxPooling2D) β (None, 10, 10, 256) β 0 β |
|
βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ |
|
β flatten (Flatten) β (None, 25600) β 0 β |
|
βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ |
|
β dropout (Dropout) β (None, 25600) β 0 β |
|
βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ |
|
β dense (Dense) β (None, 1024) β 26,215,424 β |
|
βββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββΌββββββββββββββββ€ |
|
β dense_1 (Dense) β (None, 2) β 2,050 β |
|
βββββββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββ΄ββββββββββββββββ |
|
Total params: 81,531,656 (311.02 MB) |
|
Trainable params: 27,177,218 (103.67 MB) |
|
Non-trainable params: 0 (0 MB) |
|
Optimizer params 54,354,438 (207.35 MB) |
|
``` |
|
|
|
### Loss and Accuracy |
|
![Loss and Accuracy](./images/loss-accuracy.png) |
|
|
|
### Results |
|
| | precision | recall | f1-score | support | |
|
|-----------|-----------|--------|----------|---------| |
|
| one_one | 0.98 | 0.98 | 0.96 | 1637 | |
|
| one_two | 0.98 | 0.98 | 0.98 | 1740 | |
|
| accuracy | | | 0.96 | 3377 | |
|
| macro avg | 0.98 | 0.98 | 0.98 | 3377 | |
|
| weighted avg| 0.98 | 0.98 | 0.98 | 3377 | |
|
|
|
## Environmental Impact |
|
- **Hardware Type:** M3 Pro |
|
- **Hours used:** 72 |
|
|