simplexsigil2 commited on
Commit
88dbfe7
·
verified ·
1 Parent(s): ec392b5

Upload folder using huggingface_hub

Browse files
.claude/.nfs0000000676cbbb9200039239 ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Read(//home/dschneider/workspace/PROJECTS/omnifall/hf/**)",
5
+ "Read(//lsdf/users/dschneider-kf3609/workspace/PROJECTS/omnifall/hf/**)",
6
+ "Read(//lsdf/users/dschneider-kf3609/workspace/PROJECTS/wanfall/labels/**)",
7
+ "Bash(source ~/miniconda3/bin/activate ccode)",
8
+ "Bash(source:*)"
9
+ ],
10
+ "deny": [],
11
+ "ask": []
12
+ }
13
+ }
.claude/settings.local.json CHANGED
@@ -4,7 +4,9 @@
4
  "Read(//home/dschneider/workspace/PROJECTS/omnifall/hf/**)",
5
  "Read(//lsdf/users/dschneider-kf3609/workspace/PROJECTS/omnifall/hf/**)",
6
  "Read(//lsdf/users/dschneider-kf3609/workspace/PROJECTS/wanfall/labels/**)",
7
- "Bash(source ~/miniconda3/bin/activate ccode)"
 
 
8
  ],
9
  "deny": [],
10
  "ask": []
 
4
  "Read(//home/dschneider/workspace/PROJECTS/omnifall/hf/**)",
5
  "Read(//lsdf/users/dschneider-kf3609/workspace/PROJECTS/omnifall/hf/**)",
6
  "Read(//lsdf/users/dschneider-kf3609/workspace/PROJECTS/wanfall/labels/**)",
7
+ "Bash(source ~/miniconda3/bin/activate ccode)",
8
+ "Bash(source:*)",
9
+ "WebSearch"
10
  ],
11
  "deny": [],
12
  "ask": []
.gitignore CHANGED
@@ -3,3 +3,5 @@ create_demographic_plots.py
3
  create_splits.py
4
  export_via_to_csv.py
5
  extract_jsonl_metadata.py
 
 
 
3
  create_splits.py
4
  export_via_to_csv.py
5
  extract_jsonl_metadata.py
6
+ test_wanfall_builder.py
7
+
data_files/frame_wise_labels.tar.zst ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f6025389eade4c047b56a92c37b3f34b43e380fe9214a421f9b50660ecc3113
3
+ size 356098
wanfall.py ADDED
@@ -0,0 +1,397 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """WanFall: A Synthetic Activity Recognition Dataset
2
+
3
+ This dataset builder provides access to the WanFall synthetic activity recognition dataset,
4
+ featuring 12,000 videos with dense temporal annotations across 16 activity classes.
5
+
6
+ The dataset includes rich demographic and scene metadata, enabling research in fair and
7
+ robust activity recognition across diverse populations.
8
+ """
9
+
10
+ import pandas as pd
11
+ import datasets
12
+ from datasets import BuilderConfig, GeneratorBasedBuilder, Features, Value, ClassLabel, SplitGenerator, Split
13
+
14
+
15
+ # Dataset metadata
16
+ _CITATION = """\
17
+ TBD
18
+ """
19
+
20
+ _DESCRIPTION = """\
21
+ WanFall is a large-scale synthetic activity recognition dataset designed for fall detection
22
+ and activities of daily living research. The dataset features computer-generated videos of
23
+ human actors performing various activities in controlled virtual environments.
24
+
25
+ **Key Features:**
26
+ - 12,000 video clips with dense temporal annotations
27
+ - 16 activity classes including falls, posture transitions, and static states
28
+ - 19,228 temporal segments with frame-level precision
29
+ - 5.0625 seconds per video clip (81 frames @ 16 fps)
30
+ - Rich demographic metadata (soft labels): age, gender, ethnicity, body type, height, skin tone
31
+ - Scene attributes: environment, camera angle, frame rate
32
+ - Multiple evaluation splits: random (80/10/10) and cross-demographic (age, ethnicity, BMI)
33
+
34
+ **Use Cases:**
35
+ - Fall detection research
36
+ - Activity recognition with temporal segmentation
37
+ - Bias and fairness analysis across demographics
38
+ - Cross-demographic generalization studies
39
+ """
40
+
41
+ _HOMEPAGE = "https://huggingface.co/datasets/simplexsigil2/wanfall"
42
+ _LICENSE = "cc-by-nc-4.0"
43
+
44
+ # Activity class labels (16 classes)
45
+ _ACTIVITY_LABELS = [
46
+ "walk", # 0: Walking movement
47
+ "fall", # 1: Falling down action
48
+ "fallen", # 2: Person on ground after fall
49
+ "sit_down", # 3: Transitioning to sitting
50
+ "sitting", # 4: Stationary sitting posture
51
+ "lie_down", # 5: Intentionally lying down
52
+ "lying", # 6: Stationary lying posture
53
+ "stand_up", # 7: Rising, mostly to standing, but also from lying to sitting.
54
+ "standing", # 8: Stationary standing posture
55
+ "other", # 9: Unclassified activities
56
+ "kneel_down", # 10: Transitioning to kneeling
57
+ "kneeling", # 11: Stationary kneeling posture
58
+ "squat_down", # 12: Transitioning to squatting
59
+ "squatting", # 13: Stationary squatting posture
60
+ "crawl", # 14: Crawling movement
61
+ "jump", # 15: Jumping action
62
+ ]
63
+
64
+ # Demographic and scene metadata categories
65
+ _AGE_GROUPS = ["toddlers_1_4", "children_5_12", "teenagers_13_17",
66
+ "young_adults_18_34", "middle_aged_35_64", "elderly_65_plus"]
67
+ _GENDERS = ["male", "female"]
68
+ _SKIN_TONES = [f"mst{i}" for i in range(1, 11)] # Monk Skin Tone scale (1-10)
69
+ _ETHNICITIES = ["white", "black", "asian", "hispanic_latino", "aian", "nhpi", "mena"]
70
+ _BMI_BANDS = ["underweight", "normal", "overweight", "obese"]
71
+ _HEIGHT_BANDS = ["short", "avg", "tall"]
72
+ _ENVIRONMENTS = ["indoor", "outdoor"]
73
+ _CAMERA_ELEVATIONS = ["eye", "low", "high", "top"]
74
+ _CAMERA_AZIMUTHS = ["front", "rear", "left", "right"]
75
+ _CAMERA_DISTANCES = ["medium", "far"]
76
+ _CAMERA_SHOTS = ["static_wide", "static_medium_wide"]
77
+ _SPEEDS = ["24fps_rt", "25fps_rt", "30fps_rt", "std_rt"]
78
+
79
+
80
+ class WanFallConfig(BuilderConfig):
81
+ """BuilderConfig for WanFall dataset.
82
+
83
+ Args:
84
+ split_type: Type of data to load ("labels", "metadata", or split name like "random")
85
+ paths_only: If True, only return video paths for split configs (no label merging)
86
+ **kwargs: Keyword arguments forwarded to super.
87
+ """
88
+
89
+ def __init__(self, split_type="labels", paths_only=False, **kwargs):
90
+ super().__init__(**kwargs)
91
+ self.split_type = split_type
92
+ self.paths_only = paths_only
93
+
94
+
95
+ class WanFall(GeneratorBasedBuilder):
96
+ """WanFall synthetic activity recognition dataset builder."""
97
+
98
+ VERSION = datasets.Version("1.0.0")
99
+
100
+ BUILDER_CONFIG_CLASS = WanFallConfig
101
+ BUILDER_CONFIGS = [
102
+ WanFallConfig(
103
+ name="labels",
104
+ version=VERSION,
105
+ description="All temporal segment labels with metadata (19,228 segments)",
106
+ split_type="labels",
107
+ ),
108
+ WanFallConfig(
109
+ name="metadata",
110
+ version=VERSION,
111
+ description="Video-level metadata without temporal segments (12,000 videos)",
112
+ split_type="metadata",
113
+ ),
114
+ WanFallConfig(
115
+ name="random",
116
+ version=VERSION,
117
+ description="Random 80/10/10 train/val/test split",
118
+ split_type="random",
119
+ ),
120
+ WanFallConfig(
121
+ name="cross_age",
122
+ version=VERSION,
123
+ description="Cross-age evaluation: train on young/middle-aged, test on children/elderly",
124
+ split_type="cross_age",
125
+ ),
126
+ WanFallConfig(
127
+ name="cross_ethnicity",
128
+ version=VERSION,
129
+ description="Cross-ethnicity evaluation: train on white/asian/hispanic, test on black/mena/nhpi",
130
+ split_type="cross_ethnicity",
131
+ ),
132
+ WanFallConfig(
133
+ name="cross_bmi",
134
+ version=VERSION,
135
+ description="Cross-BMI evaluation: train on normal/underweight, test on obese",
136
+ split_type="cross_bmi",
137
+ ),
138
+ ]
139
+
140
+ DEFAULT_CONFIG_NAME = "random"
141
+
142
+ def _info(self):
143
+ """Specify dataset metadata and features schema."""
144
+
145
+ # Define features based on config type
146
+ if self.config.split_type == "metadata":
147
+ features = self._get_metadata_features()
148
+ elif self.config.paths_only:
149
+ features = self._get_paths_only_features()
150
+ else:
151
+ features = self._get_full_features()
152
+
153
+ # Create id2label and label2id mappings
154
+ id2label = {i: label for i, label in enumerate(_ACTIVITY_LABELS)}
155
+ label2id = {label: i for i, label in enumerate(_ACTIVITY_LABELS)}
156
+
157
+ return datasets.DatasetInfo(
158
+ description=_DESCRIPTION,
159
+ features=features,
160
+ homepage=_HOMEPAGE,
161
+ license=_LICENSE,
162
+ citation=_CITATION,
163
+ # Note: Label mappings are accessible via dataset.info.features["label"].names
164
+ )
165
+
166
+ def _get_full_features(self):
167
+ """Complete feature schema with all 19 fields (temporal segments + metadata)."""
168
+ return Features({
169
+ # Core identity and temporal fields
170
+ "path": Value("string"),
171
+ "label": ClassLabel(num_classes=16, names=_ACTIVITY_LABELS),
172
+ "start": Value("float32"),
173
+ "end": Value("float32"),
174
+ "subject": Value("int32"), # -1 for WanFall (no subject tracking)
175
+ "cam": Value("int32"), # -1 for WanFall (single view)
176
+ "dataset": Value("string"), # "wanfall" constant
177
+
178
+ # Demographic metadata
179
+ "age_group": ClassLabel(num_classes=6, names=_AGE_GROUPS),
180
+ "gender_presentation": ClassLabel(num_classes=2, names=_GENDERS),
181
+ "monk_skin_tone": ClassLabel(num_classes=10, names=_SKIN_TONES),
182
+ "race_ethnicity_omb": ClassLabel(num_classes=7, names=_ETHNICITIES),
183
+ "bmi_band": ClassLabel(num_classes=4, names=_BMI_BANDS),
184
+ "height_band": ClassLabel(num_classes=3, names=_HEIGHT_BANDS),
185
+
186
+ # Scene metadata
187
+ "environment_category": ClassLabel(num_classes=2, names=_ENVIRONMENTS),
188
+ "camera_shot": ClassLabel(num_classes=2, names=_CAMERA_SHOTS),
189
+ "speed": ClassLabel(num_classes=4, names=_SPEEDS),
190
+ "camera_elevation": ClassLabel(num_classes=4, names=_CAMERA_ELEVATIONS),
191
+ "camera_azimuth": ClassLabel(num_classes=4, names=_CAMERA_AZIMUTHS),
192
+ "camera_distance": ClassLabel(num_classes=2, names=_CAMERA_DISTANCES),
193
+ })
194
+
195
+ def _get_metadata_features(self):
196
+ """Feature schema for metadata config (video-level, no temporal segments)."""
197
+ return Features({
198
+ # Core identity (no temporal fields)
199
+ "path": Value("string"),
200
+ "dataset": Value("string"),
201
+
202
+ # Demographic metadata
203
+ "age_group": ClassLabel(num_classes=6, names=_AGE_GROUPS),
204
+ "gender_presentation": ClassLabel(num_classes=2, names=_GENDERS),
205
+ "monk_skin_tone": ClassLabel(num_classes=10, names=_SKIN_TONES),
206
+ "race_ethnicity_omb": ClassLabel(num_classes=7, names=_ETHNICITIES),
207
+ "bmi_band": ClassLabel(num_classes=4, names=_BMI_BANDS),
208
+ "height_band": ClassLabel(num_classes=3, names=_HEIGHT_BANDS),
209
+
210
+ # Scene metadata
211
+ "environment_category": ClassLabel(num_classes=2, names=_ENVIRONMENTS),
212
+ "camera_shot": ClassLabel(num_classes=2, names=_CAMERA_SHOTS),
213
+ "speed": ClassLabel(num_classes=4, names=_SPEEDS),
214
+ "camera_elevation": ClassLabel(num_classes=4, names=_CAMERA_ELEVATIONS),
215
+ "camera_azimuth": ClassLabel(num_classes=4, names=_CAMERA_AZIMUTHS),
216
+ "camera_distance": ClassLabel(num_classes=2, names=_CAMERA_DISTANCES),
217
+ })
218
+
219
+ def _get_paths_only_features(self):
220
+ """Minimal feature schema for paths-only mode."""
221
+ return Features({
222
+ "path": Value("string"),
223
+ })
224
+
225
+ def _split_generators(self, dl_manager):
226
+ """Define data splits and their source files."""
227
+
228
+ # Handle different config types
229
+ if self.config.split_type == "labels":
230
+ # Labels config: single split with all temporal segments
231
+ return [
232
+ SplitGenerator(
233
+ name=Split.TRAIN,
234
+ gen_kwargs={
235
+ "filepath": "labels/wanfall.csv",
236
+ "split_name": "labels",
237
+ },
238
+ ),
239
+ ]
240
+
241
+ elif self.config.split_type == "metadata":
242
+ # Metadata config: single split with video-level metadata
243
+ return [
244
+ SplitGenerator(
245
+ name=Split.TRAIN,
246
+ gen_kwargs={
247
+ "filepath": "videos/metadata.csv",
248
+ "split_name": "metadata",
249
+ },
250
+ ),
251
+ ]
252
+
253
+ else:
254
+ # Split configs (random, cross_age, cross_ethnicity, cross_bmi)
255
+ split_dir = f"splits/{self.config.split_type}"
256
+
257
+ # If paths_only mode, just load split files
258
+ # Otherwise, we need both split files and labels for merging
259
+ base_kwargs = {
260
+ "split_dir": split_dir,
261
+ "labels_path": "labels/wanfall.csv" if not self.config.paths_only else None,
262
+ }
263
+
264
+ return [
265
+ SplitGenerator(
266
+ name=Split.TRAIN,
267
+ gen_kwargs={
268
+ **base_kwargs,
269
+ "split_file": f"{split_dir}/train.csv",
270
+ "split_name": "train",
271
+ },
272
+ ),
273
+ SplitGenerator(
274
+ name=Split.VALIDATION,
275
+ gen_kwargs={
276
+ **base_kwargs,
277
+ "split_file": f"{split_dir}/val.csv",
278
+ "split_name": "val",
279
+ },
280
+ ),
281
+ SplitGenerator(
282
+ name=Split.TEST,
283
+ gen_kwargs={
284
+ **base_kwargs,
285
+ "split_file": f"{split_dir}/test.csv",
286
+ "split_name": "test",
287
+ },
288
+ ),
289
+ ]
290
+
291
+ def _generate_examples(self, filepath=None, split_file=None, labels_path=None,
292
+ split_name=None, split_dir=None):
293
+ """Generate examples from CSV files.
294
+
295
+ Args:
296
+ filepath: Direct path to CSV file (for labels/metadata configs)
297
+ split_file: Path to split file containing video paths (for split configs)
298
+ labels_path: Path to labels file for merging (for split configs with full data)
299
+ split_name: Name of the split being generated
300
+ split_dir: Directory containing split files
301
+ """
302
+
303
+ # Case 1: Direct file loading (labels or metadata config)
304
+ if filepath is not None:
305
+ df = pd.read_csv(filepath)
306
+
307
+ # For metadata config, filter out temporal segment columns if they exist
308
+ if self.config.split_type == "metadata":
309
+ # Keep only metadata columns (exclude label, start, end, subject, cam if present)
310
+ metadata_cols = ["path", "age_group", "gender_presentation",
311
+ "monk_skin_tone", "race_ethnicity_omb", "bmi_band", "height_band",
312
+ "environment_category", "camera_shot", "speed",
313
+ "camera_elevation", "camera_azimuth", "camera_distance"]
314
+ # Only keep columns that exist in the dataframe
315
+ available_cols = [col for col in metadata_cols if col in df.columns]
316
+ df = df[available_cols].drop_duplicates(subset=["path"]).reset_index(drop=True)
317
+ # Add dataset column manually
318
+ df["dataset"] = "wanfall"
319
+
320
+ # Yield examples
321
+ for idx, row in df.iterrows():
322
+ yield idx, self._row_to_example(row)
323
+
324
+ # Case 2: Split file loading with optional merging
325
+ elif split_file is not None:
326
+ # Load split paths
327
+ split_df = pd.read_csv(split_file)
328
+
329
+ # Paths-only mode: just return paths
330
+ if self.config.paths_only or labels_path is None:
331
+ for idx, row in split_df.iterrows():
332
+ yield idx, {"path": row["path"]}
333
+
334
+ # Full mode: merge with labels
335
+ else:
336
+ # Load all labels
337
+ labels_df = pd.read_csv(labels_path)
338
+
339
+ # Merge split paths with labels
340
+ merged_df = pd.merge(split_df, labels_df, on="path", how="left")
341
+
342
+ # Yield examples
343
+ for idx, row in merged_df.iterrows():
344
+ yield idx, self._row_to_example(row)
345
+
346
+ def _row_to_example(self, row):
347
+ """Convert a DataFrame row to an example dictionary with proper types.
348
+
349
+ Args:
350
+ row: pandas Series representing one row
351
+
352
+ Returns:
353
+ Dictionary with properly typed values for the features schema
354
+ """
355
+ example = {}
356
+
357
+ # Always include path
358
+ example["path"] = str(row["path"])
359
+
360
+ # Include fields based on what's available in the row
361
+ if "label" in row and pd.notna(row["label"]):
362
+ example["label"] = int(row["label"])
363
+
364
+ if "start" in row and pd.notna(row["start"]):
365
+ example["start"] = float(row["start"])
366
+
367
+ if "end" in row and pd.notna(row["end"]):
368
+ example["end"] = float(row["end"])
369
+
370
+ if "subject" in row and pd.notna(row["subject"]):
371
+ example["subject"] = int(row["subject"])
372
+
373
+ if "cam" in row and pd.notna(row["cam"]):
374
+ example["cam"] = int(row["cam"])
375
+
376
+ if "dataset" in row and pd.notna(row["dataset"]):
377
+ example["dataset"] = str(row["dataset"])
378
+
379
+ # Demographic metadata (categorical - keep as strings, ClassLabel handles conversion)
380
+ demographic_fields = [
381
+ "age_group", "gender_presentation", "monk_skin_tone",
382
+ "race_ethnicity_omb", "bmi_band", "height_band"
383
+ ]
384
+ for field in demographic_fields:
385
+ if field in row and pd.notna(row[field]):
386
+ example[field] = str(row[field])
387
+
388
+ # Scene metadata (categorical)
389
+ scene_fields = [
390
+ "environment_category", "camera_shot", "speed",
391
+ "camera_elevation", "camera_azimuth", "camera_distance"
392
+ ]
393
+ for field in scene_fields:
394
+ if field in row and pd.notna(row[field]):
395
+ example[field] = str(row[field])
396
+
397
+ return example