galaxy-datasets
ML-friendly datasets for major Galaxy Zoo citizen science campaigns.
- PyTorch Datasets and PyTorch Lightning DataModules
- Framework-independent download and augmentation code
See also our HuggingFace datasets, which offer faster downloads and more flexible use. This repo was created earlier and may ultimately be replaced by HuggingFace.
| Name | Method | PyTorch Dataset | Published | Downloadable | Galaxies |
|---|---|---|---|---|---|
| Galaxy Zoo 2 | gz2 | GZ2 | ☑ | ☑ | ~210k (main sample) |
| GZ UKIDSS | gz_ukidss | GZUKIDSS | ☒ | ☑ | ~71k |
| GZ Hubble* | gz_hubble | GZHubble | ☑ | ☑ | ~106k (main sample) |
| GZ CANDELS | gz_candels | GZCandels | ☑ | ☑ | ~50k |
| GZ DECaLS GZD-5 | gz_decals_5 | GZDecals5 | ☑ | ☑ | ~230k (GZD-5 only) |
| GZ Rings | gz_rings | GZRings | ☒ | ☑ | ~93k |
| GZ DESI | gz_desi | GZDesi | ☑ | No* (500GB) | 8.7M |
| GZ UKIDSS | gz_ukidss | - | ☑ | ☑ | ~70k |
| GZ Euclid | gz_euclid | - | ☒ | ☑ | ~100k |
| GZ H2O (deep HSC) | gz_h2o | GZH2O | ☒ | ☑ | ~48k |
| GZ JWST (CEERS) | gz_jwst | GZJWST | ☒ | ☑ | ~7k |
| CFHT Tidal* | tidal | Tidal | ☑ | ☑ | 1760 (expert) |
Any datasets marked as downloadable but not marked as published are only downloadable internally (for development purposes).
For each dataset, you must cite/acknowledge the GZ data release paper and the original telescope survey from which the images were derived. See data.galaxyzoo.org for the data release paper citations to use.
We also include small debugging datasets:
| Name | Method | PyTorch Dataset | Downloadable | Galaxies |
|---|---|---|---|---|
| Demo Rings (binary) | demo_rings | DemoRings | ☑ | 1000 |
| Galaxy MNIST (four-class) | galaxy_mnist | GalaxyMNIST | ☑ | 10k |
Galaxy MNIST is also available as a pure torchvision dataset (exactly like MNIST).
*GZ Hubble is also available in "euclidised" form (i.e. with the Euclid PSF applied) to Euclid collaboration members. The method is gz_hubble_euclidised. Courtesy of Ben Aussel.
**Mike Smith has shared a replication of the GZ DESI images and labels on HuggingFace (983GB)
**CFHT Tidal is not a Galaxy Zoo dataset, but rather a small expert-labelled dataset of tidal features from Atkinson 2013. MW reproduced and modified the images in Walmsley 2019. We include it here as a challenging fine-grained morphology classification task with little labelled data.
Installation
Installing zoobot will automatically install this package as a dependency.
To install directly:
pip install galaxy-datasets(includes PyTorch dependencies)
For local development (e.g. adding a new dataset), you can install this by cloning from github, then running pip install -e . in the cloned repo root. This makes changing the code easier than if you don't use the -e, in which case the package is installed under sitepackages.
I suggest either:
- For basic use without changes, installing
zoobotvia pip and allowing pip to manage this dependency - For development, installing both
zoobotandgalaxy-datasetsvia git
Usage
Check out the PyTorch quickstart Colab here, or keep reading for more explanation.
Framework-Independent
To download a dataset:
from galaxy_datasets import gz2 # or gz_hubble, gz_candels, ...
catalog, label_cols = gz2(
root='your_data_folder/gz2',
train=True,
download=True
)
This will download the images and train/test catalogs to root. Each catalog is a pandas DataFrame with the column file_loc giving absolute image paths and additional columns label_cols = ['col_a', 'col_b', ...] giving the labels (usually, the number of volunteers who gave each answer for each galaxy). If train=True, the method returns the train catalog, otherwise, the test catalog.
If training Zoobot from scratch, this is all you need. For example, in PyTorch:
from zoobot.pytorch.training import train_with_pytorch_lightning
train_with_pytorch_lightning.train_default_zoobot_from_scratch(
catalog=catalog,
save_dir=save_dir,
schema=gz2_schema, # see zoobot/pytorch/examples/minimal_example.py
...
)
Otherwise, you might like to use the classes in this package to load these catalogs into ML-friendly inputs.
PyTorch
Create a PyTorch Dataset from a catalog like so:
from galaxy_datasets.pytorch.galaxy_dataset import CatalogDataset # generic Dataset for galaxies
dataset = CatalogDataset(
catalog=catalog.sample(1000), # from gz2(...) above
label_cols=['smooth-or-featured-gz2_smooth']
)
Notice how you can adjust the catalog before creating the Dataset. This gives flexibility to try training on e.g. different catalog subsets.
If you don't want to change anything about the catalog, you can skip the framework-independent download and use a named class from galaxy_datasets.pytorch, which takes the same arguments and directly gives a Dataset:
from galaxy_datasets.pytorch import GZ2
gz2_dataset = GZ2(
root='your_data_folder/gz2',
train=True,
download=False
)
batch = gz2_dataset[0]
image = batch['image']
label = batch['smooth-or-featured-gz2_smooth']
You might also find the PyTorch Lightning DataModule under galaxy_datasets/pytorch/galaxy_datamodule useful. Zoobot uses this for training and finetuning.
from galaxy_datasets.pytorch.galaxy_datamodule import CatalogDataModule
from galaxy_datasets.transforms import get_galaxy_transform, default_view_config
datamodule = CatalogDataModule(
label_cols=['smooth-or-featured-gz2_smooth'],
catalog=catalog
# optional args to specify augmentations
train_transform=get_galaxy_transform(default_view_config()),
test_transform=get_galaxy_transform(default_view_config())
)
datamodule.prepare_data()
datamodule.setup()
for batch in datamodule.train_dataloader():
images = batch['image']
labels = batch['smooth-or-featured-gz2_smooth']
print(images.shape, labels.shape)
break
TensorFlow
TensorFlow support has now been deprecated. The ML research community has broadly converged on PyTorch. We suggest using PyTorch or, for framework-indepedent data loading, our HuggingFace datasets.
Download Notes
Datasets are downloaded like:
- {root}
- images
- subfolder (except GZ2)
- image.jpg
- subfolder (except GZ2)
- {catalog_name(s)}.parquet
- images
The whole dataset is downloaded regardless of whether train=True or train=False.
Metadata
Release files for galaxy-datasets 0.0.25
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| galaxy_datasets-0.0.25.tar.gz | 59.8 kB | Without provenance | Details for galaxy_datasets-0.0.25.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| galaxy_datasets-0.0.25-py3-none-any.whl | Python 3 | none | any | Details for galaxy_datasets-0.0.25-py3-none-any.whl |
Total release size: 133.1 kB
Release files / galaxy_datasets-0.0.25.tar.gz
| Download URL | galaxy_datasets-0.0.25.tar.gz |
|---|---|
| Size | 59.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
804c56106ce7995375f0f74a250db9d71b67f34c4778dd0a1efbed5d4fb8631f
|
|
BLAKE2b-256 checksum How to use checksums |
910cbf1e5fe8bfe008e66c4913a4c205c56dd75a2bd2e97b30875eb870d31fba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / galaxy_datasets-0.0.25-py3-none-any.whl
| Download URL | galaxy_datasets-0.0.25-py3-none-any.whl |
|---|---|
| Size | 73.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d51895c21da57b4d1924701298097b5876e031f4d347725809229116d49151f8
|
|
BLAKE2b-256 checksum How to use checksums |
843f1a5bbfee705ea49ec029585f142880d135271310336aec46c9e3f75d041a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Security for galaxy-datasets 0.0.25
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.