Causal3D.py CHANGED
@@ -4,6 +4,7 @@ import os
4
  from pathlib import Path
5
  from tqdm import tqdm
6
 
 
7
  _CITATION = """\
8
  @article{liu2025causal3d,
9
  title={CAUSAL3D: A Comprehensive Benchmark for Causal Learning from Visual Data},
@@ -65,37 +66,15 @@ class Causal3D(datasets.GeneratorBasedBuilder):
65
  citation=_CITATION,
66
  )
67
 
68
- # def _split_generators(self, dl_manager):
69
- # parts = self.config.name.split("_", 2)
70
-
71
- # category = parts[0] + "_" + parts[1] # real_scenes or hypothetical_scenes
72
-
73
- # if category not in ["real_scenes", "hypothetical_scenes"]:
74
- # raise ValueError(f"Invalid category '{category}'. Must be one of ['real_scenes', 'hypothetical_scenes']")
75
-
76
- # scene = parts[2]
77
- # data_dir = os.path.join(category, scene)
78
-
79
- # return [
80
- # datasets.SplitGenerator(
81
- # name=datasets.Split.TRAIN,
82
- # gen_kwargs={"data_dir": data_dir},
83
- # )
84
- # ]
85
  def _split_generators(self, dl_manager):
86
  parts = self.config.name.split("_", 2)
87
- category = parts[0] + "_" + parts[1]
 
88
  if category not in ["real_scenes", "hypothetical_scenes"]:
89
- raise ValueError(f"Invalid category '{category}'.")
90
 
91
  scene = parts[2]
92
- scene_path = os.path.join(category, scene)
93
-
94
- if os.path.exists(scene_path):
95
- data_dir = scene_path
96
- else:
97
- archive_path = dl_manager.download_and_extract(f"{scene_path}.zip")
98
- data_dir = os.path.join(archive_path, scene)
99
 
100
  return [
101
  datasets.SplitGenerator(
@@ -103,10 +82,12 @@ class Causal3D(datasets.GeneratorBasedBuilder):
103
  gen_kwargs={"data_dir": data_dir},
104
  )
105
  ]
 
106
  def _generate_examples(self, data_dir):
107
  def color(text, code):
108
  return f"\033[{code}m{text}\033[0m"
109
- print("load data from {}".format(data_dir))
 
110
  try:
111
  image_files = {}
112
  for ext in ("*.png", "*.jpg", "*.jpeg"):
 
4
  from pathlib import Path
5
  from tqdm import tqdm
6
 
7
+ print("✅ Custom Causal3D loaded: outside Causal3D.py")
8
  _CITATION = """\
9
  @article{liu2025causal3d,
10
  title={CAUSAL3D: A Comprehensive Benchmark for Causal Learning from Visual Data},
 
66
  citation=_CITATION,
67
  )
68
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  def _split_generators(self, dl_manager):
70
  parts = self.config.name.split("_", 2)
71
+ category = parts[0] + "_" + parts[1] # real_scenes or hypothetical_scenes
72
+
73
  if category not in ["real_scenes", "hypothetical_scenes"]:
74
+ raise ValueError(f"Invalid category '{category}'. Must be one of ['real_scenes', 'hypothetical_scenes']")
75
 
76
  scene = parts[2]
77
+ data_dir = os.path.join(category, scene)
 
 
 
 
 
 
78
 
79
  return [
80
  datasets.SplitGenerator(
 
82
  gen_kwargs={"data_dir": data_dir},
83
  )
84
  ]
85
+
86
  def _generate_examples(self, data_dir):
87
  def color(text, code):
88
  return f"\033[{code}m{text}\033[0m"
89
+
90
+ # Load image paths
91
  try:
92
  image_files = {}
93
  for ext in ("*.png", "*.jpg", "*.jpeg"):
README.md CHANGED
@@ -336,48 +336,6 @@ dataset_info:
336
 
337
  **Causal3D** is a comprehensive benchmark designed to evaluate models’ abilities to uncover *latent causal relations* from structured and visual data. This dataset integrates **3D-rendered scenes** with **tabular causal annotations**, providing a unified testbed for advancing *causal discovery*, *causal representation learning*, and *causal reasoning* with **vision-language models (VLMs)** and **large language models (LLMs)**.
338
 
339
- ## 🖼️ Visual Previews
340
-
341
- Below are example images from different Causal3D scenes:
342
-
343
- <table>
344
- <tr>
345
- <td align="center">
346
- <img src="https://huggingface.co/datasets/LLDDSS/Causal3D/resolve/main/preview/parabola.png" width="250"/><br/>parabola
347
- </td>
348
- <td align="center">
349
- <img src="https://huggingface.co/datasets/LLDDSS/Causal3D/resolve/main/preview/convex.png" width="250"/><br/>convex
350
- </td>
351
- </tr>
352
- <tr>
353
- <td align="center">
354
- <img src="https://huggingface.co/datasets/LLDDSS/Causal3D/resolve/main/preview/magnetic.png" width="200"/><br/>magnetic
355
- </td>
356
- <td align="center">
357
- <img src="https://huggingface.co/datasets/LLDDSS/Causal3D/resolve/main/preview/pendulum.png" width="200"/><br/>pendulum
358
- </td>
359
- <td align="center">
360
- <img src="https://huggingface.co/datasets/LLDDSS/Causal3D/resolve/main/preview/reflection.png" width="200"/><br/>reflection
361
- </td>
362
- </tr>
363
- <tr>
364
- <td align="center">
365
- <img src="https://huggingface.co/datasets/LLDDSS/Causal3D/resolve/main/preview/seesaw.png" width="200"/><br/>seesaw
366
- </td>
367
- <td align="center">
368
- <img src="https://huggingface.co/datasets/LLDDSS/Causal3D/resolve/main/preview/spring.png" width="200"/><br/>spring
369
- </td>
370
- <td align="center">
371
- <img src="https://huggingface.co/datasets/LLDDSS/Causal3D/resolve/main/preview/water_flow.png" width="200"/><br/>water_flow
372
- </td>
373
- </tr>
374
- </table>
375
-
376
- <!-- - `causal_graph.json`: Ground-truth causal structure (as adjacency matrix or graph).
377
- - `view_info.json`: Camera/viewpoint metadata.
378
- - `split.json`: Recommended train/val/test splits for benchmarking. -->
379
-
380
-
381
  ## 📚 Usage
382
 
383
  #### 🔹 Option 1: Load from Hugging Face
@@ -398,7 +356,7 @@ print(dataset)
398
  ```
399
 
400
  #### 🔹 Option 2: Download via [**Kaggle**](https://www.kaggle.com/datasets/dsliu0011/causal3d-image-dataset) + Croissant
401
- ```python
402
  import mlcroissant as mlc
403
  import pandas as pd
404
 
@@ -407,9 +365,11 @@ croissant_dataset = mlc.Dataset(
407
  "https://www.kaggle.com/datasets/dsliu0011/causal3d-image-dataset/croissant/download"
408
  )
409
 
 
410
  record_sets = croissant_dataset.metadata.record_sets
411
  print(record_sets)
412
 
 
413
  df = pd.DataFrame(croissant_dataset.records(record_set=record_sets[0].uuid))
414
  print(df.head())
415
  ```
@@ -434,6 +394,48 @@ Each sub-dataset (scene) contains:
434
  - `images/`: Rendered images under different camera views and backgrounds.
435
  - `tabular.csv`: Instance-level annotations including object attributes in causal graph.
436
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
437
  ---
438
 
439
  ## 🎯 Evaluation Tasks
 
336
 
337
  **Causal3D** is a comprehensive benchmark designed to evaluate models’ abilities to uncover *latent causal relations* from structured and visual data. This dataset integrates **3D-rendered scenes** with **tabular causal annotations**, providing a unified testbed for advancing *causal discovery*, *causal representation learning*, and *causal reasoning* with **vision-language models (VLMs)** and **large language models (LLMs)**.
338
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
  ## 📚 Usage
340
 
341
  #### 🔹 Option 1: Load from Hugging Face
 
356
  ```
357
 
358
  #### 🔹 Option 2: Download via [**Kaggle**](https://www.kaggle.com/datasets/dsliu0011/causal3d-image-dataset) + Croissant
359
+ ```
360
  import mlcroissant as mlc
361
  import pandas as pd
362
 
 
365
  "https://www.kaggle.com/datasets/dsliu0011/causal3d-image-dataset/croissant/download"
366
  )
367
 
368
+ # List available record sets
369
  record_sets = croissant_dataset.metadata.record_sets
370
  print(record_sets)
371
 
372
+ # Load records from the first record set
373
  df = pd.DataFrame(croissant_dataset.records(record_set=record_sets[0].uuid))
374
  print(df.head())
375
  ```
 
394
  - `images/`: Rendered images under different camera views and backgrounds.
395
  - `tabular.csv`: Instance-level annotations including object attributes in causal graph.
396
 
397
+
398
+ ## 🖼️ Visual Previews
399
+
400
+ Below are example images from different Causal3D scenes:
401
+
402
+ <table>
403
+ <tr>
404
+ <td align="center">
405
+ <img src="https://huggingface.co/datasets/LLDDSS/Causal3D/resolve/main/preview/parabola.png" width="250"/><br/>parabola
406
+ </td>
407
+ <td align="center">
408
+ <img src="https://huggingface.co/datasets/LLDDSS/Causal3D/resolve/main/preview/convex.png" width="250"/><br/>convex
409
+ </td>
410
+ </tr>
411
+ <tr>
412
+ <td align="center">
413
+ <img src="https://huggingface.co/datasets/LLDDSS/Causal3D/resolve/main/preview/magnetic.png" width="200"/><br/>magnetic
414
+ </td>
415
+ <td align="center">
416
+ <img src="https://huggingface.co/datasets/LLDDSS/Causal3D/resolve/main/preview/pendulum.png" width="200"/><br/>pendulum
417
+ </td>
418
+ <td align="center">
419
+ <img src="https://huggingface.co/datasets/LLDDSS/Causal3D/resolve/main/preview/reflection.png" width="200"/><br/>reflection
420
+ </td>
421
+ </tr>
422
+ <tr>
423
+ <td align="center">
424
+ <img src="https://huggingface.co/datasets/LLDDSS/Causal3D/resolve/main/preview/seesaw.png" width="200"/><br/>seesaw
425
+ </td>
426
+ <td align="center">
427
+ <img src="https://huggingface.co/datasets/LLDDSS/Causal3D/resolve/main/preview/spring.png" width="200"/><br/>spring
428
+ </td>
429
+ <td align="center">
430
+ <img src="https://huggingface.co/datasets/LLDDSS/Causal3D/resolve/main/preview/water_flow.png" width="200"/><br/>water_flow
431
+ </td>
432
+ </tr>
433
+ </table>
434
+
435
+ <!-- - `causal_graph.json`: Ground-truth causal structure (as adjacency matrix or graph).
436
+ - `view_info.json`: Camera/viewpoint metadata.
437
+ - `split.json`: Recommended train/val/test splits for benchmarking. -->
438
+
439
  ---
440
 
441
  ## 🎯 Evaluation Tasks
hypothetical_scenes/Hypothetic_v2_linear.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:9175871f055720040bfd0e7b5c9cc52cf41393f680bf5b810606b08944ba1c75
3
- size 1110377090
 
 
 
 
hypothetical_scenes/Hypothetic_v2_nonlinear.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:9f6fb5f2dbc8eeeb31d4ffde8724a92a87c1db5e31433dbbbe99ed1e50609bd1
3
- size 800467917
 
 
 
 
hypothetical_scenes/Hypothetic_v3_fully_connected_linear.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:9e8c897052f0b70acbd5514c289870d4935d1837e74817439270a98ff0778ca3
3
- size 822752525
 
 
 
 
hypothetical_scenes/Hypothetic_v4_linear_full_connected.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:8315bfca5b41db160a3eba26ea199d2a42fe4489a29e92726b9399d1750a32a9
3
- size 826644475
 
 
 
 
hypothetical_scenes/Hypothetic_v4_linear_v.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:4b44ed4cfcbaa7c25e179998f1f1424f86eb1fc9fa6143c993ed44cb1b324d08
3
- size 808208138
 
 
 
 
hypothetical_scenes/Hypothetic_v4_nonlinear_v.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:d8d317260703195963c4822331ca25cbe81c5541f92aaf12a1bb0b686a230e49
3
- size 811335400
 
 
 
 
hypothetical_scenes/Hypothetic_v5_linear.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:9d537224a27461535c20c669215fb0cf91c9026ef63fb59c6747800a019b2319
3
- size 810261564
 
 
 
 
hypothetical_scenes/Hypothetic_v5_linear_full_connected.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:699f2dfb16e81887afa5ccef0f89dc5e6eca0b5f1da92b4239aceb06ac76820e
3
- size 809814676
 
 
 
 
hypothetical_scenes/rendered_h3_linear_128P.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:c9588258afa914857e5d17385c46455d2a4dc17d29ebe3a0871469b317ddcd35
3
- size 302097317
 
 
 
 
hypothetical_scenes/rendered_h3_nonlinear_128P.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:24f9edc90d29ce450e783aba1737d57f4a0b9e41d96ff1c8e20f52a915598d0c
3
- size 205482525
 
 
 
 
hypothetical_scenes/rendered_h5_nonlinear.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:5e79e03ff43377540772012506abdbd4fe21ec5a6b1d8d4da31e4649dfc69420
3
- size 1169848303
 
 
 
 
real_scenes/Real_Parabola.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:a1ae148865846af812fb4dcbe1c5ad1a7411fac7dd2d44d4ef0641594ccc4181
3
- size 1383346876
 
 
 
 
real_scenes/Real_magnet_v3.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:99108db8d6498341a0793e274af424c7b9cc35fcbab70a05aee5c783d38d4e6c
3
- size 61633001
 
 
 
 
real_scenes/Real_magnet_v3_5.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:8c8628bd8e3dbe856dbc1c775a4583de54ac7cccfff21015ef586dfb1d2f78ae
3
- size 192949303
 
 
 
 
real_scenes/Real_spring_v3_256P.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:66e321d4b136fa183da1f753858d4cb5444ec4885af95a2668b77825784f7277
3
- size 32003111
 
 
 
 
real_scenes/Water_flow_scene_render.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:f0454296ace356f28947f5c532e3cecf11825e5675902eb6f331e2eda846eaeb
3
- size 733875487
 
 
 
 
real_scenes/convex_len_render_images.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:93213b6734ee26f060b06ef29334566fedf1953b1e13a1847d6f8db9acbdc698
3
- size 136593946
 
 
 
 
real_scenes/real_pendulum.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:fb1280b4006d0a292161421f5a909159a80f796d5a84a22a899c46a4c9ff15b4
3
- size 716373611
 
 
 
 
real_scenes/rendered_magnetic_128.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:fcee77b970b562dd785202d38476192da318b138e792db70ac7c622d31e646c2
3
- size 130631876
 
 
 
 
real_scenes/rendered_reflection_128P.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:04be7343d2597f38025d05804dd5ae48ed586984945db40d539cf3a3590e8099
3
- size 99792676
 
 
 
 
real_scenes/seesaw_scene_128P.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:b26a118585b71192baa62f25fc01168d2220636374061a80ff26e97192d4c333
3
- size 184896622
 
 
 
 
real_scenes/spring_scene_128P.zip DELETED
@@ -1,3 +0,0 @@
1
- version https://git-lfs.github.com/spec/v1
2
- oid sha256:e989d60c77aa382e916924814b5117d3ba6b46e7f652b22857532ac63af13658
3
- size 1194906885