anonuser7251
commited on
Commit
•
aaad474
1
Parent(s):
5d06e72
Add dataset
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +1 -0
- README.md +83 -0
- SBI-16-2D.py +158 -0
- baseline_results_2d.csv +0 -0
- data/.gitattributes +0 -0
- data/j6la01umq_raw.fits +3 -0
- data/j6lk02wkq_raw.fits +3 -0
- data/j6mf10a2q_raw.fits +3 -0
- data/j6mf19qdq_raw.fits +3 -0
- data/j8c480meq_raw.fits +3 -0
- data/j8d101e8q_raw.fits +3 -0
- data/j8d102thq_raw.fits +3 -0
- data/j8d103qyq_raw.fits +3 -0
- data/j8d320evq_raw.fits +3 -0
- data/j8d501rpq_raw.fits +3 -0
- data/j8db01khq_raw.fits +3 -0
- data/j8db02qfq_raw.fits +3 -0
- data/j8db03leq_raw.fits +3 -0
- data/j8db04a1q_raw.fits +3 -0
- data/j8db05xeq_raw.fits +3 -0
- data/j8db06wlq_raw.fits +3 -0
- data/j8db07zaq_raw.fits +3 -0
- data/j8db08leq_raw.fits +3 -0
- data/j8db09dnq_raw.fits +3 -0
- data/j8db10mrq_raw.fits +3 -0
- data/j8db12h7q_raw.fits +3 -0
- data/j8dd01fsq_raw.fits +3 -0
- data/j8de41awq_raw.fits +3 -0
- data/j8di26r5q_raw.fits +3 -0
- data/j8di53ucq_raw.fits +3 -0
- data/j8di54maq_raw.fits +3 -0
- data/j8di56vvq_raw.fits +3 -0
- data/j8di59myq_raw.fits +3 -0
- data/j8di63raq_raw.fits +3 -0
- data/j8di66vrq_raw.fits +3 -0
- data/j8di67a2q_raw.fits +3 -0
- data/j8di68oaq_raw.fits +3 -0
- data/j8di69naq_raw.fits +3 -0
- data/j8di70idq_raw.fits +3 -0
- data/j8di71bhq_raw.fits +3 -0
- data/j8di72uqq_raw.fits +3 -0
- data/j8di73anq_raw.fits +3 -0
- data/j8di74r0q_raw.fits +3 -0
- data/j8di75jcq_raw.fits +3 -0
- data/j8di77guq_raw.fits +3 -0
- data/j8di89dmq_raw.fits +3 -0
- data/j8di91q3q_raw.fits +3 -0
- data/j8di93sfq_raw.fits +3 -0
- data/j8di98mqq_raw.fits +3 -0
- data/j8dt07udq_raw.fits +3 -0
.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
|
data/j6lk02wkq_raw.fits
ADDED
Git LFS Details
|
data/j6mf10a2q_raw.fits
ADDED
Git LFS Details
|
data/j6mf19qdq_raw.fits
ADDED
Git LFS Details
|
data/j8c480meq_raw.fits
ADDED
Git LFS Details
|
data/j8d101e8q_raw.fits
ADDED
Git LFS Details
|
data/j8d102thq_raw.fits
ADDED
Git LFS Details
|
data/j8d103qyq_raw.fits
ADDED
Git LFS Details
|
data/j8d320evq_raw.fits
ADDED
Git LFS Details
|
data/j8d501rpq_raw.fits
ADDED
Git LFS Details
|
data/j8db01khq_raw.fits
ADDED
Git LFS Details
|
data/j8db02qfq_raw.fits
ADDED
Git LFS Details
|
data/j8db03leq_raw.fits
ADDED
Git LFS Details
|
data/j8db04a1q_raw.fits
ADDED
Git LFS Details
|
data/j8db05xeq_raw.fits
ADDED
Git LFS Details
|
data/j8db06wlq_raw.fits
ADDED
Git LFS Details
|
data/j8db07zaq_raw.fits
ADDED
Git LFS Details
|
data/j8db08leq_raw.fits
ADDED
Git LFS Details
|
data/j8db09dnq_raw.fits
ADDED
Git LFS Details
|
data/j8db10mrq_raw.fits
ADDED
Git LFS Details
|
data/j8db12h7q_raw.fits
ADDED
Git LFS Details
|
data/j8dd01fsq_raw.fits
ADDED
Git LFS Details
|
data/j8de41awq_raw.fits
ADDED
Git LFS Details
|
data/j8di26r5q_raw.fits
ADDED
Git LFS Details
|
data/j8di53ucq_raw.fits
ADDED
Git LFS Details
|
data/j8di54maq_raw.fits
ADDED
Git LFS Details
|
data/j8di56vvq_raw.fits
ADDED
Git LFS Details
|
data/j8di59myq_raw.fits
ADDED
Git LFS Details
|
data/j8di63raq_raw.fits
ADDED
Git LFS Details
|
data/j8di66vrq_raw.fits
ADDED
Git LFS Details
|
data/j8di67a2q_raw.fits
ADDED
Git LFS Details
|
data/j8di68oaq_raw.fits
ADDED
Git LFS Details
|
data/j8di69naq_raw.fits
ADDED
Git LFS Details
|
data/j8di70idq_raw.fits
ADDED
Git LFS Details
|
data/j8di71bhq_raw.fits
ADDED
Git LFS Details
|
data/j8di72uqq_raw.fits
ADDED
Git LFS Details
|
data/j8di73anq_raw.fits
ADDED
Git LFS Details
|
data/j8di74r0q_raw.fits
ADDED
Git LFS Details
|
data/j8di75jcq_raw.fits
ADDED
Git LFS Details
|
data/j8di77guq_raw.fits
ADDED
Git LFS Details
|
data/j8di89dmq_raw.fits
ADDED
Git LFS Details
|
data/j8di91q3q_raw.fits
ADDED
Git LFS Details
|
data/j8di93sfq_raw.fits
ADDED
Git LFS Details
|
data/j8di98mqq_raw.fits
ADDED
Git LFS Details
|
data/j8dt07udq_raw.fits
ADDED
Git LFS Details
|