This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @title Define SIREN deformation model | |
# https://github.com/vsitzmann/siren | |
# MIT License | |
# Copyright (c) 2020 Vincent Sitzmann | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# simple positional embedding (NeRF style) | |
# as in https://arxiv.org/pdf/2003.08934 (Equation 4) | |
def positional_embedding(x, k): | |
batch_size, n_dims = x.shape | |
x_rep = x.unsqueeze(-1).expand(-1, -1, k) | |
k_pows = torch.pow(2, torch.arange(0, k, device=x.device)).view(1, 1, k) | |
x_k = k_pows * torch.pi * x_rep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import torch.nn as nn | |
def laplacian_smoothing_loss2d(Y_pred): | |
C, H, W = Y_pred.shape[1], Y_pred.shape[2], Y_pred.shape[3] | |
kernel = torch.tensor([[0, 1, 0], [1, -4, 1], [0, 1, 0]], device=device, dtype=torch.float32) | |
kernel = kernel.view(1, 1, 3, 3).repeat(C, 1, 1, 1) | |
Y_laplacian = nn.functional.conv2d(Y_pred, kernel, groups=C, padding=1) | |
laplacian_loss = (Y_laplacian ** 2).mean() | |
return laplacian_loss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pymeshlab normal estimation (and optional Poisson) | |
# https://github.com/cnr-isti-vclab/PyMeshLab/blob/main/docs/filter_list.rst | |
# https://pymeshlab.readthedocs.io/en/0.2/tutorials/get_mesh_values.html | |
import pymeshlab | |
def get_normals_pymeshlab(x, k=10, smoothiter=0): | |
tmp_mesh_path = 'tmp.obj' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
MIT License | |
Copyright (c) 2024 Sergey Prokudin [email protected] | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# following | |
# https://github.com/facebookresearch/pytorch3d/issues/35 | |
import torch | |
import torch.nn as nn | |
class PointsRendererDepth(nn.Module): | |
""" | |
A class for rendering a batch of points. The class should | |
be initialized with a rasterizer and compositor class which each have a forward | |
function. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import open3d as o3d | |
import numpy as np | |
def poisson_open3d(ply_path, depth=8): | |
pcd = o3d.io.read_point_cloud(ply_path) | |
mesh, densities = o3d.geometry.TriangleMesh.create_from_point_cloud_poisson(pcd, depth=8) | |
vertices_to_remove = densities < np.quantile(densities, 0.02) | |
mesh.remove_vertices_by_mask(vertices_to_remove) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
newmtl material_1 | |
map_Kd rp_mei_posed_001_dif.jpg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5.251361131668090820e-01 9.620525240898132324e-01 7.196764349937438965e-01 | |
5.226933956146240234e-01 9.544755220413208008e-01 7.539969086647033691e-01 | |
5.285560488700866699e-01 9.512906074523925781e-01 7.259945869445800781e-01 | |
5.315514206886291504e-01 9.564292430877685547e-01 6.891824007034301758e-01 | |
5.269100069999694824e-01 9.467492103576660156e-01 7.527468204498291016e-01 | |
5.214509367942810059e-01 9.482995271682739258e-01 7.740847468376159668e-01 | |
5.324009060859680176e-01 9.465931057929992676e-01 6.968711614608764648e-01 | |
5.352808237075805664e-01 9.493461251258850098e-01 6.598548889160156250e-01 | |
5.359319448471069336e-01 9.241502285003662109e-01 6.846292018890380859e-01 | |
5.381639003753662109e-01 9.202622175216674805e-01 6.565521359443664551e-01 |
NewerOlder