Spaces:
Paused
Paused
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import spaces
|
| 3 |
from gradio_litmodel3d import LitModel3D
|
| 4 |
|
| 5 |
import os
|
|
@@ -107,7 +107,6 @@ def get_seed(randomize_seed: bool, seed: int) -> int:
|
|
| 107 |
return np.random.randint(0, MAX_SEED) if randomize_seed else seed
|
| 108 |
|
| 109 |
|
| 110 |
-
@spaces.GPU
|
| 111 |
def image_to_3d(
|
| 112 |
image: Image.Image,
|
| 113 |
multiimages: List[Tuple[Image.Image, str]],
|
|
@@ -180,7 +179,6 @@ def image_to_3d(
|
|
| 180 |
return state, video_path
|
| 181 |
|
| 182 |
|
| 183 |
-
@spaces.GPU(duration=90)
|
| 184 |
def extract_glb(
|
| 185 |
state: dict,
|
| 186 |
mesh_simplify: float,
|
|
@@ -207,7 +205,6 @@ def extract_glb(
|
|
| 207 |
return glb_path, glb_path
|
| 208 |
|
| 209 |
|
| 210 |
-
@spaces.GPU
|
| 211 |
def extract_gaussian(state: dict, req: gr.Request) -> Tuple[str, str]:
|
| 212 |
"""
|
| 213 |
Extract a Gaussian file from the 3D model.
|
|
@@ -255,6 +252,17 @@ def split_image(image: Image.Image) -> List[Image.Image]:
|
|
| 255 |
return [preprocess_image(image) for image in images]
|
| 256 |
|
| 257 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
with gr.Blocks(delete_cache=(600, 600)) as demo:
|
| 259 |
gr.Markdown("""
|
| 260 |
## Image to 3D Asset with [TRELLIS](https://github.com/microsoft/TRELLIS)
|
|
@@ -406,10 +414,5 @@ with gr.Blocks(delete_cache=(600, 600)) as demo:
|
|
| 406 |
|
| 407 |
# Launch the Gradio app
|
| 408 |
if __name__ == "__main__":
|
| 409 |
-
pipeline = TrellisImageTo3DPipeline.from_pretrained("microsoft/TRELLIS-image-large")
|
| 410 |
-
pipeline.cuda()
|
| 411 |
-
try:
|
| 412 |
-
pipeline.preprocess_image(Image.fromarray(np.zeros((512, 512, 3), dtype=np.uint8))) # Preload rembg
|
| 413 |
-
except:
|
| 414 |
pass
|
| 415 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
# import spaces # Not needed on dedicated GPU
|
| 3 |
from gradio_litmodel3d import LitModel3D
|
| 4 |
|
| 5 |
import os
|
|
|
|
| 107 |
return np.random.randint(0, MAX_SEED) if randomize_seed else seed
|
| 108 |
|
| 109 |
|
|
|
|
| 110 |
def image_to_3d(
|
| 111 |
image: Image.Image,
|
| 112 |
multiimages: List[Tuple[Image.Image, str]],
|
|
|
|
| 179 |
return state, video_path
|
| 180 |
|
| 181 |
|
|
|
|
| 182 |
def extract_glb(
|
| 183 |
state: dict,
|
| 184 |
mesh_simplify: float,
|
|
|
|
| 205 |
return glb_path, glb_path
|
| 206 |
|
| 207 |
|
|
|
|
| 208 |
def extract_gaussian(state: dict, req: gr.Request) -> Tuple[str, str]:
|
| 209 |
"""
|
| 210 |
Extract a Gaussian file from the 3D model.
|
|
|
|
| 252 |
return [preprocess_image(image) for image in images]
|
| 253 |
|
| 254 |
|
| 255 |
+
|
| 256 |
+
# Initialize pipeline (dedicated GPU - load at startup)
|
| 257 |
+
pipeline = TrellisImageTo3DPipeline.from_pretrained("microsoft/TRELLIS-image-large")
|
| 258 |
+
pipeline.cuda()
|
| 259 |
+
try:
|
| 260 |
+
pipeline.preprocess_image(Image.fromarray(np.zeros((512, 512, 3), dtype=np.uint8))) # Preload rembg
|
| 261 |
+
except:
|
| 262 |
+
pass
|
| 263 |
+
print("Pipeline loaded successfully")
|
| 264 |
+
|
| 265 |
+
|
| 266 |
with gr.Blocks(delete_cache=(600, 600)) as demo:
|
| 267 |
gr.Markdown("""
|
| 268 |
## Image to 3D Asset with [TRELLIS](https://github.com/microsoft/TRELLIS)
|
|
|
|
| 414 |
|
| 415 |
# Launch the Gradio app
|
| 416 |
if __name__ == "__main__":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 417 |
pass
|
| 418 |
demo.launch()
|