-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread.py
140 lines (100 loc) · 3.45 KB
/
read.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 10 10:37:40 2019
@author: mancmanomyst
"""
import h5py
import numpy as np
from voxelgrid import VoxelGrid
f=h5py.File("ply_data_train0.h5","r")
data=f["data"][:]
label=f["label"][:]
size=data.shape[0]
out = (np.zeros((size, 4096), dtype="f"), np.zeros(size, dtype=np.int8))
for i in range(size):
voxelgrid = VoxelGrid(data[i,:], x_y_z=[16, 16, 16])
# make the vector range 0-1
out[0][i] = voxelgrid.vector.reshape(-1) / np.max(voxelgrid.vector)
out[1][i] = label[i]
print("[DONE]")
f.close
f=h5py.File("ply_data_train1.h5","r")
data=f["data"][:]
label=f["label"][:]
size=data.shape[0]
out1 = (np.zeros((size, 4096), dtype="f"), np.zeros(size, dtype=np.int8))
for i in range(size):
voxelgrid = VoxelGrid(data[i,:], x_y_z=[16, 16, 16])
# make the vector range 0-1
out1[0][i] = voxelgrid.vector.reshape(-1) / np.max(voxelgrid.vector)
out1[1][i] = label[i]
print("[DONE]")
f.close
f=h5py.File("ply_data_train2.h5","r")
data=f["data"][:]
label=f["label"][:]
size=data.shape[0]
out2 = (np.zeros((size, 4096), dtype="f"), np.zeros(size, dtype=np.int8))
for i in range(size):
voxelgrid = VoxelGrid(data[i,:], x_y_z=[16, 16, 16])
# make the vector range 0-1
out2[0][i] = voxelgrid.vector.reshape(-1) / np.max(voxelgrid.vector)
out2[1][i] = label[i]
print("[DONE]")
f.close
f=h5py.File("ply_data_train3.h5","r")
data=f["data"][:]
label=f["label"][:]
size=data.shape[0]
out3 = (np.zeros((size, 4096), dtype="f"), np.zeros(size, dtype=np.int8))
for i in range(size):
voxelgrid = VoxelGrid(data[i,:], x_y_z=[16, 16, 16])
# make the vector range 0-1
out3[0][i] = voxelgrid.vector.reshape(-1) / np.max(voxelgrid.vector)
out3[1][i] = label[i]
print("[DONE]")
f.close
f=h5py.File("ply_data_train4.h5","r")
data=f["data"][:]
label=f["label"][:]
size=data.shape[0]
out4 = (np.zeros((size, 4096), dtype="f"), np.zeros(size, dtype=np.int8))
for i in range(size):
voxelgrid = VoxelGrid(data[i,:], x_y_z=[16, 16, 16])
# make the vector range 0-1
out4[0][i] = voxelgrid.vector.reshape(-1) / np.max(voxelgrid.vector)
out4[1][i] = label[i]
print("[DONE]")
f.close
f=h5py.File("ply_data_test0.h5","r")
data=f["data"][:]
label=f["label"][:]
size=data.shape[0]
out_t = (np.zeros((size, 4096), dtype="f"), np.zeros(size, dtype=np.int8))
for i in range(size):
voxelgrid = VoxelGrid(data[i,:], x_y_z=[16, 16, 16])
# make the vector range 0-1
out_t[0][i] = voxelgrid.vector.reshape(-1) / np.max(voxelgrid.vector)
out_t[1][i] = label[i]
print("[DONE]")
f.close
f=h5py.File("ply_data_test1.h5","r")
data=f["data"][:]
label=f["label"][:]
size=data.shape[0]
out_t2 = (np.zeros((size, 4096), dtype="f"), np.zeros(size, dtype=np.int8))
for i in range(size):
voxelgrid = VoxelGrid(data[i,:], x_y_z=[16, 16, 16])
# make the vector range 0-1
out_t2[0][i] = voxelgrid.vector.reshape(-1) / np.max(voxelgrid.vector)
out_t2[1][i] = label[i]
print("[DONE]")
f.close
X_train=np.concatenate((out[0],out1[0],out2[0],out3[0],out4[0]))
X_test=np.array(out_t[0])
y_train=np.concatenate((out[1],out1[1],out2[1],out3[1],out4[1]))
y_test=np.array(out_t[1])
X_test2=np.array(out_t2[0])
y_test2=np.array(out_t2[1])
np.savez("voxelgrid.npz",X_train=X_train,y_train=y_train,X_test=X_test,y_test=y_test,X_test2=X_test2,y_test2=y_test2)