Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -8,6 +8,9 @@ from typing import Any, Union
|
|
| 8 |
|
| 9 |
import numpy as np
|
| 10 |
import torch
|
|
|
|
|
|
|
|
|
|
| 11 |
import trimesh
|
| 12 |
from huggingface_hub import snapshot_download
|
| 13 |
from PIL import Image
|
|
@@ -18,6 +21,42 @@ from src.utils.render_utils import render_views_around_mesh, render_normal_views
|
|
| 18 |
from src.pipelines.pipeline_partcrafter import PartCrafterPipeline
|
| 19 |
from src.utils.image_utils import prepare_image
|
| 20 |
from src.models.briarmbg import BriaRMBG
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
# Constants
|
| 23 |
MAX_NUM_PARTS = 16
|
|
|
|
| 8 |
|
| 9 |
import numpy as np
|
| 10 |
import torch
|
| 11 |
+
|
| 12 |
+
print(f'torch version:{torch.__version__}')
|
| 13 |
+
|
| 14 |
import trimesh
|
| 15 |
from huggingface_hub import snapshot_download
|
| 16 |
from PIL import Image
|
|
|
|
| 21 |
from src.pipelines.pipeline_partcrafter import PartCrafterPipeline
|
| 22 |
from src.utils.image_utils import prepare_image
|
| 23 |
from src.models.briarmbg import BriaRMBG
|
| 24 |
+
import subprocess
|
| 25 |
+
import importlib, site, sys
|
| 26 |
+
|
| 27 |
+
# Re-discover all .pth/.egg-link files
|
| 28 |
+
for sitedir in site.getsitepackages():
|
| 29 |
+
site.addsitedir(sitedir)
|
| 30 |
+
|
| 31 |
+
# Clear caches so importlib will pick up new modules
|
| 32 |
+
importlib.invalidate_caches()
|
| 33 |
+
|
| 34 |
+
def sh(cmd): subprocess.check_call(cmd, shell=True)
|
| 35 |
+
|
| 36 |
+
def install_cuda_toolkit():
|
| 37 |
+
CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/12.1.0/local_installers/cuda_12.1.0_530.30.02_linux.run"
|
| 38 |
+
CUDA_TOOLKIT_FILE = "/tmp/%s" % os.path.basename(CUDA_TOOLKIT_URL)
|
| 39 |
+
subprocess.call(["wget", "-q", CUDA_TOOLKIT_URL, "-O", CUDA_TOOLKIT_FILE])
|
| 40 |
+
subprocess.call(["chmod", "+x", CUDA_TOOLKIT_FILE])
|
| 41 |
+
subprocess.call([CUDA_TOOLKIT_FILE, "--silent", "--toolkit"])
|
| 42 |
+
|
| 43 |
+
os.environ["CUDA_HOME"] = "/usr/local/cuda"
|
| 44 |
+
os.environ["PATH"] = "%s/bin:%s" % (os.environ["CUDA_HOME"], os.environ["PATH"])
|
| 45 |
+
os.environ["LD_LIBRARY_PATH"] = "%s/lib:%s" % (
|
| 46 |
+
os.environ["CUDA_HOME"],
|
| 47 |
+
"" if "LD_LIBRARY_PATH" not in os.environ else os.environ["LD_LIBRARY_PATH"],
|
| 48 |
+
)
|
| 49 |
+
# Fix: arch_list[-1] += '+PTX'; IndexError: list index out of range
|
| 50 |
+
os.environ["TORCH_CUDA_ARCH_LIST"] = "9.0"
|
| 51 |
+
print("==> finished installation")
|
| 52 |
+
|
| 53 |
+
install_cuda_toolkit()
|
| 54 |
+
|
| 55 |
+
sh("pip install diso")
|
| 56 |
+
|
| 57 |
+
# tell Python to re-scan site-packages now that the egg-link exists
|
| 58 |
+
import importlib, site; site.addsitedir(site.getsitepackages()[0]); importlib.invalidate_caches()
|
| 59 |
+
|
| 60 |
|
| 61 |
# Constants
|
| 62 |
MAX_NUM_PARTS = 16
|