Spaces:
Running
on
L40S
Running
on
L40S
Upload app_hg.py with huggingface_hub
Browse files
app_hg.py
CHANGED
@@ -34,68 +34,67 @@ from PIL import Image
|
|
34 |
from einops import rearrange
|
35 |
import pandas as pd
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
#
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
#
|
57 |
-
|
58 |
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
|
96 |
-
#
|
97 |
-
|
98 |
-
|
99 |
|
100 |
from infer import seed_everything, save_gif
|
101 |
from infer import Text2Image, Removebg, Image2Views, Views2Mesh, GifRenderer
|
|
|
34 |
from einops import rearrange
|
35 |
import pandas as pd
|
36 |
|
37 |
+
import sys
|
38 |
+
import spaces
|
39 |
+
import subprocess
|
40 |
+
from huggingface_hub import snapshot_download
|
41 |
+
|
42 |
+
def install_cuda_toolkit():
|
43 |
+
# CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run"
|
44 |
+
CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda_12.2.0_535.54.03_linux.run"
|
45 |
+
CUDA_TOOLKIT_FILE = "/tmp/%s" % os.path.basename(CUDA_TOOLKIT_URL)
|
46 |
+
subprocess.call(["wget", "-q", CUDA_TOOLKIT_URL, "-O", CUDA_TOOLKIT_FILE])
|
47 |
+
subprocess.call(["chmod", "+x", CUDA_TOOLKIT_FILE])
|
48 |
+
subprocess.call([CUDA_TOOLKIT_FILE, "--silent", "--toolkit"])
|
49 |
+
|
50 |
+
os.environ["CUDA_HOME"] = "/usr/local/cuda"
|
51 |
+
os.environ["PATH"] = "%s/bin:%s" % (os.environ["CUDA_HOME"], os.environ["PATH"])
|
52 |
+
os.environ["LD_LIBRARY_PATH"] = "%s/lib:%s" % (
|
53 |
+
os.environ["CUDA_HOME"],
|
54 |
+
"" if "LD_LIBRARY_PATH" not in os.environ else os.environ["LD_LIBRARY_PATH"],
|
55 |
+
)
|
56 |
+
# Fix: arch_list[-1] += '+PTX'; IndexError: list index out of range
|
57 |
+
os.environ["TORCH_CUDA_ARCH_LIST"] = "8.0;8.6"
|
58 |
|
59 |
+
def install_requirements():
|
60 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", "git+https://github.com/NVlabs/nvdiffrast"])
|
61 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", "git+https://github.com/facebookresearch/pytorch3d@stable"])
|
|
|
62 |
|
63 |
+
def download_models():
|
64 |
+
os.makedirs("weights", exist_ok=True)
|
65 |
+
os.makedirs("weights/hunyuanDiT", exist_ok=True)
|
66 |
+
os.makedirs("third_party/weights/DUSt3R_ViTLarge_BaseDecoder_512_dpt", exist_ok=True)
|
67 |
+
try:
|
68 |
+
snapshot_download(
|
69 |
+
repo_id="tencent/Hunyuan3D-1",
|
70 |
+
local_dir="./weights",
|
71 |
+
resume_download=True
|
72 |
+
)
|
73 |
+
print("Successfully downloaded Hunyuan3D-1 model")
|
74 |
+
except Exception as e:
|
75 |
+
print(f"Error downloading Hunyuan3D-1: {e}")
|
76 |
+
try:
|
77 |
+
snapshot_download(
|
78 |
+
repo_id="Tencent-Hunyuan/HunyuanDiT-v1.1-Diffusers-Distilled",
|
79 |
+
local_dir="./weights/hunyuanDiT",
|
80 |
+
resume_download=True
|
81 |
+
)
|
82 |
+
print("Successfully downloaded HunyuanDiT model")
|
83 |
+
except Exception as e:
|
84 |
+
print(f"Error downloading HunyuanDiT: {e}")
|
85 |
+
try:
|
86 |
+
snapshot_download(
|
87 |
+
repo_id="naver/DUSt3R_ViTLarge_BaseDecoder_512_dpt",
|
88 |
+
local_dir="./third_party/weights/DUSt3R_ViTLarge_BaseDecoder_512_dpt",
|
89 |
+
resume_download=True
|
90 |
+
)
|
91 |
+
print("Successfully downloaded DUSt3R model")
|
92 |
+
except Exception as e:
|
93 |
+
print(f"Error downloading DUSt3R: {e}")
|
94 |
|
95 |
+
# install_cuda_toolkit()
|
96 |
+
install_requirements()
|
97 |
+
download_models() ### download weights !!!!
|
98 |
|
99 |
from infer import seed_everything, save_gif
|
100 |
from infer import Text2Image, Removebg, Image2Views, Views2Mesh, GifRenderer
|