Spaces:
Running on Zero
Running on Zero
Test
#16
by nick2200 - opened
- README.md +2 -2
- app.py +1 -51
- requirements.txt +9 -8
README.md
CHANGED
|
@@ -4,11 +4,11 @@ emoji: 📚
|
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
short_description: Create a 3D model from an image in 10 seconds!
|
| 11 |
license: apache-2.0
|
| 12 |
---
|
| 13 |
|
| 14 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: green
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.26.0
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
short_description: Create a 3D model from an image in 10 seconds!
|
| 11 |
license: apache-2.0
|
| 12 |
---
|
| 13 |
|
| 14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
|
@@ -13,57 +13,6 @@ from einops import rearrange, repeat
|
|
| 13 |
from tqdm import tqdm
|
| 14 |
from diffusers import DiffusionPipeline, EulerAncestralDiscreteScheduler
|
| 15 |
|
| 16 |
-
import subprocess, sys, glob, tempfile, ctypes
|
| 17 |
-
|
| 18 |
-
CUDA_HOME = "/cuda-image/usr/local/cuda-13.0"
|
| 19 |
-
CUDA_LIBDIR = os.path.join(CUDA_HOME, "lib64")
|
| 20 |
-
|
| 21 |
-
@spaces.GPU(duration=210)
|
| 22 |
-
def first_gpu_setup():
|
| 23 |
-
try:
|
| 24 |
-
import nvdiffrast # noqa: F401
|
| 25 |
-
print("nvdiffrast already installed; skipping build.")
|
| 26 |
-
return
|
| 27 |
-
except ImportError:
|
| 28 |
-
pass
|
| 29 |
-
|
| 30 |
-
if not os.path.exists(os.path.join(CUDA_HOME, "bin", "nvcc")):
|
| 31 |
-
raise RuntimeError(
|
| 32 |
-
f"nvcc not found at {CUDA_HOME}/bin/nvcc on the ZeroGPU worker. "
|
| 33 |
-
"The new-hardware CUDA path may have moved; please update CUDA_HOME."
|
| 34 |
-
)
|
| 35 |
-
|
| 36 |
-
patch_dir = tempfile.mkdtemp(prefix="torch_cuda_patch_")
|
| 37 |
-
with open(os.path.join(patch_dir, "sitecustomize.py"), "w") as f:
|
| 38 |
-
f.write(
|
| 39 |
-
"try:\n"
|
| 40 |
-
" import torch.utils.cpp_extension as _c\n"
|
| 41 |
-
" _c._check_cuda_version = lambda *a, **k: None\n"
|
| 42 |
-
"except Exception:\n"
|
| 43 |
-
" pass\n"
|
| 44 |
-
)
|
| 45 |
-
|
| 46 |
-
env = os.environ.copy()
|
| 47 |
-
env["CUDA_HOME"] = CUDA_HOME
|
| 48 |
-
env["CUDA_PATH"] = CUDA_HOME
|
| 49 |
-
env["PATH"] = os.path.join(CUDA_HOME, "bin") + os.pathsep + env.get("PATH", "")
|
| 50 |
-
env["PYTHONPATH"] = patch_dir + os.pathsep + env.get("PYTHONPATH", "")
|
| 51 |
-
env["TORCH_CUDA_ARCH_LIST"] = "12.0"
|
| 52 |
-
|
| 53 |
-
subprocess.check_call(
|
| 54 |
-
[sys.executable, "-m", "pip", "install", "--no-deps",
|
| 55 |
-
"setuptools", "wheel", "ninja"],
|
| 56 |
-
)
|
| 57 |
-
subprocess.check_call(
|
| 58 |
-
[sys.executable, "-m", "pip", "install", "--no-build-isolation",
|
| 59 |
-
"git+https://github.com/NVlabs/nvdiffrast/"],
|
| 60 |
-
env=env,
|
| 61 |
-
)
|
| 62 |
-
first_gpu_setup()
|
| 63 |
-
|
| 64 |
-
ctypes.CDLL(os.path.join(CUDA_LIBDIR, "libcudart.so.13"), mode=ctypes.RTLD_GLOBAL)
|
| 65 |
-
os.environ["LD_LIBRARY_PATH"] = CUDA_LIBDIR + os.pathsep + os.environ.get("LD_LIBRARY_PATH", "")
|
| 66 |
-
|
| 67 |
from src.utils.train_util import instantiate_from_config
|
| 68 |
from src.utils.camera_util import (
|
| 69 |
FOV_to_intrinsics,
|
|
@@ -80,6 +29,7 @@ from huggingface_hub import hf_hub_download
|
|
| 80 |
|
| 81 |
import gradio as gr
|
| 82 |
|
|
|
|
| 83 |
def get_render_cameras(batch_size=1, M=120, radius=2.5, elevation=10.0, is_flexicubes=False):
|
| 84 |
"""
|
| 85 |
Get the rendering camera parameters.
|
|
|
|
| 13 |
from tqdm import tqdm
|
| 14 |
from diffusers import DiffusionPipeline, EulerAncestralDiscreteScheduler
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
from src.utils.train_util import instantiate_from_config
|
| 17 |
from src.utils.camera_util import (
|
| 18 |
FOV_to_intrinsics,
|
|
|
|
| 29 |
|
| 30 |
import gradio as gr
|
| 31 |
|
| 32 |
+
|
| 33 |
def get_render_cameras(batch_size=1, M=120, radius=2.5, elevation=10.0, is_flexicubes=False):
|
| 34 |
"""
|
| 35 |
Get the rendering camera parameters.
|
requirements.txt
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
-
torch==2.
|
| 2 |
-
torchvision==0.
|
| 3 |
-
torchaudio==2.
|
| 4 |
-
pytorch-lightning
|
| 5 |
einops
|
| 6 |
omegaconf
|
| 7 |
deepspeed
|
|
@@ -12,11 +12,12 @@ tensorboard
|
|
| 12 |
PyMCubes
|
| 13 |
trimesh
|
| 14 |
rembg
|
| 15 |
-
transformers==4.
|
| 16 |
-
diffusers==0.
|
| 17 |
bitsandbytes
|
| 18 |
imageio[ffmpeg]
|
| 19 |
xatlas
|
| 20 |
plyfile
|
| 21 |
-
xformers
|
| 22 |
-
|
|
|
|
|
|
| 1 |
+
torch==2.1.0
|
| 2 |
+
torchvision==0.16.0
|
| 3 |
+
torchaudio==2.1.0
|
| 4 |
+
pytorch-lightning==2.1.2
|
| 5 |
einops
|
| 6 |
omegaconf
|
| 7 |
deepspeed
|
|
|
|
| 12 |
PyMCubes
|
| 13 |
trimesh
|
| 14 |
rembg
|
| 15 |
+
transformers==4.34.1
|
| 16 |
+
diffusers==0.19.3
|
| 17 |
bitsandbytes
|
| 18 |
imageio[ffmpeg]
|
| 19 |
xatlas
|
| 20 |
plyfile
|
| 21 |
+
xformers==0.0.22.post7
|
| 22 |
+
git+https://github.com/NVlabs/nvdiffrast/
|
| 23 |
+
huggingface-hub
|