├── README.md ├── core_code.py └── img ├── towards1.png └── towards2.png /README.md: -------------------------------------------------------------------------------- 1 | # Towards Better Gradient Consistency for Neural Signed Distance Functions via Level Set Alignment (CVPR 2023) 2 | 3 | 4 |

Personal Web Pages | Paper

5 | 6 | This repository contains the code to reproduce the results from the paper. 7 | [Towards Better Gradient Consistency for Neural Signed Distance Functions via Level Set Alignment](http://arxiv.org/abs/2305.11601/). 8 | 9 | You can find detailed usage instructions for training your own models and using pretrained models below. 10 | 11 | If you find our code or paper useful, please consider citing 12 | 13 | @inproceedings{BaoruiTowards, 14 | title = {Towards Better Gradient Consistency for Neural Signed Distance Functions via Level Set Alignment}, 15 | author = {Baorui Ma and Junsheng Zhou and Yu-Shen Liu and Zhizhong Han}, 16 | booktitle = {Conference on Computer Vision and Pattern Recognition (CVPR)}, 17 | year = {2023} 18 | } 19 | 20 | ## Coming Soon 21 | 22 | Related work 23 | ```bash 24 | Pytorch 25 | https://github.com/mabaorui/NeuralPull-Pytorch 26 | https://github.com/junshengzhou/CAP-UDF 27 | Tensorflow 28 | https://github.com/mabaorui/NeuralPull 29 | https://github.com/mabaorui/OnSurfacePrior 30 | https://github.com/mabaorui/PredictableContextPrior 31 | ``` 32 | 33 | 34 | ## Demo 35 |

36 | 37 |

38 | 39 |

40 | 41 |

42 | 43 | 44 | ## Installation 45 | First you have to make sure that you have all dependencies in place. 46 | The simplest way to do so, is to use [anaconda](https://www.anaconda.com/). 47 | 48 | You can create an anaconda environment called `tf` using 49 | ``` 50 | conda env create -f tf.yaml 51 | conda activate tf 52 | ``` 53 | 54 | ## ToDo 55 | In different datasets or your own data, because of the variation in point cloud density, this ['0.25' parameter](https://github.com/mabaorui/OnSurfacePrior/blob/d53bf3a7bc88837e2974ddc1fd0700ecc2641ade/onSurPrior.py#L425) has a very strong influence on the final result, which controls the distance between the query points and the point cloud. So if you want to get better results, you should adjust this parameter. We give '0.25' here as a reference value, and this value can be used for most object-level reconstructions. For the scene dataset, we will later publish the reference values for the hyperparameter settings for the scene dataset. 56 | -------------------------------------------------------------------------------- /core_code.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | """ 3 | Created on Mon Jun 26 19:22:12 2023 4 | 5 | @author: Admin 6 | """ 7 | 8 | # pytorch version 9 | sdf_nn_output = sdf_network(pts) 10 | sdf = sdf_nn_output[:, :1] 11 | gradients = sdf_network.gradient(pts).squeeze() 12 | gradient_norm = F.normalize(gradients, dim=-1) 13 | pts_moved = pts + gradient_norm * sdf 14 | 15 | sdf_moved = sdf_network(pts_moved)[:, :1] 16 | gradient_moved = sdf_network.gradient(pts_moved).squeeze() 17 | gradient_moved_norm = F.normalize(gradient_moved, dim=-1) 18 | consis_constraint = 1 - F.cosine_similarity(gradient_moved_norm, gradient_norm, dim=-1) 19 | weight_moved = torch.exp(-self.conf.get_float('train.sharp') * torch.abs(sdf)).reshape(-1,consis_constraint.shape[-1]) 20 | consis_constraint = consis_constraint * weight_moved 21 | 22 | # tensorflow version 23 | gradient_norm = F.normalize(gradient, dim=-1) 24 | coords_moved = coords + gradient_norm * pred_sdf 25 | model_moved_input = {'coords':coords_moved} 26 | model_output_moved = model(model_moved_input) 27 | coords_moved = model_output_moved['model_in'] 28 | pred_sdf_moved = model_output_moved['model_out'] 29 | gradient_moved = diff_operators.gradient(pred_sdf_moved, coords_moved) 30 | gradient_moved_norm = F.normalize(gradient_moved, dim=-1) 31 | consis_constraint = 1 - F.cosine_similarity(gradient_moved_norm, gradient_norm, dim=-1) 32 | weight_moved = torch.exp(-self.conf.get_float('train.sharp') * torch.abs(sdf)).reshape(-1,consis_constraint.shape[-1]) 33 | consis_constraint = consis_constraint * weight_moved -------------------------------------------------------------------------------- /img/towards1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mabaorui/TowardsBetterGradient/a60598f55d7be951031cb21e035d2913c709d11b/img/towards1.png -------------------------------------------------------------------------------- /img/towards2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mabaorui/TowardsBetterGradient/a60598f55d7be951031cb21e035d2913c709d11b/img/towards2.png --------------------------------------------------------------------------------