-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 02b9ace
Showing
17 changed files
with
468,884 additions
and
0 deletions.
There are no files selected for viewing
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
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 | ||
|
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
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) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .Normalizer import Normalizer | ||
from .MeshNormalizer import MeshNormalizer |
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
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. | ||
|
||
|
Oops, something went wrong.