Spaces:
Sleeping
Sleeping
daidedou
commited on
Commit
·
904b157
1
Parent(s):
d408533
Try to fix the gpu aborted problem : processing on downsampled meshes during optimization
Browse files- app.py +1 -1
- notebook_helpers.py +1 -1
- utils/geometry.py +5 -13
app.py
CHANGED
|
@@ -241,7 +241,7 @@ def run_clicked(mesh1_path, mesh2_path, yaml_path, lambda_val, zoomout_val, time
|
|
| 241 |
with torch.no_grad():
|
| 242 |
n_fmap = C12_new.shape[-1]
|
| 243 |
C12_all = C_up.squeeze()[:n_fmap, :n_fmap] @ C12_new.clone().squeeze() @ C_down.squeeze()[:n_fmap, :n_fmap]
|
| 244 |
-
C12_end_zo = torch_zoomout(evecs1, evecs2, evecs_2trans, C12_all,
|
| 245 |
p2p_zo, _ = extract_p2p_torch_fmap(C12_end_zo, evecs1, evecs2)
|
| 246 |
return build_outputs(datadicts.shape_surf, datadicts.target_surf, datadicts.cmap1, p2p_zo, tag="run")
|
| 247 |
|
|
|
|
| 241 |
with torch.no_grad():
|
| 242 |
n_fmap = C12_new.shape[-1]
|
| 243 |
C12_all = C_up.squeeze()[:n_fmap, :n_fmap] @ C12_new.clone().squeeze() @ C_down.squeeze()[:n_fmap, :n_fmap]
|
| 244 |
+
C12_end_zo = torch_zoomout(evecs1, evecs2, evecs_2trans, C12_all, 50)
|
| 245 |
p2p_zo, _ = extract_p2p_torch_fmap(C12_end_zo, evecs1, evecs2)
|
| 246 |
return build_outputs(datadicts.shape_surf, datadicts.target_surf, datadicts.cmap1, p2p_zo, tag="run")
|
| 247 |
|
notebook_helpers.py
CHANGED
|
@@ -21,7 +21,7 @@ def load_data(file, cache_path, name, num_evecs=128, make_cache=False):
|
|
| 21 |
if not os.path.exists(cache_path) or make_cache:
|
| 22 |
print("Computing operators ...")
|
| 23 |
vnormals = surf.computeVertexNormals()
|
| 24 |
-
get_operators(surf.vertices, surf.faces,
|
| 25 |
vnormals_down = surf_down.computeVertexNormals()
|
| 26 |
get_operators(surf_down.vertices, surf_down.faces, num_evecs, cache_down, vnormals_down)
|
| 27 |
data_dict = load_operators(cache_path)
|
|
|
|
| 21 |
if not os.path.exists(cache_path) or make_cache:
|
| 22 |
print("Computing operators ...")
|
| 23 |
vnormals = surf.computeVertexNormals()
|
| 24 |
+
get_operators(surf.vertices, surf.faces, 50, cache_path, vnormals)
|
| 25 |
vnormals_down = surf_down.computeVertexNormals()
|
| 26 |
get_operators(surf_down.vertices, surf_down.faces, num_evecs, cache_down, vnormals_down)
|
| 27 |
data_dict = load_operators(cache_path)
|
utils/geometry.py
CHANGED
|
@@ -386,11 +386,7 @@ def compute_operators(verts, faces, k_eig, normals=None, normalize_desc=True):
|
|
| 386 |
gradX = sparse_np_to_torch(gradX_np).to(device=device, dtype=dtype)
|
| 387 |
gradY = sparse_np_to_torch(gradY_np).to(device=device, dtype=dtype)
|
| 388 |
|
| 389 |
-
|
| 390 |
-
wks = torch.from_numpy(compute_wks(evecs_np, evals_np, massvec_np, n_descr=128, subsample_step=1, n_eig=128, normalize=normalize_desc)).to(device=device, dtype=dtype)
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
return frames, massvec, L, evals, evecs, gradX, gradY, hks, wks
|
| 394 |
|
| 395 |
|
| 396 |
def get_all_operators(verts_list, faces_list, k_eig, op_cache_dir=None, normals=None):
|
|
@@ -514,8 +510,6 @@ def get_operators(verts, faces, k_eig=128, cache_path=None, normals=None, overwr
|
|
| 514 |
evecs = npzfile["evecs"][:, :k_eig]
|
| 515 |
gradX = read_sp_mat("gradX")
|
| 516 |
gradY = read_sp_mat("gradY")
|
| 517 |
-
frames = npzfile["hks"]
|
| 518 |
-
mass = npzfile["wks"]
|
| 519 |
|
| 520 |
frames = torch.from_numpy(frames).to(device=device, dtype=dtype)
|
| 521 |
mass = torch.from_numpy(mass).to(device=device, dtype=dtype)
|
|
@@ -541,7 +535,7 @@ def get_operators(verts, faces, k_eig=128, cache_path=None, normals=None, overwr
|
|
| 541 |
if not found:
|
| 542 |
|
| 543 |
# No matching entry found; recompute.
|
| 544 |
-
frames, mass, L, evals, evecs, gradX, gradY
|
| 545 |
|
| 546 |
dtype_np = np.float32
|
| 547 |
|
|
@@ -572,11 +566,10 @@ def get_operators(verts, faces, k_eig=128, cache_path=None, normals=None, overwr
|
|
| 572 |
gradY_data=gradY_np.data.astype(dtype_np),
|
| 573 |
gradY_indices=gradY_np.indices,
|
| 574 |
gradY_indptr=gradY_np.indptr,
|
| 575 |
-
gradY_shape=gradY_np.shape
|
| 576 |
-
wks=wks
|
| 577 |
)
|
| 578 |
|
| 579 |
-
return frames, mass, L, evals, evecs, gradX, gradY
|
| 580 |
|
| 581 |
|
| 582 |
def load_operators(filepath):
|
|
@@ -602,8 +595,7 @@ def load_operators(filepath):
|
|
| 602 |
evals=npzfile['evals'],
|
| 603 |
evecs=npzfile['evecs'],
|
| 604 |
gradX=read_sp_mat('gradX'),
|
| 605 |
-
gradY=read_sp_mat('gradY')
|
| 606 |
-
wks=npzfile['wks'],
|
| 607 |
)
|
| 608 |
|
| 609 |
|
|
|
|
| 386 |
gradX = sparse_np_to_torch(gradX_np).to(device=device, dtype=dtype)
|
| 387 |
gradY = sparse_np_to_torch(gradY_np).to(device=device, dtype=dtype)
|
| 388 |
|
| 389 |
+
return frames, massvec, L, evals, evecs, gradX, gradY
|
|
|
|
|
|
|
|
|
|
|
|
|
| 390 |
|
| 391 |
|
| 392 |
def get_all_operators(verts_list, faces_list, k_eig, op_cache_dir=None, normals=None):
|
|
|
|
| 510 |
evecs = npzfile["evecs"][:, :k_eig]
|
| 511 |
gradX = read_sp_mat("gradX")
|
| 512 |
gradY = read_sp_mat("gradY")
|
|
|
|
|
|
|
| 513 |
|
| 514 |
frames = torch.from_numpy(frames).to(device=device, dtype=dtype)
|
| 515 |
mass = torch.from_numpy(mass).to(device=device, dtype=dtype)
|
|
|
|
| 535 |
if not found:
|
| 536 |
|
| 537 |
# No matching entry found; recompute.
|
| 538 |
+
frames, mass, L, evals, evecs, gradX, gradY = compute_operators(verts, faces, k_eig, normals=normals)
|
| 539 |
|
| 540 |
dtype_np = np.float32
|
| 541 |
|
|
|
|
| 566 |
gradY_data=gradY_np.data.astype(dtype_np),
|
| 567 |
gradY_indices=gradY_np.indices,
|
| 568 |
gradY_indptr=gradY_np.indptr,
|
| 569 |
+
gradY_shape=gradY_np.shape
|
|
|
|
| 570 |
)
|
| 571 |
|
| 572 |
+
return frames, mass, L, evals, evecs, gradX, gradY
|
| 573 |
|
| 574 |
|
| 575 |
def load_operators(filepath):
|
|
|
|
| 595 |
evals=npzfile['evals'],
|
| 596 |
evecs=npzfile['evecs'],
|
| 597 |
gradX=read_sp_mat('gradX'),
|
| 598 |
+
gradY=read_sp_mat('gradY')
|
|
|
|
| 599 |
)
|
| 600 |
|
| 601 |
|