Package: pytorch-galaxy-datasets
pytorch-galaxy-datasetsPyTorch Datasets and PyTorch Lightning Datamodules for loading images and labels from Galaxy Zoo citizen science campaigns.NameClassPublishedDownloadableGalaxiesGalaxy Zoo 2GZ2☑☑~210k (main sample)GZ HubbleHubble☑☑~106k (main sample)GZ CANDELSCandels☑☑~50kGZ DECaLS GZD-5DecalsDR5☑☑~230kGalaxy Zoo RingsRings☒☑~93kGZ Legacy SurveyLegs☒z < 0.1 only~375k + 8.3m unlabelledCFHT Tidal*Tidal☑☑1760 (expert)Any datasets marked as downloadable but not marked as published are only downloadable internally (for development purposes).If a dataset is published but not marked as downloadable (none currently), it means I haven't yet got around to making the download automatic. You can still download it via the paper instructions.You may also be interested inGalaxy MNISTas a simple dataset for teaching/debugging.For each dataset, you must cite/acknowledge the GZ data release paper and the original telescope survey from which the images were derived. Seedata.galaxyzoo.orgfor the data release paper citations to use.*CFHT Tidal is not a Galaxy Zoo dataset, but rather a small expert-labelled dataset of tidal features fromAtkinson 2013.
MW reproduced and modified the images inWalmsley 2019.
We include it here as a challenging fine-grained morphology classification task with little labelled data.InstallationFor local development (e.g. adding a new dataset), you can install this by cloning from github, then runningpip install -e .in the cloned repo root.It will also be installed by default as a dependency ofzoobotif you specify the pytorch version ofzoobot- but this is slightly trickier if you'd like to make changes as it'll be installed under yoursitepackages.UsageYou can load each prepared dataset as a pytorch Dataset like so:from pytorch_galaxy_datasets.prepared_datasets import GZ2Dataset

gz2_dataset = GZ2Dataset(
    root='/nvme1/scratch/walml/repos/pytorch-galaxy-datasets/roots/gz2',
    train=True,
    download=False
)
image, label = gz2_dataset[0]
plt.imshow(image)You will probably want to customise the dataset, selecting a subset of galaxies or labels. Do this with the{dataset}_setup()methods.from pytorch_galaxy_datasets.prepared_datasets import gz2_setup

catalog, label_cols = gz2_setup(
    root='/nvme1/scratch/walml/repos/pytorch-galaxy-datasets/roots/gz2',
    train=True,
    download=False
)
adjusted_catalog = gz2_catalog.sample(1000)You can then customise the catalog and labels before creating a generic GalaxyDataset, which can be used with your own transforms etc. like any other pytorch datasetfrom pytorch_galaxy_datasets.galaxy_dataset import GalaxyDataset

dataset = GalaxyDataset(
    label_cols=['smooth-or-featured_smooth'],
    catalog=adjusted_catalog,
    transforms=some_torchvision_transforms_if_you_like
)For training models, I recommend using Pytorch Lightning and GalaxyDataModule, which has default transforms for supervised learning.from pytorch_galaxy_datasets.galaxy_datamodule import GalaxyDataModule

datamodule = GalaxyDataModule(
    label_cols=['smooth-or-featured_smooth'],
    catalog=adjusted_catalog
)

datamodule.prepare_data()
datamodule.setup()
for images, labels in datamodule.train_dataloader():
    print(images.shape, labels.shape)
    breakYou can also get the canonical catalog and label_cols from the Dataset, if you prefer.gz2_catalog = gz2_dataset.catalog
gz2_label_cols = gz2_dataset.label_colsDownload NotesDatasets are downloaded like:{root}imagessubfolder (except GZ2)image.jpg{catalog_name(s)}.parquet