MCPcopy Create free account
hub / github.com/ChristopherLu/milliEgo / load_data_single_sensor

Function load_data_single_sensor

utility/data_loader.py:184–234  ·  view source on GitHub ↗
(training_file, sensor)

Source from the content-addressed store, hash-verified

182 return n_chunk, x_time, x_sensor, x_imu, y
183
184def load_data_single_sensor(training_file, sensor):
185 # Load data
186 x, x_imu, y = [], [], []
187 hdf5_file = h5py.File(training_file, 'r')
188 x_temp = hdf5_file.get(sensor+'_data')
189 # x_imu_temp = hdf5_file.get('imu_data')
190 y_temp = hdf5_file.get('label_data')
191
192 print('Data shape: ' + str(np.shape(x_temp)))
193
194 # this is for rgb
195 # x_rgb_temp = np.squeeze(x_rgb_temp, axis=0)
196 # x_imu_temp = np.squeeze(x_imu_temp, axis=0)
197 # y_temp = np.squeeze(y_temp, axis=0)
198
199 # this is for raw data
200 if x_temp.shape[0] == 1:
201 x_temp = x_temp[0]
202 # x_imu_temp = x_imu_temp[0]
203 y_temp = y_temp[0]
204
205 print('Data shape: ' + str(np.shape(x_temp)) + str(str(np.shape(y_temp))))
206
207 data_size = np.size(x_temp, axis=0)
208
209 # Determine whether the data should be divided into several chunks
210 # to fit in memory
211 data_per_chunk = 5000
212 is_special_case = False
213 if data_size > 10000:
214 n_chunk = data_size // data_per_chunk
215 n_chunk += 1
216 is_special_case = True
217 else:
218 n_chunk = 1
219
220 if is_special_case == True:
221 # Divide into several chunks if the length of the data is too large
222 for i in range(n_chunk-1):
223 x.append(x_temp[(data_per_chunk * i):data_per_chunk * (i + 1), :, :, :])
224 # x_imu.append(x_imu_temp[(data_per_chunk * i):data_per_chunk * (i + 1), :, :, :])
225 y.append(y_temp[(data_per_chunk * i):data_per_chunk * (i + 1), :])
226 # 2300
227 x.append(x_temp[(data_size - data_per_chunk):data_size, :, :, :])
228 # x_imu.append(x_imu_temp[(data_size - data_per_chunk):data_size, :, :, :])
229 y.append(y_temp[(data_size - data_per_chunk):(data_size-1), :])
230 else:
231 x.append(x_temp[0:data_size, :, :, :])
232 # x_imu.append(x_imu_temp[0:data_size, :, :])
233 y.append(y_temp[0:(data_size-1), :])
234 return n_chunk, x, y
235
236
237def validation_stack(validation_files, sensor='mmwave_middle', imu_length=0):

Callers 1

validation_stackFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected