MCPcopy Create free account
hub / github.com/XLearning-SCU/2022-CVPR-DART / __init__

Method __init__

data_loader.py:195–337  ·  view source on GitHub ↗
(self, data_dir, trial, transform=None, colorIndex=None, thermalIndex=None, noise_rate=0.,
                 noise_file='', mode='', probV_1=[], probV_2=[], probI=[])

Source from the content-addressed store, hash-verified

193
194class RegDBData(data.Dataset):
195 def __init__(self, data_dir, trial, transform=None, colorIndex=None, thermalIndex=None, noise_rate=0.,
196 noise_file='', mode='', probV_1=[], probV_2=[], probI=[]):
197 # Load training images (path) and labels
198 data_dir = data_dir
199 train_color_list = data_dir + 'idx/train_visible_{}'.format(trial) + '.txt'
200 train_thermal_list = data_dir + 'idx/train_thermal_{}'.format(trial) + '.txt'
201 color_img_file, self.train_color_label = load_data(train_color_list)
202 thermal_img_file, self.train_thermal_label = load_data(train_thermal_list)
203
204 train_color_image = []
205 for i in range(len(color_img_file)):
206 img = Image.open(data_dir + color_img_file[i])
207 img = img.resize((144, 288), Image.ANTIALIAS)
208 pix_array = np.array(img)
209 train_color_image.append(pix_array)
210 train_color_image = np.array(train_color_image)
211
212 train_thermal_image = []
213 for i in range(len(thermal_img_file)):
214 img = Image.open(data_dir + thermal_img_file[i])
215 img = img.resize((144, 288), Image.ANTIALIAS)
216 pix_array = np.array(img)
217 train_thermal_image.append(pix_array)
218 train_thermal_image = np.array(train_thermal_image)
219
220 self.mode = mode
221 self.probI = probI
222 self.probV_1 = probV_1
223 self.probV_2 = probV_2
224
225 print("train with %.1f noisy rates" % noise_rate)
226
227 if noise_rate == 0.:
228 print("loading files and idx of trial {}".format(trial))
229 self.rgb_cleanIdx = range(len(self.train_color_label))
230 self.rgb_noiseIdx = []
231 self.ir_cleanIdx = range(len(self.train_thermal_label))
232 self.ir_noiseIdx = []
233 self.true_train_color_label = self.train_color_label
234 self.true_train_thermal_label = self.train_thermal_label
235 else:
236 if os.path.exists((noise_file +'_trial{}_'.format(trial) + 'rgb.npy')):
237 print("loading files and idx of noisy labels of trial {}".format(trial))
238 self.train_color_label = np.load((noise_file + '_trial{}_'.format(trial) + 'rgb.npy'))
239 self.train_thermal_label = np.load((noise_file + '_trial{}_'.format(trial) + 'ir.npy'))
240 self.rgb_noiseIdx = np.load((noise_file + '_trial{}_'.format(trial) + 'rgb_noiseIdx.npy'))
241 self.ir_noiseIdx = np.load((noise_file + '_trial{}_'.format(trial) + 'ir_noiseIdx.npy'))
242 self.rgb_cleanIdx = np.load((noise_file + '_trial{}_'.format(trial) + 'rgb_cleanIdx.npy'))
243 self.ir_cleanIdx = np.load((noise_file + '_trial{}_'.format(trial) + 'ir_cleanIdx.npy'))
244 self.true_train_color_label = np.load((noise_file + '_trial{}_'.format(trial) + 'rgb_true.npy'))
245 self.true_train_thermal_label = np.load((noise_file + '_trial{}_'.format(trial) + 'ir_true.npy'))
246
247 else: # inject noise
248 num_class = 0
249 while num_class != np.unique(self.train_color_label).size:
250 for j in [0, 1]:
251 if j == 0:
252 ids = self.train_color_label[:]

Callers

nothing calls this directly

Calls 4

ChannelAdapGrayClass · 0.90
ChannelExchangeClass · 0.85
load_dataFunction · 0.70

Tested by

no test coverage detected