dxl952@case.edu commited on
Commit
cc54230
·
1 Parent(s): 32db2ad
Files changed (1) hide show
  1. Causal3D.py +26 -6
Causal3D.py CHANGED
@@ -4,7 +4,6 @@ import os
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,15 +65,37 @@ class Causal3D(datasets.GeneratorBasedBuilder):
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,7 +103,6 @@ class Causal3D(datasets.GeneratorBasedBuilder):
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"
 
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
  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
+ # ✅ 自动判断:远程则下载并解压,本地则直接使用
95
+ if os.path.exists(scene_path): # 本地路径直接用
96
+ data_dir = scene_path
97
+ else: # Hub 上运行或没有本地数据,则下载
98
+ data_dir = dl_manager.download_and_extract(scene_path)
99
 
100
  return [
101
  datasets.SplitGenerator(
 
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"