MCPcopy Create free account
hub / github.com/PolymathicAI/AstroCLIP / AstroClipDataset

Class AstroClipDataset

astroclip/data/dataset.py:39–118  ·  view source on GitHub ↗

TODO: Short description of my dataset.

Source from the content-addressed store, hash-verified

37
38
39class AstroClipDataset(datasets.GeneratorBasedBuilder):
40 """TODO: Short description of my dataset."""
41
42 VERSION = datasets.Version("1.1.5")
43
44 BUILDER_CONFIGS = [
45 datasets.BuilderConfig(
46 name="joint",
47 version=VERSION,
48 description="This part of the dataset covers examples from both specral and image domains",
49 ),
50 ]
51
52 DEFAULT_CONFIG_NAME = "joint"
53
54 def _info(self):
55 if self.config.name == "joint":
56 features = datasets.Features(
57 {
58 "image": datasets.Array3D(shape=(152, 152, 3), dtype="float32"),
59 "spectrum": datasets.Array2D(shape=(7781, 1), dtype="float32"),
60 "redshift": datasets.Value("float32"),
61 "targetid": datasets.Value("int64"),
62 }
63 )
64 else:
65 raise NotImplementedError(
66 "Only the joint configuration is implemented for now"
67 )
68
69 return datasets.DatasetInfo(
70 description=_DESCRIPTION,
71 features=features,
72 homepage=_HOMEPAGE,
73 license=_LICENSE,
74 citation=_CITATION,
75 )
76
77 def _split_generators(self, dl_manager):
78 urls = _URLS[self.config.name]
79 dl_manager.download_config.storage_options["timeout"] = ClientTimeout(total=5000, connect=1000)
80 data_dir = dl_manager.download_and_extract(urls)
81 return [
82 datasets.SplitGenerator(
83 name=datasets.Split.TRAIN,
84 gen_kwargs={
85 "filepath": data_dir,
86 "split": "train",
87 },
88 ),
89 datasets.SplitGenerator(
90 name=datasets.Split.TEST,
91 gen_kwargs={"filepath": data_dir, "split": "test"},
92 ),
93 ]
94
95 def _generate_examples(self, filepath, split):
96 """Yields examples."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected