data: num_samples, num_voxels_padded return: data_aug: num_samples*aug_times, num_voxels_padded
(data, aug_times=2, interpolation_ratio=0.5)
| 53 | return v_split |
| 54 | |
| 55 | def augmentation(data, aug_times=2, interpolation_ratio=0.5): |
| 56 | ''' |
| 57 | data: num_samples, num_voxels_padded |
| 58 | return: data_aug: num_samples*aug_times, num_voxels_padded |
| 59 | ''' |
| 60 | num_to_generate = int((aug_times-1)*len(data)) |
| 61 | if num_to_generate == 0: |
| 62 | return data |
| 63 | pairs_idx = np.random.choice(len(data), size=(num_to_generate, 2), replace=True) |
| 64 | data_aug = [] |
| 65 | for i in pairs_idx: |
| 66 | z = interpolate_voxels(data[i[0]], data[i[1]], interpolation_ratio) |
| 67 | data_aug.append(np.expand_dims(z,axis=0)) |
| 68 | data_aug = np.concatenate(data_aug, axis=0) |
| 69 | |
| 70 | return np.concatenate([data, data_aug], axis=0) |
| 71 | |
| 72 | def interpolate_voxels(x, y, ratio=0.5): |
| 73 | '''' |
nothing calls this directly
no test coverage detected