Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,8 @@ from gradio_litmodel3d import LitModel3D
|
|
| 4 |
import os
|
| 5 |
import shutil
|
| 6 |
os.environ['SPCONV_ALGO'] = 'native'
|
|
|
|
|
|
|
| 7 |
from easydict import EasyDict as edict
|
| 8 |
from PIL import Image, ImageOps
|
| 9 |
from trellis.pipelines import TrellisImageTo3DPipeline
|
|
@@ -51,10 +53,16 @@ def start_session(req: gr.Request):
|
|
| 51 |
def end_session(req: gr.Request):
|
| 52 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
| 53 |
shutil.rmtree(user_dir)
|
|
|
|
|
|
|
| 54 |
def preprocess_image(
|
| 55 |
image: Image.Image,
|
| 56 |
prompt: str = "",
|
| 57 |
negative_prompt: str = "",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
style_name: str = "",
|
| 59 |
num_steps: int = 25,
|
| 60 |
guidance_scale: float = 5,
|
|
@@ -140,6 +148,10 @@ def get_seed(randomize_seed: bool, seed: int) -> int:
|
|
| 140 |
@spaces.GPU
|
| 141 |
def image_to_3d(
|
| 142 |
image: Image.Image,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
slat_sampling_steps: int,
|
| 144 |
req: gr.Request,
|
| 145 |
) -> Tuple[dict, str]:
|
|
@@ -151,6 +163,10 @@ def image_to_3d(
|
|
| 151 |
preprocess_image=False,
|
| 152 |
sparse_structure_sampler_params={
|
| 153 |
"steps": ss_sampling_steps,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
"cfg_strength": slat_guidance_strength,
|
| 155 |
},
|
| 156 |
)
|
|
|
|
| 4 |
import os
|
| 5 |
import shutil
|
| 6 |
os.environ['SPCONV_ALGO'] = 'native'
|
| 7 |
+
from typing import *
|
| 8 |
+
import imageio
|
| 9 |
from easydict import EasyDict as edict
|
| 10 |
from PIL import Image, ImageOps
|
| 11 |
from trellis.pipelines import TrellisImageTo3DPipeline
|
|
|
|
| 53 |
def end_session(req: gr.Request):
|
| 54 |
user_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
| 55 |
shutil.rmtree(user_dir)
|
| 56 |
+
|
| 57 |
+
@spaces.GPU
|
| 58 |
def preprocess_image(
|
| 59 |
image: Image.Image,
|
| 60 |
prompt: str = "",
|
| 61 |
negative_prompt: str = "",
|
| 62 |
+
image=image,
|
| 63 |
+
num_inference_steps=num_steps,
|
| 64 |
+
controlnet_conditioning_scale=controlnet_conditioning_scale,
|
| 65 |
+
guidance_scale=guidance_scale,
|
| 66 |
style_name: str = "",
|
| 67 |
num_steps: int = 25,
|
| 68 |
guidance_scale: float = 5,
|
|
|
|
| 148 |
@spaces.GPU
|
| 149 |
def image_to_3d(
|
| 150 |
image: Image.Image,
|
| 151 |
+
seed: int,
|
| 152 |
+
ss_guidance_strength: float,
|
| 153 |
+
ss_sampling_steps: int,
|
| 154 |
+
slat_guidance_strength: float,
|
| 155 |
slat_sampling_steps: int,
|
| 156 |
req: gr.Request,
|
| 157 |
) -> Tuple[dict, str]:
|
|
|
|
| 163 |
preprocess_image=False,
|
| 164 |
sparse_structure_sampler_params={
|
| 165 |
"steps": ss_sampling_steps,
|
| 166 |
+
"cfg_strength": ss_guidance_strength,
|
| 167 |
+
},
|
| 168 |
+
slat_sampler_params={
|
| 169 |
+
"steps": slat_sampling_steps,
|
| 170 |
"cfg_strength": slat_guidance_strength,
|
| 171 |
},
|
| 172 |
)
|