Convert dataset to Parquet (#1)
Browse files- Convert dataset to Parquet (fb243e84df52059ade357368a0d5468ee990530d)
- Delete loading script auxiliary file (4ca7b0afd58ab2c6244f2b873f0ef4ac74f4fa32)
- Delete data file (26e319b7cb616f5310b458604cbc6028ed04e0c3)
- Delete data file (5f64b085b249011ede972ffa312bbd33a3973975)
- Delete data file (3f5787e7fe9c9cb7ed2c3ce2f2fb314427041184)
- Delete data file (8c592518fae8f44b6bc8d50b1406bb96e0048b1a)
- Delete data file (71547c41aa162ac9fa54fab78796053eea20372c)
- README.md +15 -0
- images/frame_0a1d5ccc-e1c7-4c66-8fbc-f87080c3f408_0046.png → data/train-00000-of-00001.parquet +2 -2
- image_dataset.py +0 -95
- images/frame_0a0ab072-9729-4e16-88c5-a3ea9ed959d0_0036.png +0 -3
- images/frame_0a0bf5c3-9ee4-41aa-9298-ccfebdb1b5ea_0029.png +0 -3
- images/frame_0a1d30e1-d358-4533-a192-75c5c86a2d56_0049.png +0 -3
- metadata.json +0 -18
README.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
+
configs:
|
| 4 |
+
- config_name: default
|
| 5 |
+
data_files:
|
| 6 |
+
- split: train
|
| 7 |
+
path: data/train-*
|
| 8 |
+
dataset_info:
|
| 9 |
+
features:
|
| 10 |
+
- name: image
|
| 11 |
+
dtype: image
|
| 12 |
+
splits:
|
| 13 |
+
- name: train
|
| 14 |
+
num_bytes: 4454294.0
|
| 15 |
+
num_examples: 4
|
| 16 |
+
download_size: 4456047
|
| 17 |
+
dataset_size: 4454294.0
|
| 18 |
---
|
images/frame_0a1d5ccc-e1c7-4c66-8fbc-f87080c3f408_0046.png → data/train-00000-of-00001.parquet
RENAMED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:641d36a565ab641a5be9eba5019f1a0dd0f5f5771bbbf4e6c66cbe1a059daf15
|
| 3 |
+
size 4456047
|
image_dataset.py
DELETED
|
@@ -1,95 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import json
|
| 3 |
-
import random
|
| 4 |
-
from datasets import (
|
| 5 |
-
BuilderConfig,
|
| 6 |
-
DatasetInfo,
|
| 7 |
-
DownloadManager,
|
| 8 |
-
GeneratorBasedBuilder,
|
| 9 |
-
SplitGenerator,
|
| 10 |
-
Split,
|
| 11 |
-
Features,
|
| 12 |
-
Image,
|
| 13 |
-
Sequence,
|
| 14 |
-
Value,
|
| 15 |
-
)
|
| 16 |
-
|
| 17 |
-
class ImageSubsetConfig(BuilderConfig):
|
| 18 |
-
"""BuilderConfig for small vs. full dataset."""
|
| 19 |
-
def __init__(self, name, sample_size=None, **kwargs):
|
| 20 |
-
super().__init__(
|
| 21 |
-
name=name,
|
| 22 |
-
version="1.0.0",
|
| 23 |
-
description=kwargs.get("description", "")
|
| 24 |
-
)
|
| 25 |
-
self.sample_size = sample_size
|
| 26 |
-
|
| 27 |
-
class MyImageDataset(GeneratorBasedBuilder):
|
| 28 |
-
"""A dataset of images with actuated_angle from metadata.json."""
|
| 29 |
-
BUILDER_CONFIGS = [
|
| 30 |
-
ImageSubsetConfig(
|
| 31 |
-
name="full",
|
| 32 |
-
sample_size=None,
|
| 33 |
-
description="All images (≈100 GB). Use with streaming=True."
|
| 34 |
-
),
|
| 35 |
-
ImageSubsetConfig(
|
| 36 |
-
name="small",
|
| 37 |
-
sample_size=2,
|
| 38 |
-
description="Random subset of 10 000 images for quick iteration."
|
| 39 |
-
),
|
| 40 |
-
]
|
| 41 |
-
DEFAULT_CONFIG_NAME = "smgit all"
|
| 42 |
-
|
| 43 |
-
def _info(self):
|
| 44 |
-
return DatasetInfo(
|
| 45 |
-
description="Images with a 2-D actuated_angle from metadata.json",
|
| 46 |
-
features=Features({
|
| 47 |
-
"image": Image(), # the image file
|
| 48 |
-
"actuated_angle": Sequence(Value("int32")), # [angle0, angle1]
|
| 49 |
-
}),
|
| 50 |
-
supervised_keys=None,
|
| 51 |
-
)
|
| 52 |
-
|
| 53 |
-
def _split_generators(self, dl_manager: DownloadManager):
|
| 54 |
-
data_dir = dl_manager.manual_dir or os.path.abspath(os.path.dirname(__file__))
|
| 55 |
-
images_dir = os.path.join(data_dir, "images")
|
| 56 |
-
meta_path = os.path.join(data_dir, "metadata.json")
|
| 57 |
-
|
| 58 |
-
# load your filename → {"0":…, "1":…} mapping
|
| 59 |
-
with open(meta_path, "r", encoding="utf-8") as f:
|
| 60 |
-
metadata = json.load(f)
|
| 61 |
-
|
| 62 |
-
# sample if in "small" config
|
| 63 |
-
if self.config.sample_size:
|
| 64 |
-
all_fnames = list(metadata.keys())
|
| 65 |
-
random.seed(42)
|
| 66 |
-
selected = set(random.sample(all_fnames, self.config.sample_size))
|
| 67 |
-
else:
|
| 68 |
-
selected = set(metadata.keys())
|
| 69 |
-
|
| 70 |
-
return [
|
| 71 |
-
SplitGenerator(
|
| 72 |
-
name=Split.TRAIN,
|
| 73 |
-
gen_kwargs={
|
| 74 |
-
"images_dir": images_dir,
|
| 75 |
-
"metadata": metadata,
|
| 76 |
-
"selected": selected,
|
| 77 |
-
},
|
| 78 |
-
),
|
| 79 |
-
]
|
| 80 |
-
|
| 81 |
-
def _generate_examples(self, images_dir, metadata, selected):
|
| 82 |
-
"""Yields examples of the form { "image": path, "actuated_angle": [int, int] }"""
|
| 83 |
-
for idx, fname in enumerate(selected):
|
| 84 |
-
if fname not in metadata:
|
| 85 |
-
continue
|
| 86 |
-
image_path = os.path.join(images_dir, fname)
|
| 87 |
-
if not os.path.exists(image_path):
|
| 88 |
-
continue
|
| 89 |
-
meta = metadata[fname]
|
| 90 |
-
# extract the two angle values (keys "0" and "1")
|
| 91 |
-
angles = [ int(meta.get("0", 0)), int(meta.get("1", 0)) ]
|
| 92 |
-
yield idx, {
|
| 93 |
-
"image": image_path,
|
| 94 |
-
"actuated_angle": angles,
|
| 95 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
images/frame_0a0ab072-9729-4e16-88c5-a3ea9ed959d0_0036.png
DELETED
Git LFS Details
|
images/frame_0a0bf5c3-9ee4-41aa-9298-ccfebdb1b5ea_0029.png
DELETED
Git LFS Details
|
images/frame_0a1d30e1-d358-4533-a192-75c5c86a2d56_0049.png
DELETED
Git LFS Details
|
metadata.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"frame_0a0ab072-9729-4e16-88c5-a3ea9ed959d0_0036.png": {
|
| 3 |
-
"0": 90,
|
| 4 |
-
"1": 20
|
| 5 |
-
},
|
| 6 |
-
"frame_0a1d5ccc-e1c7-4c66-8fbc-f87080c3f408_0046.png": {
|
| 7 |
-
"0": 90,
|
| 8 |
-
"1": 20
|
| 9 |
-
},
|
| 10 |
-
"frame_0a1d30e1-d358-4533-a192-75c5c86a2d56_0049.png": {
|
| 11 |
-
"0": 90,
|
| 12 |
-
"1": 20
|
| 13 |
-
},
|
| 14 |
-
"frame_0a0bf5c3-9ee4-41aa-9298-ccfebdb1b5ea_0029.png": {
|
| 15 |
-
"0": 90,
|
| 16 |
-
"1": 20
|
| 17 |
-
}
|
| 18 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|