anonuser7251 commited on
Commit
aaad474
1 Parent(s): 5d06e72

Add dataset

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
.gitattributes CHANGED
@@ -56,3 +56,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
56
  # Video files - compressed
57
  *.mp4 filter=lfs diff=lfs merge=lfs -text
58
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
56
  # Video files - compressed
57
  *.mp4 filter=lfs diff=lfs merge=lfs -text
58
  *.webm filter=lfs diff=lfs merge=lfs -text
59
+ *.fits filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ pretty_name: Raw space-based images from the Hubble Space Telescope
4
+ tags:
5
+ - astronomy
6
+ - compression
7
+ - images
8
+ ---
9
+
10
+ # SBI-16-2D Dataset
11
+
12
+ SBI-16-2D is a dataset which is part of the AstroCompress project. It contains imaging data assembled from the Hubble Space Telescope (HST). <TODO>Describe data format</TODO>
13
+
14
+ # Usage
15
+
16
+ You first need to install the `datasets` and `astropy` packages:
17
+
18
+ ```bash
19
+ pip install datasets astropy
20
+ ```
21
+
22
+ There are two datasets: `tiny` and `full`, each with `train` and `test` splits. The `tiny` dataset has 2 2D images in the `train` and 1 in the `test`. The `full` dataset contains all the images in the `data/` directory.
23
+
24
+ ## Local Use (RECOMMENDED)
25
+
26
+ You can clone this repo and use directly without connecting to hf:
27
+
28
+ ```bash
29
+ git clone https://huggingface.co/datasets/AstroCompress/SBI-16-2D
30
+ ```
31
+
32
+ To pull all data files:
33
+ ```
34
+ git lfs pull
35
+ ```
36
+
37
+ Then `cd SBI-16-3D` and start python like:
38
+
39
+ ```python
40
+ from datasets import load_dataset
41
+ dataset = load_dataset("./SBI-16-2D.py", "tiny", data_dir="./data/", writer_batch_size=1, trust_remote_code=True)
42
+ ds = dataset.with_format("np")
43
+ ```
44
+
45
+ Now you should be able to use the `ds` variable like:
46
+
47
+ ```python
48
+ ds["test"][0]["image"].shape # -> (TBD)
49
+ ```
50
+
51
+ Note of course that it will take a long time to download and convert the images in the local cache for the `full` dataset. Afterward, the usage should be quick as the files are memory-mapped from disk.
52
+
53
+ ## Use from Huggingface Directly
54
+
55
+ This method may only be an option when trying to access the "tiny" version of the dataset.
56
+
57
+ To directly use from this data from Huggingface, you'll want to log in on the command line before starting python:
58
+
59
+ ```bash
60
+ huggingface-cli login
61
+ ```
62
+
63
+ or
64
+
65
+ ```
66
+ import huggingface_hub
67
+ huggingface_hub.login(token=token)
68
+ ```
69
+
70
+ Then in your python script:
71
+
72
+ ```python
73
+ from datasets import load_dataset
74
+ dataset = load_dataset("AstroCompress/SBI-16-2D", "tiny", writer_batch_size=1, trust_remote_code=True)
75
+ ds = dataset.with_format("np")
76
+ ```
77
+
78
+
79
+ ## Demo Colab Notebook
80
+ We provide a demo collab notebook to get started on using the dataset [here](https://colab.research.google.com/drive/1SuFBPZiYZg9LH4pqypc_v8Sp99lShJqZ?usp=sharing).
81
+
82
+ ## Utils scripts
83
+ Note that utils scripts such as `eval_baselines.py` must be run from the parent directory of `utils`, i.e. `python utils/eval_baselines.py`.
SBI-16-2D.py ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import random
3
+ from glob import glob
4
+ import json
5
+ from huggingface_hub import hf_hub_download
6
+
7
+
8
+ from astropy.io import fits
9
+ import datasets
10
+ from datasets import DownloadManager
11
+ from fsspec.core import url_to_fs
12
+
13
+ _DESCRIPTION = """
14
+ SBI-16-2D is a dataset which is part of the AstroCompress project.
15
+ It contains imaging data assembled from the Hubble Space Telescope (HST).
16
+ """
17
+
18
+ _HOMEPAGE = "https://google.github.io/AstroCompress"
19
+
20
+ _LICENSE = "CC BY 4.0"
21
+
22
+ _URL = "https://huggingface.co/datasets/AstroCompress/SBI-16-2D/resolve/main/"
23
+
24
+ _URLS = {
25
+ "tiny": {
26
+ "train": "./splits/tiny_train.jsonl",
27
+ "test": "./splits/tiny_test.jsonl",
28
+ },
29
+ "full": {
30
+ "train": "./splits/full_train.jsonl",
31
+ "test": "./splits/full_test.jsonl",
32
+ },
33
+ }
34
+
35
+ _REPO_ID = "AstroCompress/SBI-16-2D"
36
+
37
+
38
+ class SBI_16_2D(datasets.GeneratorBasedBuilder):
39
+ """SBI-16-2D Dataset"""
40
+
41
+ VERSION = datasets.Version("1.0.4")
42
+
43
+ BUILDER_CONFIGS = [
44
+ datasets.BuilderConfig(
45
+ name="tiny",
46
+ version=VERSION,
47
+ description="A small subset of the data, to test downsteam workflows.",
48
+ ),
49
+ datasets.BuilderConfig(
50
+ name="full",
51
+ version=VERSION,
52
+ description="The full dataset",
53
+ ),
54
+ ]
55
+
56
+ DEFAULT_CONFIG_NAME = "tiny"
57
+
58
+ def __init__(self, **kwargs):
59
+ super().__init__(version=self.VERSION, **kwargs)
60
+
61
+ def _info(self):
62
+ return datasets.DatasetInfo(
63
+ description=_DESCRIPTION,
64
+ features=datasets.Features(
65
+ {
66
+ "image": datasets.Image(decode=True, mode="I;16"),
67
+ "ra": datasets.Value("float64"),
68
+ "dec": datasets.Value("float64"),
69
+ "pixscale": datasets.Value("float64"),
70
+ "image_id": datasets.Value("string"),
71
+ }
72
+ ),
73
+ supervised_keys=None,
74
+ homepage=_HOMEPAGE,
75
+ license=_LICENSE,
76
+ citation="TBD",
77
+ )
78
+
79
+ def _split_generators(self, dl_manager: DownloadManager):
80
+
81
+ ret = []
82
+ base_path = dl_manager._base_path
83
+ locally_run = not base_path.startswith(datasets.config.HF_ENDPOINT)
84
+ _, path = url_to_fs(base_path)
85
+
86
+ for split in ["train", "test"]:
87
+ if locally_run:
88
+ split_file_location = os.path.normpath(
89
+ os.path.join(path, _URLS[self.config.name][split])
90
+ )
91
+ split_file = dl_manager.download_and_extract(split_file_location)
92
+ else:
93
+ split_file = hf_hub_download(
94
+ repo_id=_REPO_ID,
95
+ filename=_URLS[self.config.name][split],
96
+ repo_type="dataset",
97
+ )
98
+ with open(split_file, encoding="utf-8") as f:
99
+ data_filenames = []
100
+ data_metadata = []
101
+ for line in f:
102
+ item = json.loads(line)
103
+ data_filenames.append(item["image"])
104
+ data_metadata.append(
105
+ {
106
+ "ra": item["ra"],
107
+ "dec": item["dec"],
108
+ "pixscale": item["pixscale"],
109
+ "image_id": item["image_id"],
110
+ }
111
+ )
112
+ if locally_run:
113
+ data_urls = [
114
+ os.path.normpath(os.path.join(path, data_filename))
115
+ for data_filename in data_filenames
116
+ ]
117
+ data_files = [
118
+ dl_manager.download(data_url) for data_url in data_urls
119
+ ]
120
+ else:
121
+ data_urls = data_filenames
122
+ data_files = [
123
+ hf_hub_download(
124
+ repo_id=_REPO_ID, filename=data_url, repo_type="dataset"
125
+ )
126
+ for data_url in data_urls
127
+ ]
128
+ ret.append(
129
+ datasets.SplitGenerator(
130
+ name=(
131
+ datasets.Split.TRAIN
132
+ if split == "train"
133
+ else datasets.Split.TEST
134
+ ),
135
+ gen_kwargs={
136
+ "filepaths": data_files,
137
+ "split_file": split_file,
138
+ "split": split,
139
+ "data_metadata": data_metadata,
140
+ },
141
+ ),
142
+ )
143
+ return ret
144
+
145
+ def _generate_examples(self, filepaths, split_file, split, data_metadata):
146
+ """Generate SBI-16-2D examples"""
147
+
148
+ for idx, (filepath, item) in enumerate(zip(filepaths, data_metadata)):
149
+ with fits.open(filepath, memmap=False) as hdul:
150
+ # Process image data from HDU index 1
151
+ image_data_1 = hdul[1].data[:, :].tolist()
152
+ task_instance_key_1 = f"{self.config.name}-{split}-{idx}-HDU1"
153
+ yield task_instance_key_1, {**{"image": image_data_1}, **item}
154
+
155
+ # Process image data from HDU index 4
156
+ image_data_4 = hdul[4].data[:, :].tolist()
157
+ task_instance_key_4 = f"{self.config.name}-{split}-{idx}-HDU4"
158
+ yield task_instance_key_4, {**{"image": image_data_4}, **item}
baseline_results_2d.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/.gitattributes ADDED
The diff for this file is too large to render. See raw diff
 
data/j6la01umq_raw.fits ADDED

Git LFS Details

  • SHA256: c0b51605881dee519b50cdba9aac19b6116ab9dfe0b7e0eed2ffa99d2d940355
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j6lk02wkq_raw.fits ADDED

Git LFS Details

  • SHA256: 59ec3fbfe1379414dd4742f69f71aeff49be3cc3dffb526ae737a95a00324c0b
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j6mf10a2q_raw.fits ADDED

Git LFS Details

  • SHA256: ce66a52a85be83330900f5c87d3b79792d74e8bdaf87843d9318f242730cb848
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j6mf19qdq_raw.fits ADDED

Git LFS Details

  • SHA256: 1b3d940081ac219ba8d5fe8666b5879d326e66a74d99998c8f68bf68211880a9
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8c480meq_raw.fits ADDED

Git LFS Details

  • SHA256: f0b081f52ba1677c82f21bf0d28962135c50a6d53e33c9a5a637b6c89c00045d
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8d101e8q_raw.fits ADDED

Git LFS Details

  • SHA256: b013ee83b49be8afc2d31f7de3eee649ed59b4e690fb1a0c5c32e65a732df4e0
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8d102thq_raw.fits ADDED

Git LFS Details

  • SHA256: 26ff3cbb4fbeda2a9acef8b22b050b66dd011ed2eb6746cb84e65d566e77e757
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8d103qyq_raw.fits ADDED

Git LFS Details

  • SHA256: 74af33bbea5710e5e2bd7317f292bead37160f368178830baa2fafa1a2cd7c6f
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8d320evq_raw.fits ADDED

Git LFS Details

  • SHA256: 16858d08f8ca6584e421f1e75385c67500466cc6e5012c178f84a8f34085363a
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8d501rpq_raw.fits ADDED

Git LFS Details

  • SHA256: 4a09bfb309799db80abd73f05d96b04792192d2726a2a9b2ec8e93c2ba1a8ba3
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8db01khq_raw.fits ADDED

Git LFS Details

  • SHA256: f9c673e4240b76a5ef9cd3afdc7d99be260254cccf96706ee759271373753995
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8db02qfq_raw.fits ADDED

Git LFS Details

  • SHA256: 9a16cc447583321488d421b0df3a6ec356b60cb70efe9a50f3cf94100517917e
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8db03leq_raw.fits ADDED

Git LFS Details

  • SHA256: 18d0d6d1e4f6ab7fa6ed8b81a209bf2069a225507ce2c66ac3317c376e91cfc5
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8db04a1q_raw.fits ADDED

Git LFS Details

  • SHA256: 00d994ce646b3902eb5cfd0be07b900acc67bac027d16f38d51498676175c442
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8db05xeq_raw.fits ADDED

Git LFS Details

  • SHA256: 0dee6133eeea4b43fa4dba28516aa01da6cab072f30fff1d04aca81cbb28b22c
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8db06wlq_raw.fits ADDED

Git LFS Details

  • SHA256: e49d322e0ddcc33a6384396ba07d6d924bcd93e2d6a7c18e4beabec4dc310b98
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8db07zaq_raw.fits ADDED

Git LFS Details

  • SHA256: 8c19dda4576fd6ce0909819e457f78fc05df5172bfab71c9509f308ee6faaf06
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8db08leq_raw.fits ADDED

Git LFS Details

  • SHA256: 14bcbff50e9ae071f6b11db1fce862c199f8e02ff39b571d73ed76134a0c4bb3
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8db09dnq_raw.fits ADDED

Git LFS Details

  • SHA256: b4566635b2cc0a6ac6fad412f02b1ce97a1c41fab60c7298a94536c38b55ad4a
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8db10mrq_raw.fits ADDED

Git LFS Details

  • SHA256: 571ab6fd08e3ef2e0344593756f835774d7e2b87b23459518526e8b4cd5cff72
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8db12h7q_raw.fits ADDED

Git LFS Details

  • SHA256: 70a9ed207b41f1df328337d7d670f9c730b5f777effce182d4582135c23298d7
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8dd01fsq_raw.fits ADDED

Git LFS Details

  • SHA256: 386580e6b8e80c182c2ff6dacdd415c94e3b5449d13c5db6e50f3d4f60c086bf
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8de41awq_raw.fits ADDED

Git LFS Details

  • SHA256: 4383d7ca17be852dbe63b647b53d2b5113850194870947cb086615541e28d3ea
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di26r5q_raw.fits ADDED

Git LFS Details

  • SHA256: 0922748edfb58d0b4441488ab5d35343ff49af62f4d1fac587b71dee2533c8a5
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di53ucq_raw.fits ADDED

Git LFS Details

  • SHA256: 1d25adf7b8f7dcdca79c150459e7ac1c19a5dfff223f711f5860b81736d5ddbe
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di54maq_raw.fits ADDED

Git LFS Details

  • SHA256: 30493cd6168eeb00f3b638a0bf2a398d6038f81b8144b4a5cc58e90caeda9858
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di56vvq_raw.fits ADDED

Git LFS Details

  • SHA256: d03f1ee2474fd1a7bd72f7908e0210422fa85fbe7e29e7a5c9ef121f0be6404c
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di59myq_raw.fits ADDED

Git LFS Details

  • SHA256: 748ce12dc684b31ea542490ef68e38d4682147a640aa09163742d95fc0b8d255
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di63raq_raw.fits ADDED

Git LFS Details

  • SHA256: 5c5f8dc82e2d1a62a64c359994e6c5efc46545032dc5dd643c16239f50e099df
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di66vrq_raw.fits ADDED

Git LFS Details

  • SHA256: 4aa79128d9586c2308888296cef331a3578d8a3a277e67665d2232543757917d
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di67a2q_raw.fits ADDED

Git LFS Details

  • SHA256: 7614e19b0734b7e99fc95ffcfa116946bfff7b754427549d77888972429ba198
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di68oaq_raw.fits ADDED

Git LFS Details

  • SHA256: c01ab8804120b6925695d4bf38c732fc512ffbf7906825a9c58dd451914be9f7
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di69naq_raw.fits ADDED

Git LFS Details

  • SHA256: c0b99c05999fcfbb643ccf8f662e9fcf0ee0ba1343df7ec4ced9dfc3f8b2bd25
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di70idq_raw.fits ADDED

Git LFS Details

  • SHA256: b1f2825bd8d3eff61e9d5717159de0acb5438c7b8061f9fca3c2f24cbe99937c
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di71bhq_raw.fits ADDED

Git LFS Details

  • SHA256: 1bc4311bee25d09f9dbf6600691f1c94815e5f2e8db5bfb461e49e9161d762d7
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di72uqq_raw.fits ADDED

Git LFS Details

  • SHA256: cf2c0622da99d3db21cd9c28250bf8a5e40b8644e91170475c6b4e2407f24632
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di73anq_raw.fits ADDED

Git LFS Details

  • SHA256: 155b98acaeb7ae08f9814efa614818274895c2607a7bec96e0135808538f5cb4
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di74r0q_raw.fits ADDED

Git LFS Details

  • SHA256: 0bcc5d56537b5cf9171ec5d1bc3b8cc59ae6ff859dda4d46f430bb7bddf7c3b0
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di75jcq_raw.fits ADDED

Git LFS Details

  • SHA256: de5f2f25381a5e719862100144b9c2b7d40e2ae229a20017748c7cb72d1548ab
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di77guq_raw.fits ADDED

Git LFS Details

  • SHA256: 3b71789633b4715e79a19816d99b659906dd0623842b40f80accec0cca581893
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di89dmq_raw.fits ADDED

Git LFS Details

  • SHA256: 0693ff198c5137d25e9c58f5d42a0bb7f2b3c24223eb3accd304bc4381cf6628
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di91q3q_raw.fits ADDED

Git LFS Details

  • SHA256: 06eca9d0c3408848db50d9434a57f81a728ae510a71be1fb2c3ee2a3790ee4b0
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di93sfq_raw.fits ADDED

Git LFS Details

  • SHA256: 5637b197baf12d769b5d7a89795052b3345f58a018fbd6ae01b49e364c39c47d
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8di98mqq_raw.fits ADDED

Git LFS Details

  • SHA256: 891046ff1179775372f5b5cb02de14250374b419fc75ccf0850eeaefcb4e0281
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB
data/j8dt07udq_raw.fits ADDED

Git LFS Details

  • SHA256: ba38954308301da8d0cf0222553eacc77ce634a0582c0d6de20051805c7584e1
  • Pointer size: 133 Bytes
  • Size of remote file: 34.3 MB