Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
61757c6
1
Parent(s):
191990f
Implement temporary directory cleanup every 10 minutes and remove unused kaolin imports
Browse files- app.py +16 -0
- requirements.txt +0 -4
- trellis/renderers/mesh_renderer.py +0 -5
- trellis/representations/mesh/cube2mesh.py +0 -4
- trellis/representations/mesh/flexicube.py +0 -24
app.py
CHANGED
@@ -309,6 +309,22 @@ with gr.Blocks(title="Game Items Generator") as demo:
|
|
309 |
)
|
310 |
|
311 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
312 |
# Launch the Gradio app
|
313 |
if __name__ == "__main__":
|
314 |
pipeline = TrellisImageTo3DPipeline.from_pretrained("JeffreyXiang/TRELLIS-image-large")
|
|
|
309 |
)
|
310 |
|
311 |
|
312 |
+
# Cleans up the temporary directory every 10 minutes
|
313 |
+
import threading
|
314 |
+
import time
|
315 |
+
|
316 |
+
def cleanup_tmp_dir():
|
317 |
+
while True:
|
318 |
+
if os.path.exists(TMP_DIR):
|
319 |
+
for file in os.listdir(TMP_DIR):
|
320 |
+
# remove files older than 10 minutes
|
321 |
+
if time.time() - os.path.getmtime(os.path.join(TMP_DIR, file)) > 600:
|
322 |
+
os.remove(os.path.join(TMP_DIR, file))
|
323 |
+
time.sleep(600)
|
324 |
+
|
325 |
+
cleanup_thread = threading.Thread(target=cleanup_tmp_dir)
|
326 |
+
cleanup_thread.start()
|
327 |
+
|
328 |
# Launch the Gradio app
|
329 |
if __name__ == "__main__":
|
330 |
pipeline = TrellisImageTo3DPipeline.from_pretrained("JeffreyXiang/TRELLIS-image-large")
|
requirements.txt
CHANGED
@@ -1,7 +1,5 @@
|
|
1 |
--extra-index-url https://download.pytorch.org/whl/cu121
|
2 |
-
--find-links https://nvidia-kaolin.s3.us-east-2.amazonaws.com/torch-2.4.0_cu121.html
|
3 |
|
4 |
-
spaces
|
5 |
torch==2.4.0
|
6 |
torchvision==0.19.0
|
7 |
pillow==10.4.0
|
@@ -20,10 +18,8 @@ pymeshfix==0.17.0
|
|
20 |
igraph==0.11.8
|
21 |
git+https://github.com/EasternJournalist/utils3d.git@9a4eb15e4021b67b12c460c7057d642626897ec8
|
22 |
xformers==0.0.27.post2
|
23 |
-
kaolin==0.17.0
|
24 |
spconv-cu120==2.3.6
|
25 |
transformers==4.46.3
|
26 |
-
gradio_litmodel3d==0.0.1
|
27 |
https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.0.post2/flash_attn-2.7.0.post2+cu12torch2.4cxx11abiFALSE-cp310-cp310-linux_x86_64.whl
|
28 |
https://huggingface.co/spaces/JeffreyXiang/TRELLIS/resolve/main/wheels/diff_gaussian_rasterization-0.0.0-cp310-cp310-linux_x86_64.whl?download=true
|
29 |
https://huggingface.co/spaces/JeffreyXiang/TRELLIS/resolve/main/wheels/nvdiffrast-0.3.3-cp310-cp310-linux_x86_64.whl?download=true
|
|
|
1 |
--extra-index-url https://download.pytorch.org/whl/cu121
|
|
|
2 |
|
|
|
3 |
torch==2.4.0
|
4 |
torchvision==0.19.0
|
5 |
pillow==10.4.0
|
|
|
18 |
igraph==0.11.8
|
19 |
git+https://github.com/EasternJournalist/utils3d.git@9a4eb15e4021b67b12c460c7057d642626897ec8
|
20 |
xformers==0.0.27.post2
|
|
|
21 |
spconv-cu120==2.3.6
|
22 |
transformers==4.46.3
|
|
|
23 |
https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.0.post2/flash_attn-2.7.0.post2+cu12torch2.4cxx11abiFALSE-cp310-cp310-linux_x86_64.whl
|
24 |
https://huggingface.co/spaces/JeffreyXiang/TRELLIS/resolve/main/wheels/diff_gaussian_rasterization-0.0.0-cp310-cp310-linux_x86_64.whl?download=true
|
25 |
https://huggingface.co/spaces/JeffreyXiang/TRELLIS/resolve/main/wheels/nvdiffrast-0.3.3-cp310-cp310-linux_x86_64.whl?download=true
|
trellis/renderers/mesh_renderer.py
CHANGED
@@ -6,11 +6,6 @@
|
|
6 |
# distribution of this software and related documentation without an express
|
7 |
# license agreement from NVIDIA CORPORATION & AFFILIATES is strictly prohibited.
|
8 |
import torch
|
9 |
-
try:
|
10 |
-
import kaolin as kal
|
11 |
-
import nvdiffrast.torch as dr
|
12 |
-
except :
|
13 |
-
print("Kaolin and nvdiffrast are not installed. Please install them to use the mesh renderer.")
|
14 |
from easydict import EasyDict as edict
|
15 |
from ..representations.mesh import MeshExtractResult
|
16 |
import torch.nn.functional as F
|
|
|
6 |
# distribution of this software and related documentation without an express
|
7 |
# license agreement from NVIDIA CORPORATION & AFFILIATES is strictly prohibited.
|
8 |
import torch
|
|
|
|
|
|
|
|
|
|
|
9 |
from easydict import EasyDict as edict
|
10 |
from ..representations.mesh import MeshExtractResult
|
11 |
import torch.nn.functional as F
|
trellis/representations/mesh/cube2mesh.py
CHANGED
@@ -9,10 +9,6 @@ import torch
|
|
9 |
from ...modules.sparse import SparseTensor
|
10 |
from easydict import EasyDict as edict
|
11 |
from .utils_cube import *
|
12 |
-
try:
|
13 |
-
from .flexicube import FlexiCubes
|
14 |
-
except:
|
15 |
-
print("Please install kaolin and diso to use the mesh extractor.")
|
16 |
|
17 |
|
18 |
class MeshExtractResult:
|
|
|
9 |
from ...modules.sparse import SparseTensor
|
10 |
from easydict import EasyDict as edict
|
11 |
from .utils_cube import *
|
|
|
|
|
|
|
|
|
12 |
|
13 |
|
14 |
class MeshExtractResult:
|
trellis/representations/mesh/flexicube.py
CHANGED
@@ -8,7 +8,6 @@
|
|
8 |
|
9 |
import torch
|
10 |
from .tables import *
|
11 |
-
from kaolin.utils.testing import check_tensor
|
12 |
|
13 |
__all__ = [
|
14 |
'FlexiCubes'
|
@@ -49,29 +48,6 @@ class FlexiCubes:
|
|
49 |
|
50 |
def __call__(self, voxelgrid_vertices, scalar_field, cube_idx, resolution, qef_reg_scale=1e-3,
|
51 |
weight_scale=0.99, beta=None, alpha=None, gamma_f=None, voxelgrid_colors=None, training=False):
|
52 |
-
assert torch.is_tensor(voxelgrid_vertices) and \
|
53 |
-
check_tensor(voxelgrid_vertices, (None, 3), throw=False), \
|
54 |
-
"'voxelgrid_vertices' should be a tensor of shape (num_vertices, 3)"
|
55 |
-
num_vertices = voxelgrid_vertices.shape[0]
|
56 |
-
assert torch.is_tensor(scalar_field) and \
|
57 |
-
check_tensor(scalar_field, (num_vertices,), throw=False), \
|
58 |
-
"'scalar_field' should be a tensor of shape (num_vertices,)"
|
59 |
-
assert torch.is_tensor(cube_idx) and \
|
60 |
-
check_tensor(cube_idx, (None, 8), throw=False), \
|
61 |
-
"'cube_idx' should be a tensor of shape (num_cubes, 8)"
|
62 |
-
num_cubes = cube_idx.shape[0]
|
63 |
-
assert beta is None or (
|
64 |
-
torch.is_tensor(beta) and
|
65 |
-
check_tensor(beta, (num_cubes, 12), throw=False)
|
66 |
-
), "'beta' should be a tensor of shape (num_cubes, 12)"
|
67 |
-
assert alpha is None or (
|
68 |
-
torch.is_tensor(alpha) and
|
69 |
-
check_tensor(alpha, (num_cubes, 8), throw=False)
|
70 |
-
), "'alpha' should be a tensor of shape (num_cubes, 8)"
|
71 |
-
assert gamma_f is None or (
|
72 |
-
torch.is_tensor(gamma_f) and
|
73 |
-
check_tensor(gamma_f, (num_cubes,), throw=False)
|
74 |
-
), "'gamma_f' should be a tensor of shape (num_cubes,)"
|
75 |
|
76 |
surf_cubes, occ_fx8 = self._identify_surf_cubes(scalar_field, cube_idx)
|
77 |
if surf_cubes.sum() == 0:
|
|
|
8 |
|
9 |
import torch
|
10 |
from .tables import *
|
|
|
11 |
|
12 |
__all__ = [
|
13 |
'FlexiCubes'
|
|
|
48 |
|
49 |
def __call__(self, voxelgrid_vertices, scalar_field, cube_idx, resolution, qef_reg_scale=1e-3,
|
50 |
weight_scale=0.99, beta=None, alpha=None, gamma_f=None, voxelgrid_colors=None, training=False):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
surf_cubes, occ_fx8 = self._identify_surf_cubes(scalar_field, cube_idx)
|
53 |
if surf_cubes.sum() == 0:
|