moukaii commited on
Commit
599a10f
1 Parent(s): 56c65dd

Update Tuberculosis_Dataset.py

Browse files
Files changed (1) hide show
  1. Tuberculosis_Dataset.py +4 -11
Tuberculosis_Dataset.py CHANGED
@@ -92,18 +92,11 @@ class TuberculosisDataset(GeneratorBasedBuilder):
92
 
93
  def _prepare_image_file_paths(self, images_zip_path):
94
  image_file_paths = {}
95
- with zipfile.ZipFile(images_zip_path, 'r') as z:
96
- # Create a temporary directory for the extracted images
97
- temp_dir = "extracted_images"
98
- if not os.path.exists(temp_dir):
99
- os.makedirs(temp_dir)
100
- # Iterate through each file in the ZIP
101
- for file in z.namelist():
102
- if file.endswith('.jpg') and not file.startswith('__MACOSX'):
103
  key = file.split('_')[0]
104
  if key not in image_file_paths:
105
- # Extract the first image for each case_id
106
- extract_path = z.extract(file, temp_dir)
107
- image_file_paths[key] = extract_path
108
  return image_file_paths
109
 
 
92
 
93
  def _prepare_image_file_paths(self, images_zip_path):
94
  image_file_paths = {}
95
+ for root, _, files in os.walk(images_zip_path):
96
+ for file in files:
97
+ if file.endswith('.jpg'):
 
 
 
 
 
98
  key = file.split('_')[0]
99
  if key not in image_file_paths:
100
+ image_file_paths[key] = os.path.join(root, file) # Store only the first image path
 
 
101
  return image_file_paths
102