// OPEN SOURCE DEEP LEARNING PIPELINE

MAPPING DEEP SPACE
OBSERVATIONAL DATA
WITH RESNET-34

SCROLL TO EXPLORE

An end-to-end Computer Vision framework powered by a custom ResNet-34 neural network in PyTorch 2.x. Automates batch data harvesting from NASA APOD & MAST Hubble/JWST archives, sorting observations into 5 astrophysical classes with SQLite audit tracking.

94.2% Test Set Accuracy
ResNet-34 Deep Neural Backbone
NASA + MAST APOD & Hubble Feeds
5 Classes Astrophysical Targets
Hugging Face Hub Model Weights

End-to-End Astronomical Pipeline

A fully automated, modular deep learning pipeline designed to harvest raw space captures, train robust convolutional representations, and perform audited batch classification.

Automated Data Harvester

src/data_collection/image_collection.py fetches high-resolution observations from NASA APOD API and MAST (Hubble Space Telescope catalog) with automated deduplication JSON registries.

ResNet-34 Neural Classifier

training/network_training.ipynb trains a fine-tuned ResNet-34 with PyTorch Automatic Mixed Precision (AMP), geometric space augmentations (180° rotation invariance), and Adam optimization.

Auto-Sorter & SQLite Audit

network_sorting/ performs batch inference, sorts images into class directories, and logs every audit record into SQLite (classified_images.db), viewable in Flask.

The Four Core Modules

Each component operates as an autonomous, decoupled module within the repository ecosystem.

MODULE 01

Image Harvester (APOD & MAST)

Python 3.12 Astroquery NASA APOD API Requests

Located in src/data_collection/image_collection.py. Interacts with the NASA Planetary APOD endpoint using keyword filtering (galaxy, nebula, planet, cluster, star) and queries the Mikulski Archive for Space Telescopes (MAST) with Observations.query_criteria for Hubble HST science products.

  • Deduplication tracking via persistent downloaded.json registries.
  • Automatic destination folder routing for NASA and MAST streams.
  • Graceful error handling and retry limits on network timeouts.
MODULE 02

ResNet-34 Deep Training

PyTorch 2.x TorchVision CUDA AMP Adam Optimizer

Located in training/network_training.ipynb. Implements a transfer-learning convolutional backbone (ResNet-34) pretrained on ImageNet and re-engineered with a 5-class linear output head.

  • Automatic Mixed Precision (torch.amp.autocast & GradScaler).
  • Geometric transformations: 180° rotation invariance and horizontal flips.
  • Model checkpoint export directly to trained_net.pth.
MODULE 03

Inference Engine & Auto-Sorter

TorchVision Inference SQLite 3 Batch Processing

Located in network_sorting/image_classifier.ipynb. Scans raw unclassified image directories, performs tensor inference with trained_net.pth, and dynamically moves files to organized target folders.

  • Automatic folder creation per predicted class (star, galaxy, nebula, etc.).
  • Records execution timestamps, source paths, and prediction scores in classified_images.db.
MODULE 04

Flask Classification Web Viewer

Flask SQLite Connector Semantic HTML5

Located in src/viewer/classification_viewer.py. A lightweight local web application serving a clean interface to inspect all audit records stored in the SQLite database.

  • Groups records by astronomical category into dedicated inspection tables.
  • Displays total counts, filenames, source directories, and classification audit timestamps.

Astronomical Data Feeds & Storage

AstroClass AI harvests observational data across premier astrophysical endpoints, harmonizing image distributions for convolutional training.

NASA APOD API
AUTOMATED

NASA Astronomy Picture of the Day

High-resolution space captures queried via REST API with keyword matching (nebula, galaxy, cluster, planet, supernova).

MAST ARCHIVE
AUTOMATED

Hubble & JWST Observations

Science catalog observation products harvested with Astroquery, filtered by instrument, target name, and MJD date windows.

SQLITE AUDIT DB
PERSISTENT

SQLite 3 Audit Logging

Stores complete inference records in classified_images.db: file paths, predicted classes, and audit timestamps.

TORCHVISION TRANSFORMS
AUGMENTED

ImageNet Spatial Normalization

Random horizontal flips, 180° rotation invariance, and ImageNet mean/std distribution tensors tailored for astronomy.

SCROLL TO FLY THROUGH THE 5 ASTROPHYSICAL TARGET CLASSES
CLASS [01/05] • nebula INTERSTELLAR IONIZED CLOUD

Volumetric Ionized Nebula

Emission, reflection, planetary nebulae, supernova remnants, and dark cosmic dust clouds where gravity initiates stellar birth.

Example Targets Crab Nebula, Horsehead, Tarantula
Primary Ingestion Source NASA APOD & Hubble Science Catalog
Model Output Mapping network_sorting/nebula/
CLASS [02/05] • galaxy GALACTIC MORPHOLOGY

Spiral & Elliptical Galaxy

Spiral, elliptical, irregular, and interacting galaxies with dense galactic cores, logarithmic star arms, and stellar halos.

Example Targets M81, M82, NGC 3628, Hoag's Object
Primary Ingestion Source MAST HST Deep Field & APOD
Model Output Mapping network_sorting/galaxy/
CLASS [03/05] • star STELLAR BODIES & CLUSTERS

Stellar Engines & Star Clusters

Individual stars, rich stellar fields, dense globular clusters, open clusters, and long-exposure star trails across deep space.

Example Targets Pleiades, Eta Aquaridy, 47 Tucanae
Primary Ingestion Source NASA Planetary APOD Telescopes
Model Output Mapping network_sorting/star/
CLASS [04/05] • quasar ACTIVE GALACTIC NUCLEUS

Supermassive Quasar & Pulsar

Active Galactic Nuclei (AGN), distant energetic pulsars, and high-energy relativistic plasma jets powered by central supermassive black holes.

Example Targets Vela Pulsar, Abell 2744 High-Energy Sources
Primary Ingestion Source MAST High-Energy Science Archives
Model Output Mapping network_sorting/quasar/
CLASS [05/05] • planet EXOPLANET & PLANETARY BODY

Planetary Bodies & Moons

Solar system planets, planetary moons, complex ring systems, and high-resolution planetary surface telemetry.

Example Targets Jupiter, Mars, Saturn Rings, Rhea, Titan
Primary Ingestion Source NASA Planetary Science Archives
Model Output Mapping network_sorting/planet/

3D Neural Latent Manifold

Interactive 3D manifold projection of feature vectors extracted from the ResNet-34 penultimate layer, demonstrating cluster separation across all 5 astrophysical target classes.

Nebula Galaxy Star Quasar Planet
BACKBONE: RESNET-34 PENULTIMATE LAYER (512-D) PROJECTION: 3D MANIFOLD CLUSTERING

Open Weights on Hugging Face

The fine-tuned astroclass_ai ResNet-34 model is publicly hosted on Hugging Face Hub. Download pre-trained PyTorch weights or run inference in seconds with huggingface_hub.

🤗 Hugging Face Hub 94.2% Test Accuracy

RaulSalasSahuquillo/astroclass_ai

Astrophysical Deep Learning Backbone (ResNet-34) fine-tuned on NASA APOD and Mikulski Archive for Space Telescopes (MAST Hubble Space Telescope).

Architecture ResNet-34 (Transfer Learning)
Weights File astroclass_ai.pth (85.3 MB)
Target Classes 5 (Star, Galaxy, Quasar, Nebula, Planet)
Input Resolution 224 × 224 RGB (ImageNet Norm)
Framework PyTorch 2.x & TorchVision
License CC BY-NC-SA 4.0
# Install dependencies:
pip install torch torchvision pillow huggingface_hub

import torch
from torchvision.models import resnet34
from torchvision import transforms
from PIL import Image
from huggingface_hub import hf_hub_download

# 1. Download weights directly from Hugging Face Hub
model_path = hf_hub_download(
    repo_id="RaulSalasSahuquillo/astroclass_ai",
    filename="astroclass_ai.pth"
)

# 2. Build ResNet-34 with 5 astrophysical classes
classes = ["star", "galaxy", "quasar", "nebula", "planet"]
model = resnet34(weights=None)
model.fc = torch.nn.Linear(model.fc.in_features, len(classes))
model.load_state_dict(torch.load(model_path, map_location="cpu"))
model.eval()

# 3. Preprocess observation and predict
preprocess = transforms.Compose([
    transforms.Resize((224, 224)),
    transforms.ToTensor(),
    transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
])

img = Image.open("deep_space_capture.jpg").convert("RGB")
tensor = preprocess(img).unsqueeze(0)

with torch.no_grad():
    probs = torch.softmax(model(tensor), dim=1)[0]
    best_idx = probs.argmax().item()

print(f"Predicted: {classes[best_idx]} ({probs[best_idx]*100:.1f}%)")

Run the Pipeline Locally

AstroClass AI is 100% open source under the CC BY-NC-SA 4.0 license. Clone the repository and execute the observation pipeline in 4 simple commands.

bash — astroclass-pipeline
# 1. Clone the open source repository
git clone https://github.com/RaulSalasSahuquillo/nasa-deep-space-classifier.git
cd nasa-deep-space-classifier

# 2. Create Python virtual environment and install dependencies
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

# 3. Configure your NASA API key (Optional: DEMO_KEY works out of the box)
cp .env.example .env

# 4. Harvest astronomical imagery from NASA APOD & MAST
python src/data_collection/image_collection.py

# 5. Launch the SQLite Flask Classification Web Viewer
python src/viewer/classification_viewer.py
# Navigate to http://localhost:5000 in your web browser
Raúl Salas Sahuquillo - Architect & Developer
🇪🇸 SPAIN • AGE 16

Raúl Salas Sahuquillo

I am a 16-year-old AI developer and high school student from Spain with a passionate focus on computer vision and observational astrophysics. To help catalog the vast amounts of unclassified imagery floating in astronomical archives, I built AstroClass AI (nasa-deep-space-classifier): an open-source deep learning pipeline unifying data harvesting, ResNet-34 neural training, automated sorting, and SQLite audit inspection under a reproducible open science framework.

16 Years Old Student Developer
100% Open Source Architecture
5 Astrophysical Target Classes

"Artificial intelligence and deep convolutional networks allow us to illuminate the hidden structures of deep space, cataloging celestial captures in milliseconds."