@@ -22,7 +22,7 @@ def __init__(self, data_dir, transform = None):
22
22
23
23
# full dataframe including train_val and test set
24
24
self .df = self .get_df ()
25
- print ('self.df.shape: {}' .format (self .df .shape ) )
25
+ print ('self.df.shape: {}' .format (self .df .shape ))
26
26
27
27
self .make_pkl_dir (config .pkl_dir_path )
28
28
@@ -54,12 +54,12 @@ def __init__(self, data_dir, transform = None):
54
54
else :
55
55
print ('\n {}: already exists' .format (config .disease_classes_pkl_path ))
56
56
57
- self .new_df = self .df .iloc [self .the_chosen , :] # this is the sampled train_val data
57
+ self .new_df = self .train_val_df .iloc [self .the_chosen , :] # this is the sampled train_val data
58
58
print ('\n self.all_classes_dict: {}' .format (self .all_classes_dict ))
59
59
60
60
def resample (self ):
61
61
self .the_chosen , self .all_classes , self .all_classes_dict = self .choose_the_indices ()
62
- self .new_df = self .df .iloc [self .the_chosen , :]
62
+ self .new_df = self .train_val_df .iloc [self .the_chosen , :]
63
63
print ('\n self.all_classes_dict: {}' .format (self .all_classes_dict ))
64
64
65
65
def make_pkl_dir (self , pkl_dir_path ):
@@ -79,7 +79,7 @@ def get_train_val_df(self):
79
79
if filename in train_val_list :
80
80
train_val_df = train_val_df .append (self .df .iloc [i :i + 1 , :])
81
81
82
- print ('train_val_df.shape: {}' .format (train_val_df .shape ))
82
+ # print('train_val_df.shape: {}'.format(train_val_df.shape))
83
83
84
84
return train_val_df
85
85
@@ -119,6 +119,7 @@ def choose_the_indices(self):
119
119
all_classes [t ] = 1
120
120
else :
121
121
all_classes [t ] += 1
122
+ continue
122
123
123
124
# choose if multiple labels
124
125
if len (temp ) > 1 :
@@ -180,7 +181,7 @@ def get_train_val_list(self):
180
181
f = open (os .path .join ('data' , 'NIH Chest X-rays' , 'train_val_list.txt' ), 'r' )
181
182
train_val_list = str .split (f .read (), '\n ' )
182
183
return train_val_list
183
-
184
+
184
185
def __len__ (self ):
185
186
return len (self .new_df )
186
187
@@ -194,6 +195,7 @@ def __init__(self, data_dir, transform = None):
194
195
195
196
# full dataframe including train_val and test set
196
197
self .df = self .get_df ()
198
+ print ('\n self.df.shape: {}' .format (self .df .shape ))
197
199
198
200
self .make_pkl_dir (config .pkl_dir_path )
199
201
@@ -220,7 +222,7 @@ def __init__(self, data_dir, transform = None):
220
222
221
223
def __getitem__ (self , index ):
222
224
row = self .test_df .iloc [index , :]
223
-
225
+
224
226
img = cv2 .imread (row ['image_links' ])
225
227
labels = str .split (row ['Finding Labels' ], '|' )
226
228
@@ -240,7 +242,6 @@ def make_pkl_dir(self, pkl_dir_path):
240
242
241
243
def get_df (self ):
242
244
csv_path = os .path .join (self .data_dir , 'Data_Entry_2017.csv' )
243
- # print('{} found: {}'.format(csv_path, os.path.exists(csv_path)))
244
245
245
246
all_xray_df = pd .read_csv (csv_path )
246
247
0 commit comments