Spaces:
Runtime error
Runtime error
Commit
•
5a25b6c
1
Parent(s):
c873cdd
ZeroGPU (#1)
Browse files- Update for ZeroGPU (96ac7583f174bd1f763701aba94c15160164daf7)
Co-authored-by: hysts <[email protected]>
- .gitattributes +1 -0
- Dockerfile +0 -61
- README.md +3 -2
- app.py +6 -2
- requirements.txt +2 -2
- wheel/torchmcubes-0.1.0-cp310-cp310-linux_x86_64.whl +3 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
*.whl filter=lfs diff=lfs merge=lfs -text
|
Dockerfile
DELETED
@@ -1,61 +0,0 @@
|
|
1 |
-
FROM nvidia/cuda:11.8.0-devel-ubuntu20.04
|
2 |
-
|
3 |
-
ARG DEBIAN_FRONTEND=noninteractive
|
4 |
-
|
5 |
-
ENV PYTHONUNBUFFERED=1
|
6 |
-
|
7 |
-
ENV TORCH_CUDA_ARCH_LIST="6.0 6.1 7.0 7.5 8.0 8.6"
|
8 |
-
ENV TCNN_CUDA_ARCHITECTURES=86;80;75;70;61;60
|
9 |
-
ENV FORCE_CUDA=1
|
10 |
-
|
11 |
-
ENV CUDA_HOME=/usr/local/cuda
|
12 |
-
ENV PATH=${CUDA_HOME}/bin:/home/${USER_NAME}/.local/bin:${PATH}
|
13 |
-
ENV LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
|
14 |
-
ENV LIBRARY_PATH=${CUDA_HOME}/lib64/stubs:${LIBRARY_PATH}
|
15 |
-
|
16 |
-
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
17 |
-
build-essential \
|
18 |
-
curl \
|
19 |
-
git \
|
20 |
-
libegl1-mesa-dev \
|
21 |
-
libgl1-mesa-dev \
|
22 |
-
libgles2-mesa-dev \
|
23 |
-
libglib2.0-0 \
|
24 |
-
libsm6 \
|
25 |
-
libxext6 \
|
26 |
-
libxrender1 \
|
27 |
-
python-is-python3 \
|
28 |
-
python3-dev \
|
29 |
-
python3-pip \
|
30 |
-
wget \
|
31 |
-
&& rm -rf /var/lib/apt/lists/*
|
32 |
-
|
33 |
-
# Set up a new user named "user" with user ID 1000
|
34 |
-
RUN useradd -m -u 1000 user
|
35 |
-
# Switch to the "user" user
|
36 |
-
USER user
|
37 |
-
# Set home to the user's home directory
|
38 |
-
ENV HOME=/home/user \
|
39 |
-
PATH=/home/user/.local/bin:$PATH \
|
40 |
-
PYTHONPATH=$HOME/app \
|
41 |
-
PYTHONUNBUFFERED=1 \
|
42 |
-
GRADIO_ALLOW_FLAGGING=never \
|
43 |
-
GRADIO_NUM_PORTS=1 \
|
44 |
-
GRADIO_SERVER_NAME=0.0.0.0 \
|
45 |
-
GRADIO_THEME=huggingface \
|
46 |
-
SYSTEM=spaces
|
47 |
-
|
48 |
-
RUN pip install --upgrade pip setuptools ninja
|
49 |
-
RUN pip install torch==2.2.1 --extra-index-url https://download.pytorch.org/whl/cu118
|
50 |
-
|
51 |
-
RUN python -c "import torch; print(torch.version.cuda)"
|
52 |
-
COPY requirements.txt /tmp
|
53 |
-
RUN cd /tmp && pip install -r requirements.txt
|
54 |
-
|
55 |
-
# Set the working directory to the user's home directory
|
56 |
-
WORKDIR $HOME/app
|
57 |
-
|
58 |
-
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
59 |
-
COPY --chown=user . $HOME/app
|
60 |
-
|
61 |
-
CMD ["python", "app.py"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.md
CHANGED
@@ -3,8 +3,9 @@ title: TripoSR
|
|
3 |
emoji: 🐳
|
4 |
colorFrom: gray
|
5 |
colorTo: red
|
6 |
-
sdk:
|
7 |
-
|
|
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
license: mit
|
|
|
3 |
emoji: 🐳
|
4 |
colorFrom: gray
|
5 |
colorTo: red
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 4.20.1
|
8 |
+
python_version: 3.10.13
|
9 |
app_file: app.py
|
10 |
pinned: false
|
11 |
license: mit
|
app.py
CHANGED
@@ -1,19 +1,23 @@
|
|
1 |
import logging
|
2 |
import os
|
|
|
|
|
3 |
import tempfile
|
4 |
import time
|
5 |
|
6 |
import gradio as gr
|
7 |
import numpy as np
|
8 |
import rembg
|
|
|
9 |
import torch
|
10 |
from PIL import Image
|
11 |
from functools import partial
|
12 |
|
|
|
|
|
13 |
from tsr.system import TSR
|
14 |
from tsr.utils import remove_background, resize_foreground, to_gradio_3d_orientation
|
15 |
|
16 |
-
HF_TOKEN = os.getenv("HF_TOKEN")
|
17 |
|
18 |
HEADER = """
|
19 |
# TripoSR Demo
|
@@ -63,7 +67,6 @@ model = TSR.from_pretrained(
|
|
63 |
"stabilityai/TripoSR",
|
64 |
config_name="config.yaml",
|
65 |
weight_name="model.ckpt",
|
66 |
-
token=HF_TOKEN
|
67 |
)
|
68 |
model.renderer.set_chunk_size(131072)
|
69 |
model.to(device)
|
@@ -95,6 +98,7 @@ def preprocess(input_image, do_remove_background, foreground_ratio):
|
|
95 |
return image
|
96 |
|
97 |
|
|
|
98 |
def generate(image):
|
99 |
scene_codes = model(image, device=device)
|
100 |
mesh = model.extract_mesh(scene_codes)[0]
|
|
|
1 |
import logging
|
2 |
import os
|
3 |
+
import shlex
|
4 |
+
import subprocess
|
5 |
import tempfile
|
6 |
import time
|
7 |
|
8 |
import gradio as gr
|
9 |
import numpy as np
|
10 |
import rembg
|
11 |
+
import spaces
|
12 |
import torch
|
13 |
from PIL import Image
|
14 |
from functools import partial
|
15 |
|
16 |
+
subprocess.run(shlex.split('pip install wheel/torchmcubes-0.1.0-cp310-cp310-linux_x86_64.whl'))
|
17 |
+
|
18 |
from tsr.system import TSR
|
19 |
from tsr.utils import remove_background, resize_foreground, to_gradio_3d_orientation
|
20 |
|
|
|
21 |
|
22 |
HEADER = """
|
23 |
# TripoSR Demo
|
|
|
67 |
"stabilityai/TripoSR",
|
68 |
config_name="config.yaml",
|
69 |
weight_name="model.ckpt",
|
|
|
70 |
)
|
71 |
model.renderer.set_chunk_size(131072)
|
72 |
model.to(device)
|
|
|
98 |
return image
|
99 |
|
100 |
|
101 |
+
@spaces.GPU
|
102 |
def generate(image):
|
103 |
scene_codes = model(image, device=device)
|
104 |
mesh = model.extract_mesh(scene_codes)[0]
|
requirements.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
omegaconf==2.3.0
|
2 |
Pillow==10.1.0
|
3 |
einops==0.7.0
|
4 |
-
|
5 |
transformers==4.35.0
|
6 |
trimesh==4.0.5
|
7 |
rembg
|
8 |
huggingface-hub
|
9 |
-
gradio
|
|
|
1 |
omegaconf==2.3.0
|
2 |
Pillow==10.1.0
|
3 |
einops==0.7.0
|
4 |
+
torch==2.0.1
|
5 |
transformers==4.35.0
|
6 |
trimesh==4.0.5
|
7 |
rembg
|
8 |
huggingface-hub
|
9 |
+
gradio
|
wheel/torchmcubes-0.1.0-cp310-cp310-linux_x86_64.whl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4af160ba1274e2205d3529a7b82efdb6946c2158a78e19631ed840301055b8d6
|
3 |
+
size 5824388
|