DsL commited on
Commit
72d93d5
·
1 Parent(s): a98acf7
Files changed (1) hide show
  1. Causal3D_Dataset.py +11 -3
Causal3D_Dataset.py CHANGED
@@ -104,9 +104,17 @@ class Causal3dDataset(datasets.GeneratorBasedBuilder):
104
  for idx, row in tqdm(df.iterrows(), total=len(df)) if df is not None else enumerate(image_files):
105
  if df is not None:
106
  fname = row["imgs"] if "imgs" in row else str(idx)
107
- print(images)
108
- image_name = images[idx].split("/")[-1].split(".")[0] if images else ""
109
- record_img_path = next((key for key in image_files if image_name in key), None)
 
 
 
 
 
 
 
 
110
  # raise error if the path does not exist
111
  # check the path existance
112
  if not os.path.exists(image_files[record_img_path]) if record_img_path else None:
 
104
  for idx, row in tqdm(df.iterrows(), total=len(df)) if df is not None else enumerate(image_files):
105
  if df is not None:
106
  fname = row["imgs"] if "imgs" in row else str(idx)
107
+
108
+ # catch error if happen
109
+ try:
110
+ image_name = images[idx].split("/")[-1].split(".")[0] if images else ""
111
+ record_img_path = next((key for key in image_files if image_name in key), None)
112
+ except Exception as e:
113
+ print(f"Error: {e} in row {idx}, using index as file name")
114
+ print(images[idx])
115
+ exit(0)
116
+ record_img_path = None
117
+
118
  # raise error if the path does not exist
119
  # check the path existance
120
  if not os.path.exists(image_files[record_img_path]) if record_img_path else None: