How tirth-byte/galaxy-zoo works
Purpose and Entry Points
This repository is a Python/PyTorch image-classification pipeline for assigning galaxy images to seven morphology classes using transfer-learned EfficientNet-B0. Primary operational entry points are dataset acquisition/preparation (dataset.py), model training (train.py), optional CSV-oriented training logic (train_csv.py), and batch inference/report generation (predict.py). index.html is a static browser dashboard, not part of the ML runtime.
Central Configuration Contract
config.py centralizes class definitions, filesystem locations, hyperparameters, and training/runtime constants consumed across the pipeline. It is the main contract connecting data loading, model output dimensionality, training behavior, checkpoint locations, and inference labels.
• config.py
• train.py
• predict.py
Data Acquisition and Dataset Boundary
Dataset preparation is handled by dataset.py. It can download source data through Kaggle credentials and organize images into class-oriented directories suitable for supervised training. The boundary is filesystem-based: prepared image folders become the input to PyTorch dataset/dataloader construction; raw external Kaggle data and local user-supplied images remain outside the model code.
• dataset.py
• requirements.txt
Image Transforms and Loading
The dataset stage defines image preprocessing and augmentation, then emits PyTorch loaders for training and validation. These loaders carry image tensors plus class targets into the training loop. EfficientNet-compatible normalization and resize behavior should remain consistent between this stage and inference preprocessing.
• dataset.py
• train.py
• predict.py
Model Construction
model.py owns the EfficientNet-B0 classifier definition. It adapts the pretrained model’s final classification layers to the repository’s seven galaxy classes, forming the shared network contract for both training and prediction. Training produces a checkpoint/state artifact that inference reloads.
• model.py
• train.py
• predict.py
Training and Evaluation Pipeline
train.py orchestrates transfer learning: it receives loaders, instantiates the model, optimizes cross-entropy loss, evaluates validation metrics, and applies early stopping plus cosine-annealing learning-rate scheduling. It produces persisted model checkpoints and diagnostics such as training-history and confusion-matrix images under the output artifact area.
• train.py
• model.py
• output
train_csv.py is a secondary training-oriented pipeline and should be treated as a separate/alternative input-flow path until its relationship to train.py is verified.
• train_csv.py
Batch Inference and Reporting
predict.py accepts unseen files from a local input directory, applies inference preprocessing, runs logits through the trained classifier, converts scores to probabilities and predicted labels, and writes consumable reports. Outputs include a master CSV and formatted Excel results, making this the stakeholder-facing delivery boundary.
• predict.py
• output
• config.py
Runtime and External Dependencies
The primary runtime is Python 3.8+ with PyTorch and EfficientNet-related dependencies declared in requirements.txt. Kaggle is the material external service for automated dataset download and requires local kaggle.json credentials. The static dashboard runs directly in a browser from index.html; the nested attendance-bot package appears unrelated to the galaxy-classification pipeline based on the provided repository structure.
• requirements.txt
• dataset.py
• index.html
• attendance-bot/package.json
Main entry points: config.py Pipeline configuration · train.py Training pipeline · dataset.py Dataset preparation · model.py EfficientNet-B0 model
Components 15
Data preparation
- Kaggle dataset · Download source requiring local Kaggle credentials.
- Dataset preparation · Downloads and organizes class-oriented image folders.
dataset.py - Transforms & loaders · Augments and normalizes images into training and validation tensors.
dataset.py
ML runtime
- Pipeline configuration · Classes, paths, hyperparameters, and runtime constants.
config.py - EfficientNet-B0 model · Pretrained network adapted for seven morphology classes.
model.py - Training pipeline · Orchestrates fitting, validation, and artifact creation.
train.py - Optimization & evaluation · Cross-entropy fitting with cosine scheduling and early stopping.
train.py - CSV training path · Secondary training flow with relationship to the main trainer unverified.
train_csv.py - Model & diagnostics · Checkpoints, history, and confusion-matrix outputs.
output
Inference delivery
- Batch prediction · Classifies local unseen images and generates stakeholder reports.
predict.py - Inference preprocessing · Applies compatible resize and normalization before scoring.
predict.py - CSV & Excel reports · Master CSV and formatted Excel prediction results.
output
Other components
- Python dependencies · PyTorch, EfficientNet, and Kaggle runtime packages.
requirements.txt - Static dashboard · Standalone browser dashboard outside the ML runtime.
index.html - Attendance bot · Nested package unrelated to the galaxy pipeline.
attendance-bot/package.json
Connections 18
- Python dependencies → Dataset preparation: provides runtime
- Python dependencies → Training pipeline: provides runtime
- Kaggle dataset → Dataset preparation: downloads raw data
- Pipeline configuration → Dataset preparation: uses paths & classes
- Dataset preparation → Transforms & loaders: prepared image folders
- Pipeline configuration → Transforms & loaders: uses class contract
- Transforms & loaders → Training pipeline: train/validation batches
- Pipeline configuration → Training pipeline: uses hyperparameters
- Pipeline configuration → EfficientNet-B0 model: sets output classes
- EfficientNet-B0 model → Training pipeline: instantiated for training
- Training pipeline → Optimization & evaluation: runs
- Optimization & evaluation → Model & diagnostics: writes checkpoint & diagnostics
- CSV training path → Model & diagnostics: may produce training artifacts
- Pipeline configuration → Batch prediction: supplies labels & paths
- Model & diagnostics → Batch prediction: reloads trained checkpoint
- Batch prediction → Inference preprocessing: processes input files
- EfficientNet-B0 model → Inference preprocessing: produces logits
- Inference preprocessing → CSV & Excel reports: writes labels & probabilities