Downloads · 30 days
30
11% of all-time downloads
IT-Guy007/AstroVisionV1
AstroVisionV1 is a image classification model from IT-Guy007. Use it when you need a label for an image. It is set up for keras. The card lists the license as apache-2.0.
This model classifies RGB images to the 2 classes, Spheroid or Spiral.
Downloads · 30 days
30
11% of all-time downloads
All-time downloads
274
Public
Repo size
408 MB
Likes
0
Public
Click a slice to open those files.
.keras326 MB · 100%
From the Hugging Face model README
This model classifies RGB images to the 2 classes, Spheroid or Spiral.
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.
Use the code below to get started with the model.
model = tf.keras.models.load_model('model.keras')
prediction = model.predict(image)
print(prediction)
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
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'])
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ 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)

| 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 |