Convert dataset to Parquet

#1
OpenHumnoidDataset.py DELETED
@@ -1,117 +0,0 @@
1
- # TestNew.py
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
- from huggingface_hub import hf_hub_url
17
-
18
-
19
- _REPO_ID = "iamirulofficial/OpenHumnoidDataset" # change if you ever fork the repo
20
-
21
-
22
- class ImageSubsetConfig(BuilderConfig):
23
- """BuilderConfig for full dataset vs. small random sample."""
24
- def __init__(self, name, sample_size=None, **kwargs):
25
- super().__init__(
26
- name=name,
27
- version="1.0.1",
28
- description=kwargs.get("description", "")
29
- )
30
- self.sample_size = sample_size
31
-
32
-
33
- class MyImageDataset(GeneratorBasedBuilder):
34
- """Images + 2‑D actuated_angle labels stored in metadata.json."""
35
- BUILDER_CONFIGS = [
36
- ImageSubsetConfig(
37
- name="full",
38
- sample_size=None, # all images
39
- description="Entire dataset (≈100 GB)"
40
- ),
41
- ImageSubsetConfig(
42
- name="small",
43
- sample_size=2, # tiny sample for quick tests
44
- description="Two random images"
45
- ),
46
- ]
47
- DEFAULT_CONFIG_NAME = "small"
48
-
49
- def _info(self) -> DatasetInfo:
50
- return DatasetInfo(
51
- description="Images with a 2‑D actuated_angle from metadata.json",
52
- features=Features(
53
- {
54
- "image": Image(), # PIL.Image will be returned
55
- "actuated_angle": {
56
- "0": Value("int32"),
57
- "1": Value("int32"),
58
- }, # [angle0, angle1]
59
- }
60
- ),
61
- supervised_keys=None,
62
- )
63
-
64
- # --------------------------------------------------------------------- #
65
- # Download phase #
66
- # --------------------------------------------------------------------- #
67
- def _split_generators(self, dl_manager: DownloadManager):
68
- # 1️⃣ Download metadata.json (tiny text file)
69
- meta_path = dl_manager.download(
70
- hf_hub_url(_REPO_ID, "metadata.json", repo_type="dataset")
71
- )
72
-
73
- # 2️⃣ Decide which filenames we need
74
- with open(meta_path, encoding="utf-8") as f:
75
- metadata = json.load(f) # {"frame_000.png": {"0":…, …}, …}
76
-
77
- all_fnames = list(metadata)
78
- if self.config.sample_size: # small‑config branch
79
- random.seed(42)
80
- selected = sorted(random.sample(all_fnames, self.config.sample_size))
81
- else:
82
- selected = sorted(all_fnames) # full dataset
83
-
84
- # 3️⃣ Build URLs → dl_manager.download() → local paths
85
- url_dict = {
86
- fname: hf_hub_url(
87
- _REPO_ID, f"images/{fname}", repo_type="dataset"
88
- )
89
- for fname in selected
90
- }
91
- img_paths = dl_manager.download(url_dict) # same keys, but local files
92
-
93
- return [
94
- SplitGenerator(
95
- name=Split.TRAIN,
96
- gen_kwargs={
97
- "img_paths": img_paths,
98
- "metadata": metadata,
99
- },
100
- )
101
- ]
102
-
103
- # --------------------------------------------------------------------- #
104
- # Generate examples #
105
- # --------------------------------------------------------------------- #
106
- def _generate_examples(self, img_paths: dict, metadata: dict):
107
- """
108
- Yields (key, example) where example =
109
- { "image": <local‑file‑path>, "actuated_angle": [int, int] }
110
- """
111
- for idx, (fname, local_path) in enumerate(img_paths.items()):
112
- meta = metadata.get(fname, {})
113
- angles = [int(meta.get("0", 0)), int(meta.get("1", 0))]
114
- yield idx, {"image": local_path, "actuated_angle": { # 👈 dict, not list
115
- "0": int(meta.get("0", 0)),
116
- "1": int(meta.get("1", 0)),
117
- }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ dataset_info:
3
+ - config_name: full
4
+ features:
5
+ - name: image
6
+ dtype: image
7
+ - name: actuated_angle
8
+ struct:
9
+ - name: '0'
10
+ dtype: int32
11
+ - name: '1'
12
+ dtype: int32
13
+ splits:
14
+ - name: train
15
+ num_bytes: 5561715.0
16
+ num_examples: 5
17
+ download_size: 5564574
18
+ dataset_size: 5561715.0
19
+ - config_name: small
20
+ features:
21
+ - name: image
22
+ dtype: image
23
+ - name: actuated_angle
24
+ struct:
25
+ - name: '0'
26
+ dtype: int32
27
+ - name: '1'
28
+ dtype: int32
29
+ splits:
30
+ - name: train
31
+ num_bytes: 2219188.0
32
+ num_examples: 2
33
+ download_size: 2221784
34
+ dataset_size: 2219188.0
35
+ configs:
36
+ - config_name: full
37
+ data_files:
38
+ - split: train
39
+ path: full/train-*
40
+ - config_name: small
41
+ data_files:
42
+ - split: train
43
+ path: small/train-*
44
+ default: true
45
+ ---
images/frame_0a1d5ccc-e1c7-4c66-8fbc-f87080c3f408_0046.png → full/train-00000-of-00001.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:6a0470866fd6b60d1d16f3dbaca1c81a52f21148899d3b6b2a44c034331e5822
3
- size 1117345
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e84d1682965461198ddb5968642539dcd34681c85797688a30b10448f6a0f914
3
+ size 5564574
images/frame_0a0bf5c3-9ee4-41aa-9298-ccfebdb1b5ea_0029.png DELETED

Git LFS Details

  • SHA256: 2dbebca5a8815a7d56670df0b1af2c1138c46235623c0086d30101a4f5f80401
  • Pointer size: 132 Bytes
  • Size of remote file: 1.11 MB
images/frame_0a1d30e1-d358-4533-a192-75c5c86a2d56_0049.png DELETED

Git LFS Details

  • SHA256: 0a84cfa938625d0ed18586b59b11378adb3a03f01a76b1538907509ee0bb78e1
  • Pointer size: 132 Bytes
  • Size of remote file: 1.11 MB
images/frame_0a9d926d-9372-47d6-b54f-514996ed504c_0017.png DELETED

Git LFS Details

  • SHA256: 390d71bcff37b938aab1577e196299840ffbd64e8cf1d694bbfa4dd243890534
  • Pointer size: 132 Bytes
  • Size of remote file: 1.11 MB
metadata.json DELETED
@@ -1,22 +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
- "frame_0a9d926d-9372-47d6-b54f-514996ed504c_0017.png":{
19
- "0":90,
20
- "2":20
21
- }
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
images/frame_0a0ab072-9729-4e16-88c5-a3ea9ed959d0_0036.png → small/train-00000-of-00001.parquet RENAMED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:0e4d31d882451f8c48d66459ab0c69953d9766b48f7543b7b2662fb62bd80786
3
- size 1111786
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e7e9fa669c9fd159899648d695cf7819196586e5951a6d172d95321bad888c19
3
+ size 2221784