alkzar90 commited on
Commit
7c4579a
1 Parent(s): 5c7307b

iterate trought image names and store it in a list for each dataset

Browse files
Files changed (1) hide show
  1. NIH-Chest-X-ray-dataset.py +34 -3
NIH-Chest-X-ray-dataset.py CHANGED
@@ -91,11 +91,42 @@ class XChest(datasets.GeneratorBasedBuilder):
91
 
92
 
93
  def _split_generators(self, dl_manager):
94
- data_files = dl_manager.download_and_extract(_URLS['image_urls'])
95
  train_val_list = get(_URLS['train_val_list']).iter_lines()
96
  train_val_list = set([x.decode('UTF8') for x in train_val_list])
97
- print(train_val_list)
98
- pass
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
 
100
  def _generate_examples(self, files):
101
  pass
 
91
 
92
 
93
  def _split_generators(self, dl_manager):
94
+ # Get the image names that belong to the train-val dataset
95
  train_val_list = get(_URLS['train_val_list']).iter_lines()
96
  train_val_list = set([x.decode('UTF8') for x in train_val_list])
97
+ print(train_val_list))
98
+
99
+ # Create list for store the name of the images for each dataset
100
+ train_files = []
101
+ test_files = []
102
+
103
+ # Download batches
104
+ data_files = dl_manager.download_and_extract(_URLS['image_urls'])
105
+
106
+ # Iterate trought image folder and check if they belong to
107
+ # the trainset or testset
108
+ for batch in data_files:
109
+ for img in batch:
110
+ if img in train_val_list:
111
+ train_files.append(img)
112
+ else:
113
+ test_files.append(img)
114
+
115
+ print(train_files)
116
+ print(test_files)
117
+
118
+ return [
119
+ datatsets.SplitGenerator(
120
+ name=datasets.Split.TRAIN,
121
+ gen_kwargs={
122
+ 'files': dl_manager.iter_files()
123
+ }
124
+
125
+ ),
126
+ datasets.SplitGenerator(
127
+
128
+ )
129
+ ]
130
 
131
  def _generate_examples(self, files):
132
  pass