Spaces:
Runtime error
Runtime error
Commit
ยท
9ad025b
1
Parent(s):
b0d06b4
update
Browse files
app.py
CHANGED
|
@@ -11,6 +11,7 @@ from torchvision import transforms
|
|
| 11 |
from huggingface_hub import hf_hub_download, snapshot_download
|
| 12 |
import subprocess
|
| 13 |
import shutil
|
|
|
|
| 14 |
|
| 15 |
# install others
|
| 16 |
#subprocess.run("pip install spandrel==0.4.1 --no-deps", shell=True, check=True)
|
|
@@ -159,6 +160,7 @@ def run_full(image: str, req: gr.Request):
|
|
| 159 |
mesh.export(mesh_path)
|
| 160 |
print("save to ", mesh_path)
|
| 161 |
|
|
|
|
| 162 |
torch.cuda.empty_cache()
|
| 163 |
|
| 164 |
height, width = 768, 768
|
|
@@ -221,6 +223,7 @@ def run_full(image: str, req: gr.Request):
|
|
| 221 |
**pipe_kwargs,
|
| 222 |
).images
|
| 223 |
|
|
|
|
| 224 |
torch.cuda.empty_cache()
|
| 225 |
|
| 226 |
mv_image_path = os.path.join(save_dir, f"mv_adapter_{get_random_hex()}.png")
|
|
@@ -244,6 +247,9 @@ def run_full(image: str, req: gr.Request):
|
|
| 244 |
camera_azimuth_deg=[x - 90 for x in [0, 90, 180, 270, 180, 180]],
|
| 245 |
)
|
| 246 |
|
|
|
|
|
|
|
|
|
|
| 247 |
return image_seg, mesh_path, textured_glb_path
|
| 248 |
|
| 249 |
|
|
@@ -283,6 +289,7 @@ def image_to_3d(
|
|
| 283 |
mesh.export(mesh_path)
|
| 284 |
print("save to ", mesh_path)
|
| 285 |
|
|
|
|
| 286 |
torch.cuda.empty_cache()
|
| 287 |
|
| 288 |
return mesh_path
|
|
@@ -350,6 +357,7 @@ def run_texture(image: Image, mesh_path: str, seed: int, req: gr.Request):
|
|
| 350 |
**pipe_kwargs,
|
| 351 |
).images
|
| 352 |
|
|
|
|
| 353 |
torch.cuda.empty_cache()
|
| 354 |
|
| 355 |
save_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
|
@@ -373,6 +381,8 @@ def run_texture(image: Image, mesh_path: str, seed: int, req: gr.Request):
|
|
| 373 |
rgb_process_config=ModProcessConfig(view_upscale=True, inpaint_mode="view"),
|
| 374 |
camera_azimuth_deg=[x - 90 for x in [0, 90, 180, 270, 180, 180]],
|
| 375 |
)
|
|
|
|
|
|
|
| 376 |
|
| 377 |
return textured_glb_path
|
| 378 |
|
|
|
|
| 11 |
from huggingface_hub import hf_hub_download, snapshot_download
|
| 12 |
import subprocess
|
| 13 |
import shutil
|
| 14 |
+
import gc
|
| 15 |
|
| 16 |
# install others
|
| 17 |
#subprocess.run("pip install spandrel==0.4.1 --no-deps", shell=True, check=True)
|
|
|
|
| 160 |
mesh.export(mesh_path)
|
| 161 |
print("save to ", mesh_path)
|
| 162 |
|
| 163 |
+
gc.collect()
|
| 164 |
torch.cuda.empty_cache()
|
| 165 |
|
| 166 |
height, width = 768, 768
|
|
|
|
| 223 |
**pipe_kwargs,
|
| 224 |
).images
|
| 225 |
|
| 226 |
+
gc.collect()
|
| 227 |
torch.cuda.empty_cache()
|
| 228 |
|
| 229 |
mv_image_path = os.path.join(save_dir, f"mv_adapter_{get_random_hex()}.png")
|
|
|
|
| 247 |
camera_azimuth_deg=[x - 90 for x in [0, 90, 180, 270, 180, 180]],
|
| 248 |
)
|
| 249 |
|
| 250 |
+
gc.collect()
|
| 251 |
+
torch.cuda.empty_cache()
|
| 252 |
+
|
| 253 |
return image_seg, mesh_path, textured_glb_path
|
| 254 |
|
| 255 |
|
|
|
|
| 289 |
mesh.export(mesh_path)
|
| 290 |
print("save to ", mesh_path)
|
| 291 |
|
| 292 |
+
gc.collect()
|
| 293 |
torch.cuda.empty_cache()
|
| 294 |
|
| 295 |
return mesh_path
|
|
|
|
| 357 |
**pipe_kwargs,
|
| 358 |
).images
|
| 359 |
|
| 360 |
+
gc.collect()
|
| 361 |
torch.cuda.empty_cache()
|
| 362 |
|
| 363 |
save_dir = os.path.join(TMP_DIR, str(req.session_hash))
|
|
|
|
| 381 |
rgb_process_config=ModProcessConfig(view_upscale=True, inpaint_mode="view"),
|
| 382 |
camera_azimuth_deg=[x - 90 for x in [0, 90, 180, 270, 180, 180]],
|
| 383 |
)
|
| 384 |
+
gc.collect()
|
| 385 |
+
torch.cuda.empty_cache()
|
| 386 |
|
| 387 |
return textured_glb_path
|
| 388 |
|