Skip to content

Commit c63d82b

Browse files
committed
all
0 parents  commit c63d82b

29 files changed

+3427
-0
lines changed
888 Bytes
Binary file not shown.
1.15 KB
Binary file not shown.
967 Bytes
Binary file not shown.

Eikonal/data/bunny.npy

843 KB
Binary file not shown.

Eikonal/dataset.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import torch
2+
import numpy as np
3+
from scipy import spatial
4+
5+
class Dataset(torch.utils.data.Dataset):
6+
def __init__(self, pts, knn, transform=None):
7+
self.transform = transform
8+
self.pts = pts.astype(np.float32)
9+
10+
def __len__(self):
11+
return len(self.pts)
12+
13+
def __getitem__(self, idx):
14+
p = self.pts[idx]
15+
16+
if self.transform:
17+
p = self.transform(p)
18+
19+
return p

Eikonal/marching_cubes.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import os
2+
import random
3+
import argparse
4+
import numpy as np
5+
import colorsys
6+
from skimage import measure
7+
import tqdm
8+
9+
10+
import torch
11+
import torch.nn as nn
12+
import torch.nn.functional as F
13+
14+
from utils import build_network
15+
16+
# For extracting mesh through marching cubes:
17+
# python marching_cubes.py --name output --epochs 2000
18+
19+
20+
########################
21+
# this function you need to complete
22+
def compute_SDFs(net, device, nb_grid):
23+
x = np.linspace(-1.5, 1.5, nb_grid)
24+
y = np.linspace(-1.5, 1.5, nb_grid)
25+
z = np.linspace(-1.5, 1.5, nb_grid)
26+
X, Y, Z = np.meshgrid(x, y, z)
27+
28+
...
29+
30+
return val
31+
32+
33+
if __name__ == '__main__':
34+
parser = argparse.ArgumentParser(description='Process some integers.')
35+
parser.add_argument('--name', '-n', type=str, default='output', help='output model name')
36+
37+
args = parser.parse_args()
38+
name = args.name
39+
40+
use_cuda = torch.cuda.is_available()
41+
device = torch.device("cuda" if use_cuda else "cpu")
42+
43+
net = build_network(input_dim=3)
44+
net.to(device)
45+
net.load_state_dict(torch.load('./models/{}_model.pth'.format(name), map_location=device))
46+
47+
nb_grid = 128
48+
val = compute_SDFs(net, device, nb_grid)
49+
volume = val.reshape(nb_grid, nb_grid, nb_grid)
50+
51+
verts, faces, normals, values = measure.marching_cubes(volume, 0.0, spacing=(1.0, -1.0, 1.0), gradient_direction='ascent')
52+
53+
import open3d as o3d
54+
55+
mesh = o3d.geometry.TriangleMesh()
56+
57+
mesh.vertices = o3d.utility.Vector3dVector(verts)
58+
mesh.triangles = o3d.utility.Vector3iVector(faces)
59+
mesh.triangle_normals = o3d.utility.Vector3dVector(normals)
60+
61+
os.makedirs('output', exist_ok=True)
62+
o3d.io.write_triangle_mesh("output/{}_mesh.ply".format(name), mesh)

Eikonal/models/model_0000.pth

6.02 MB
Binary file not shown.

Eikonal/models/model_0100.pth

6.02 MB
Binary file not shown.

Eikonal/models/model_0200.pth

6.02 MB
Binary file not shown.

Eikonal/models/model_0300.pth

6.02 MB
Binary file not shown.

0 commit comments

Comments
 (0)