Update RefRef_test.py
Browse files- RefRef_test.py +22 -22
RefRef_test.py
CHANGED
@@ -97,27 +97,27 @@ class RefRef_test(datasets.GeneratorBasedBuilder):
|
|
97 |
# "rotation": frame.get("rotation", 0.0)
|
98 |
# }
|
99 |
def _generate_examples(self, filepaths, split):
|
100 |
-
for filepath in filepaths:
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
continue
|
|
|
|
|
|
|
|
|
|
|
105 |
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
for frame_idx, frame in enumerate(data.get("frames", [])):
|
115 |
-
base_dir = os.path.dirname(filepath)
|
116 |
-
|
117 |
-
yield f"{scene_name}_{frame_idx}", {
|
118 |
-
"image": os.path.join(base_dir, frame["file_path"]),
|
119 |
-
"depth": os.path.join(base_dir, frame["depth_file_path"]),
|
120 |
-
"mask": os.path.join(base_dir, frame["mask_file_path"]),
|
121 |
-
"transform_matrix": frame["transform_matrix"],
|
122 |
-
"rotation": frame.get("rotation", 0.0)
|
123 |
-
}
|
|
|
97 |
# "rotation": frame.get("rotation", 0.0)
|
98 |
# }
|
99 |
def _generate_examples(self, filepaths, split):
|
100 |
+
# for filepath in filepaths:
|
101 |
+
print(filepaths)
|
102 |
+
# Add validation for JSON files
|
103 |
+
if not filepaths.endswith(".json") or os.path.isdir(filepaths):
|
104 |
+
continue
|
105 |
+
|
106 |
+
with open(filepaths, "r", encoding="utf-8") as f:
|
107 |
+
try:
|
108 |
+
data = json.load(f)
|
109 |
+
except json.JSONDecodeError:
|
110 |
continue
|
111 |
+
|
112 |
+
scene_name = os.path.basename(os.path.dirname(filepaths))
|
113 |
+
|
114 |
+
for frame_idx, frame in enumerate(data.get("frames", [])):
|
115 |
+
base_dir = os.path.dirname(filepaths)
|
116 |
|
117 |
+
yield f"{scene_name}_{frame_idx}", {
|
118 |
+
"image": os.path.join(base_dir, frame["file_path"]),
|
119 |
+
"depth": os.path.join(base_dir, frame["depth_file_path"]),
|
120 |
+
"mask": os.path.join(base_dir, frame["mask_file_path"]),
|
121 |
+
"transform_matrix": frame["transform_matrix"],
|
122 |
+
"rotation": frame.get("rotation", 0.0)
|
123 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|