Skip to content

Commit

Permalink
Supplemental code upload
Browse files Browse the repository at this point in the history
  • Loading branch information
factoryofthesun authored Nov 25, 2021
0 parents commit 02b9ace
Show file tree
Hide file tree
Showing 17 changed files with 468,884 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Normalization/MeshNormalizer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import copy
from . import Normalizer


class MeshNormalizer:
def __init__(self, mesh):
self._mesh = mesh # original copy of the mesh
self.normalizer = Normalizer.get_bounding_sphere_normalizer(self._mesh.vertices)

def __call__(self):
self._mesh.vertices = self.normalizer(self._mesh.vertices)
return self._mesh

27 changes: 27 additions & 0 deletions Normalization/Normalizer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import torch


class Normalizer:
@classmethod
def get_bounding_box_normalizer(cls, x):
shift = torch.mean(x, dim=0)
scale = torch.max(torch.norm(x-shift, p=1, dim=1))
return Normalizer(scale=scale, shift=shift)

@classmethod
def get_bounding_sphere_normalizer(cls, x):
shift = torch.mean(x, dim=0)
scale = torch.max(torch.norm(x-shift, p=2, dim=1))
return Normalizer(scale=scale, shift=shift)

def __init__(self, scale, shift):
self._scale = scale
self._shift = shift

def __call__(self, x):
return (x-self._shift) / self._scale

def get_de_normalizer(self):
inv_scale = 1 / self._scale
inv_shift = -self._shift / self._scale
return Normalizer(scale=inv_scale, shift=inv_shift)
2 changes: 2 additions & 0 deletions Normalization/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from .Normalizer import Normalizer
from .MeshNormalizer import MeshNormalizer
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Text2Mesh Demo Code

## Installation
```
conda env create --file text2mesh.yml
conda activate text2mesh
```

## System Requirements
- Python == 3.7
- CUDA == 10.2.0
- GPU w/ 8 GB ram, CUDA 10.2 compatible

## Run example
Call the below shell scripts to generate example styles.
```bash
# batman
./run_batman.sh
# shoe made of cactus
./run_shoe.sh
# colorful crochet vase
./run_vase.sh
```
The outputs will be saved to `results/demo`, with the stylized .obj files, colored and uncolored render views, and screenshots during training.


Loading

0 comments on commit 02b9ace

Please sign in to comment.