simplexsigil commited on
Commit
fb6ba11
·
1 Parent(s): 08c9177

Added reference to companion package

Browse files
README.md CHANGED
@@ -26,6 +26,10 @@ configs:
26
  data_files:
27
  - split: train
28
  path: parquet/metadata-syn/train-*.parquet
 
 
 
 
29
  - config_name: of-sta-cs
30
  data_files:
31
  - split: train
@@ -505,6 +509,136 @@ dataset_info:
505
  - name: train
506
  num_bytes: 0
507
  num_examples: 12000
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
508
  - config_name: of-sta-cs
509
  features:
510
  - name: path
@@ -2115,7 +2249,7 @@ All configurations are loaded via `load_dataset("simplexsigil2/omnifall", "<conf
2115
  - `labels` (default): All staged + OOPS labels (52k segments, 7 columns)
2116
  - `labels-syn`: OF-Syn labels with demographic metadata (19k segments, 19 columns)
2117
  - `metadata-syn`: OF-Syn video-level metadata (12k videos)
2118
- - `framewise-syn`: OF-Syn frame-wise HDF5 labels (81 labels per video). **Requires the `omnifall` package (coming soon).**
2119
 
2120
  ### OF-Staged Configs
2121
  - `of-sta-cs`: 8 staged datasets, cross-subject splits
@@ -2124,7 +2258,7 @@ All configurations are loaded via `load_dataset("simplexsigil2/omnifall", "<conf
2124
  ### OF-ItW Config
2125
  - `of-itw`: OOPS-Fall in-the-wild genuine accidents
2126
 
2127
- Video loading requires the `omnifall` package (coming soon). See examples below.
2128
 
2129
  ### OF-Syn Configs
2130
  - `of-syn`: Fixed randomized 80/10/10 split
@@ -2132,7 +2266,7 @@ Video loading requires the `omnifall` package (coming soon). See examples below.
2132
  - `of-syn-cross-ethnicity`: Cross-ethnicity split
2133
  - `of-syn-cross-bmi`: Cross-BMI split (train: normal/underweight, test: obese)
2134
 
2135
- Video loading for OF-Syn configs requires the `omnifall` package (coming soon).
2136
 
2137
  ### Cross-Domain Evaluation
2138
  - `of-sta-itw-cs`: Train/val on staged CS, test on OOPS
@@ -2192,15 +2326,46 @@ syn_labels = load_dataset("simplexsigil2/omnifall", "labels-syn")["train"]
2192
 
2193
  ### Loading Videos
2194
 
2195
- Video loading (OF-Syn, OF-ItW, and cross-domain configs) requires the `omnifall` Python package, which will be available on PyPI soon. The package handles video download, caching, and integration with HuggingFace datasets.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2196
 
2197
- For OOPS videos specifically, you can prepare them manually using the included script:
 
 
 
 
 
 
 
 
 
 
2198
 
2199
  ```bash
 
 
 
 
2200
  python prepare_oops_videos.py --output_dir /path/to/oops_prepared
2201
  ```
2202
 
2203
- The preparation streams the full OOPS archive from the original source and extracts only the 818 videos used in OF-ItW. The archive is streamed and never written to disk, so only ~2.6GB of disk space is needed. If you already have the OOPS archive downloaded locally, pass it with `--oops_archive /path/to/video_and_anns.tar.gz`.
2204
 
2205
  ## Label definitions
2206
 
 
26
  data_files:
27
  - split: train
28
  path: parquet/metadata-syn/train-*.parquet
29
+ - config_name: framewise-syn
30
+ data_files:
31
+ - split: train
32
+ path: parquet/framewise-syn/train-*.parquet
33
  - config_name: of-sta-cs
34
  data_files:
35
  - split: train
 
509
  - name: train
510
  num_bytes: 0
511
  num_examples: 12000
512
+ - config_name: framewise-syn
513
+ features:
514
+ - name: path
515
+ dtype: string
516
+ - name: dataset
517
+ dtype: string
518
+ - name: frame_labels
519
+ sequence:
520
+ dtype:
521
+ class_label:
522
+ names:
523
+ '0': walk
524
+ '1': fall
525
+ '2': fallen
526
+ '3': sit_down
527
+ '4': sitting
528
+ '5': lie_down
529
+ '6': lying
530
+ '7': stand_up
531
+ '8': standing
532
+ '9': other
533
+ '10': kneel_down
534
+ '11': kneeling
535
+ '12': squat_down
536
+ '13': squatting
537
+ '14': crawl
538
+ '15': jump
539
+ length: 81
540
+ - name: age_group
541
+ dtype:
542
+ class_label:
543
+ names:
544
+ '0': toddlers_1_4
545
+ '1': children_5_12
546
+ '2': teenagers_13_17
547
+ '3': young_adults_18_34
548
+ '4': middle_aged_35_64
549
+ '5': elderly_65_plus
550
+ - name: gender_presentation
551
+ dtype:
552
+ class_label:
553
+ names:
554
+ '0': male
555
+ '1': female
556
+ - name: monk_skin_tone
557
+ dtype:
558
+ class_label:
559
+ names:
560
+ '0': mst1
561
+ '1': mst2
562
+ '2': mst3
563
+ '3': mst4
564
+ '4': mst5
565
+ '5': mst6
566
+ '6': mst7
567
+ '7': mst8
568
+ '8': mst9
569
+ '9': mst10
570
+ - name: race_ethnicity_omb
571
+ dtype:
572
+ class_label:
573
+ names:
574
+ '0': white
575
+ '1': black
576
+ '2': asian
577
+ '3': hispanic_latino
578
+ '4': aian
579
+ '5': nhpi
580
+ '6': mena
581
+ - name: bmi_band
582
+ dtype:
583
+ class_label:
584
+ names:
585
+ '0': underweight
586
+ '1': normal
587
+ '2': overweight
588
+ '3': obese
589
+ - name: height_band
590
+ dtype:
591
+ class_label:
592
+ names:
593
+ '0': short
594
+ '1': avg
595
+ '2': tall
596
+ - name: environment_category
597
+ dtype:
598
+ class_label:
599
+ names:
600
+ '0': indoor
601
+ '1': outdoor
602
+ - name: camera_shot
603
+ dtype:
604
+ class_label:
605
+ names:
606
+ '0': static_wide
607
+ '1': static_medium_wide
608
+ - name: speed
609
+ dtype:
610
+ class_label:
611
+ names:
612
+ '0': 24fps_rt
613
+ '1': 25fps_rt
614
+ '2': 30fps_rt
615
+ '3': std_rt
616
+ - name: camera_elevation
617
+ dtype:
618
+ class_label:
619
+ names:
620
+ '0': eye
621
+ '1': low
622
+ '2': high
623
+ '3': top
624
+ - name: camera_azimuth
625
+ dtype:
626
+ class_label:
627
+ names:
628
+ '0': front
629
+ '1': rear
630
+ '2': left
631
+ '3': right
632
+ - name: camera_distance
633
+ dtype:
634
+ class_label:
635
+ names:
636
+ '0': medium
637
+ '1': far
638
+ splits:
639
+ - name: train
640
+ num_bytes: 0
641
+ num_examples: 12000
642
  - config_name: of-sta-cs
643
  features:
644
  - name: path
 
2249
  - `labels` (default): All staged + OOPS labels (52k segments, 7 columns)
2250
  - `labels-syn`: OF-Syn labels with demographic metadata (19k segments, 19 columns)
2251
  - `metadata-syn`: OF-Syn video-level metadata (12k videos)
2252
+ - `framewise-syn`: OF-Syn frame-wise labels (81 labels per video, from parquet)
2253
 
2254
  ### OF-Staged Configs
2255
  - `of-sta-cs`: 8 staged datasets, cross-subject splits
 
2258
  ### OF-ItW Config
2259
  - `of-itw`: OOPS-Fall in-the-wild genuine accidents
2260
 
2261
+ Video loading requires the `omnifall` companion package. See examples below.
2262
 
2263
  ### OF-Syn Configs
2264
  - `of-syn`: Fixed randomized 80/10/10 split
 
2266
  - `of-syn-cross-ethnicity`: Cross-ethnicity split
2267
  - `of-syn-cross-bmi`: Cross-BMI split (train: normal/underweight, test: obese)
2268
 
2269
+ Video loading for OF-Syn configs requires the `omnifall` companion package.
2270
 
2271
  ### Cross-Domain Evaluation
2272
  - `of-sta-itw-cs`: Train/val on staged CS, test on OOPS
 
2326
 
2327
  ### Loading Videos
2328
 
2329
+ Video loading requires the `omnifall` companion package (`pip install omnifall`), which handles video download, caching, and path resolution.
2330
+
2331
+ ```python
2332
+ import omnifall
2333
+
2334
+ # OF-Syn: videos are auto-downloaded from HF Hub (~9.1GB, cached)
2335
+ ds = omnifall.load("of-syn", video=True)
2336
+
2337
+ # OF-ItW: requires one-time OOPS video preparation (~45GB stream, ~2.6GB on disk)
2338
+ omnifall.prepare_oops() # interactive license consent
2339
+ ds = omnifall.load("of-itw", video=True)
2340
+
2341
+ # Cross-domain: syn videos for train/val, OOPS for test
2342
+ ds = omnifall.load("of-syn-itw", video=True)
2343
+
2344
+ # The video column contains absolute file paths (strings)
2345
+ print(ds["train"][0]["video"]) # /home/user/.cache/omnifall/of-syn-videos/fall/fall_to_001.mp4
2346
+ ```
2347
 
2348
+ The `video` column contains string paths rather than decoded video frames, since temporal segmentation tasks require frame-level control via PyAV or decord.
2349
+
2350
+ You can also add video paths to an already-loaded dataset:
2351
+
2352
+ ```python
2353
+ from datasets import load_dataset
2354
+ ds = load_dataset("simplexsigil2/omnifall", "of-syn")
2355
+ ds = omnifall.add_video(ds, config="of-syn")
2356
+ ```
2357
+
2358
+ OOPS videos can also be prepared via CLI or the standalone script:
2359
 
2360
  ```bash
2361
+ # Via omnifall CLI
2362
+ omnifall prepare-oops
2363
+
2364
+ # Via standalone script (alternative)
2365
  python prepare_oops_videos.py --output_dir /path/to/oops_prepared
2366
  ```
2367
 
2368
+ The preparation streams the full OOPS archive from the original source and extracts only the 818 videos used in OF-ItW. The archive is streamed and never written to disk, so only ~2.6GB of disk space is needed. If you already have the OOPS archive downloaded locally, pass it with `--oops-archive /path/to/video_and_anns.tar.gz`.
2369
 
2370
  ## Label definitions
2371
 
generate_parquet.py CHANGED
@@ -9,6 +9,9 @@ Usage:
9
  """
10
 
11
  import os
 
 
 
12
  from pathlib import Path
13
 
14
  import numpy as np
@@ -322,6 +325,75 @@ def gen_individual(ds_name):
322
  return {ds_name: results}
323
 
324
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
325
  # ---- Main ----
326
 
327
  def main():
@@ -332,7 +404,7 @@ def main():
332
 
333
  # Labels configs (single train split)
334
  print("\n--- Labels configs ---")
335
- for gen_fn in [gen_labels, gen_labels_syn, gen_metadata_syn]:
336
  result = gen_fn()
337
  all_results.update(result)
338
  for config, splits in result.items():
 
9
  """
10
 
11
  import os
12
+ import subprocess
13
+ import tarfile
14
+ import tempfile
15
  from pathlib import Path
16
 
17
  import numpy as np
 
325
  return {ds_name: results}
326
 
327
 
328
+ def gen_framewise_syn():
329
+ """Config: framewise-syn - OF-Syn frame-wise labels from HDF5, single train split.
330
+
331
+ Reads syn_frame_wise_labels.tar.zst (HDF5 files with 81 frame labels each),
332
+ merges with videos/metadata.csv for demographics, writes a single parquet.
333
+ Requires h5py at generation time only.
334
+ """
335
+ import h5py
336
+
337
+ archive_path = REPO_ROOT / "data_files" / "syn_frame_wise_labels.tar.zst"
338
+ if not archive_path.exists():
339
+ print(f" SKIP framewise-syn: archive not found at {archive_path}")
340
+ return {"framewise-syn": {}}
341
+
342
+ metadata_df = load_csv(METADATA_FILE)
343
+
344
+ metadata_fields = DEMOGRAPHIC_COLUMNS
345
+
346
+ rows = []
347
+
348
+ with tempfile.TemporaryDirectory() as tmpdir:
349
+ # Extract the .tar.zst archive (tarfile doesn't support zstd natively)
350
+ subprocess.run(
351
+ ["tar", "--zstd", "-xf", str(archive_path), "-C", tmpdir],
352
+ check=True,
353
+ )
354
+ tmppath = Path(tmpdir)
355
+ h5_files = sorted(tmppath.glob("**/*.h5"))
356
+ print(f" Found {len(h5_files)} HDF5 files in archive")
357
+
358
+ for h5_file_path in h5_files:
359
+ relative_path = h5_file_path.relative_to(tmppath)
360
+ video_path = str(relative_path.with_suffix(""))
361
+
362
+ try:
363
+ with h5py.File(h5_file_path, "r") as f:
364
+ frame_labels = f["label_indices"][:].tolist()
365
+ except Exception as e:
366
+ print(f" WARNING: Failed to read {h5_file_path}: {e}")
367
+ continue
368
+
369
+ video_metadata = metadata_df[metadata_df["path"] == video_path]
370
+ if len(video_metadata) == 0:
371
+ print(f" WARNING: No metadata for {video_path}, skipping")
372
+ continue
373
+ video_meta = video_metadata.iloc[0]
374
+
375
+ row = {
376
+ "path": video_path,
377
+ "dataset": "of-syn",
378
+ "frame_labels": frame_labels,
379
+ }
380
+ for field in metadata_fields:
381
+ if field in video_meta and pd.notna(video_meta[field]):
382
+ row[field] = str(video_meta[field])
383
+ else:
384
+ row[field] = ""
385
+ rows.append(row)
386
+
387
+ df = pd.DataFrame(rows)
388
+ # Cast demographic columns to string
389
+ df = cast_demographic_dtypes(df)
390
+ df["path"] = df["path"].astype(str)
391
+ df["dataset"] = df["dataset"].astype(str)
392
+
393
+ path = write_parquet(df, "framewise-syn", "train")
394
+ return {"framewise-syn": {"train": len(df)}}
395
+
396
+
397
  # ---- Main ----
398
 
399
  def main():
 
404
 
405
  # Labels configs (single train split)
406
  print("\n--- Labels configs ---")
407
+ for gen_fn in [gen_labels, gen_labels_syn, gen_metadata_syn, gen_framewise_syn]:
408
  result = gen_fn()
409
  all_results.update(result)
410
  for config, splits in result.items():
omnifall_dataset_examples.ipynb CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:80442a8e82cee61a8c64d78b081b9c9271438cc7442a1ab3fcd12dcd472537f3
3
- size 10103509
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5b52439f11c721e01c5db072454e4c7571bdd2a72df9f04acbf62b6735f218c0
3
+ size 10085652
parquet/framewise-syn/train-00000-of-00001.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e2c88f22010e64afa58b3ee0d7ddacf84525386aed594346ecc0680504f976cd
3
+ size 139176