alkzar90 lhoestq HF staff commited on
Commit
3655d3c
1 Parent(s): e7ec57d

Fix the way it reads the file name (#2)

Browse files

- Fix the way it reads the file name (be827978bc7dd2e1c7fbff24b3d869e66c35ee90)


Co-authored-by: Quentin Lhoest <lhoestq@users.noreply.huggingface.co>

Files changed (1) hide show
  1. NIH-Chest-X-ray-dataset.py +2 -2
NIH-Chest-X-ray-dataset.py CHANGED
@@ -186,7 +186,7 @@ class ChestXray14(datasets.GeneratorBasedBuilder):
186
  logger.info(f"Batch for data_files: {batch}")
187
  path_files = dl_manager.iter_files(batch)
188
  for img in path_files:
189
- if img.split('/')[-1] in train_val_list:
190
  train_files.append(img)
191
  else:
192
  test_files.append(img)
@@ -215,7 +215,7 @@ class ChestXray14(datasets.GeneratorBasedBuilder):
215
  for i, path in enumerate(files):
216
  file_name = os.path.basename(path)
217
  # Get image id to filter the respective row of the csv
218
- image_id = file_name.split('/')[-1]
219
  image_labels = label_csv[label_csv["Image Index"] == image_id]["Finding Labels"].values[0].split("|")
220
  if file_name.endswith(".png"):
221
  yield i, {
186
  logger.info(f"Batch for data_files: {batch}")
187
  path_files = dl_manager.iter_files(batch)
188
  for img in path_files:
189
+ if os.path.basename(img) in train_val_list:
190
  train_files.append(img)
191
  else:
192
  test_files.append(img)
215
  for i, path in enumerate(files):
216
  file_name = os.path.basename(path)
217
  # Get image id to filter the respective row of the csv
218
+ image_id = file_name
219
  image_labels = label_csv[label_csv["Image Index"] == image_id]["Finding Labels"].values[0].split("|")
220
  if file_name.endswith(".png"):
221
  yield i, {