-
Notifications
You must be signed in to change notification settings - Fork 0
/
dataset.py
127 lines (82 loc) · 2.61 KB
/
dataset.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
from shapemaker import *
####################
# Metaballs ########
####################
def create_8D():
# Create dataset of metaballs from 2 balls
# 2 . 3 coordinates + 2 radii = 8 dimensions
points = []
f = open(r"dataset/dataset_8D.npy", "wb")
for i in range(50):
points.append(shape_maker8D(2000, 4))
print(i)
np.save(f, points)
return
def eval_8D(i):
# Plot metaballs of 2 balls from the dataset
f = np.load(open(r"dataset/dataset_16D.npy", "rb"),allow_pickle=True)
draw_point_cloud(Tensor(f[i][0]))
print(f[i][1])
def create():
# Create dataset of metaballs
points = []
f = open(r"dataset/dataset1k.npy", "wb")
for i in range(50):
points.append(shape_maker1(3,1000))
print(i)
np.save(f, points)
return
def eval(i):
# visualize items from the metaball dataset
f = np.load(open(r"dataset/dataset1k.npy", "rb"))
draw_point_cloud(Tensor(f[i]))
####################
# Ellipsoid ########
####################
def create_ell():
# Create dataset of ellipsoids
points = []
f = open(r"dataset/dataset_ellipsoid.npy", "wb")
for i in range(50):
points.append(make_ellipse())
print(i)
np.save(f, points)
return
def eval_ell(i):
# Plot ellipsoids from the dataset
f = np.load(open(r"dataset/dataset_ellipsoid.npy", "rb"),allow_pickle=True)
draw_point_cloud(Tensor(f[i][0]))
####################
# Faces ##########
####################
# 383 faces in total
#import open3d as o3d
def load_face(index):
# Load face 'index' from .ply file
# Need to enable the import open3d part for this
pcd = o3d.io.read_point_cloud("faces/face_" + str(index) + ".ply")
x = np.asarray(pcd.points)
x = Tensor(normalize(x))
x = x - np.array([-0.22,-0.22,0.24])
x = Tensor(normalize(x))
x = x + np.array([0.0,.15,-0.15])
x = np.array(normalize(x))
if x.shape[0] != 23725:
print("NOT THE RIGHT SIZE!!")
print(index)
return x
def make_face_dataset():
# Convert all .ply files into one numpy array and save it
points = []
f = open(r"dataset/dataset_faces.npy", "wb")
for i in range(100):
print(i)
x = (load_face(i),0)
points.append(x)
np.save(f, points)
return
def show_face(i):
# Plot face from the dataset
f = np.load(open(r"dataset/dataset_faces.npy", "rb"),allow_pickle=True)
draw_point_cloud(Tensor(f[i][0]))
show_face(5)