Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,28 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
-
@spaces.GPU
|
4 |
def image_to_3d(
|
5 |
image: Image.Image,
|
6 |
seed: int,
|
@@ -107,7 +129,6 @@ def image_to_3d(
|
|
107 |
torch.cuda.empty_cache()
|
108 |
raise gr.Error(f"Processing failed: {str(e)}")
|
109 |
|
110 |
-
@spaces.GPU
|
111 |
def extract_reduced_glb(
|
112 |
state: dict,
|
113 |
mesh_simplify: float,
|
@@ -146,9 +167,9 @@ def extract_reduced_glb(
|
|
146 |
torch.cuda.empty_cache()
|
147 |
raise gr.Error(f"GLB reduction failed: {str(e)}")
|
148 |
|
149 |
-
#
|
|
|
150 |
|
151 |
-
# Add some memory optimization settings at startup
|
152 |
if __name__ == "__main__":
|
153 |
# Set some CUDA memory management options
|
154 |
torch.cuda.empty_cache()
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from gradio_litmodel3d import LitModel3D
|
3 |
+
|
4 |
+
import os
|
5 |
+
import shutil
|
6 |
+
os.environ['SPCONV_ALGO'] = 'native'
|
7 |
+
from typing import *
|
8 |
+
import torch
|
9 |
+
import numpy as np
|
10 |
+
import imageio
|
11 |
+
import uuid
|
12 |
+
from easydict import EasyDict as edict
|
13 |
+
from PIL import Image
|
14 |
+
from trellis.pipelines import TrellisImageTo3DPipeline
|
15 |
+
from trellis.representations import Gaussian, MeshExtractResult
|
16 |
+
from trellis.utils import render_utils, postprocessing_utils
|
17 |
+
|
18 |
+
|
19 |
+
MAX_SEED = np.iinfo(np.int32).max
|
20 |
+
TMP_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'tmp')
|
21 |
+
os.makedirs(TMP_DIR, exist_ok=True)
|
22 |
+
|
23 |
+
# Rest of the utility functions remain the same...
|
24 |
+
[Previous utility functions: start_session, end_session, preprocess_image, pack_state, unpack_state, get_seed]
|
25 |
|
|
|
26 |
def image_to_3d(
|
27 |
image: Image.Image,
|
28 |
seed: int,
|
|
|
129 |
torch.cuda.empty_cache()
|
130 |
raise gr.Error(f"Processing failed: {str(e)}")
|
131 |
|
|
|
132 |
def extract_reduced_glb(
|
133 |
state: dict,
|
134 |
mesh_simplify: float,
|
|
|
167 |
torch.cuda.empty_cache()
|
168 |
raise gr.Error(f"GLB reduction failed: {str(e)}")
|
169 |
|
170 |
+
# Rest of the UI code and demo definition remains the same...
|
171 |
+
[Previous UI code with Blocks, event handlers, etc.]
|
172 |
|
|
|
173 |
if __name__ == "__main__":
|
174 |
# Set some CUDA memory management options
|
175 |
torch.cuda.empty_cache()
|