Spaces:
Sleeping
Sleeping
Add files
Browse files- .gitattributes +1 -0
- .gitignore +163 -0
- .gitmodules +3 -0
- .pre-commit-config.yaml +36 -0
- .style.yapf +5 -0
- Dockerfile +59 -0
- TEXTurePaper +1 -0
- app.py +67 -0
- model.py +63 -0
- patch +34 -0
- requirements.txt +15 -0
- shapes/dragon1.obj +3 -0
- shapes/dragon2.obj +3 -0
- shapes/eagle.obj +3 -0
- shapes/napoleon.obj +3 -0
- shapes/nascar.obj +3 -0
- shapes/shell.obj +3 -0
- style.css +3 -0
.gitattributes
CHANGED
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
35 |
+
*.obj filter=lfs diff=lfs merge=lfs -text
|
.gitignore
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
cache/
|
2 |
+
experiments/
|
3 |
+
|
4 |
+
# Byte-compiled / optimized / DLL files
|
5 |
+
__pycache__/
|
6 |
+
*.py[cod]
|
7 |
+
*$py.class
|
8 |
+
|
9 |
+
# C extensions
|
10 |
+
*.so
|
11 |
+
|
12 |
+
# Distribution / packaging
|
13 |
+
.Python
|
14 |
+
build/
|
15 |
+
develop-eggs/
|
16 |
+
dist/
|
17 |
+
downloads/
|
18 |
+
eggs/
|
19 |
+
.eggs/
|
20 |
+
lib/
|
21 |
+
lib64/
|
22 |
+
parts/
|
23 |
+
sdist/
|
24 |
+
var/
|
25 |
+
wheels/
|
26 |
+
share/python-wheels/
|
27 |
+
*.egg-info/
|
28 |
+
.installed.cfg
|
29 |
+
*.egg
|
30 |
+
MANIFEST
|
31 |
+
|
32 |
+
# PyInstaller
|
33 |
+
# Usually these files are written by a python script from a template
|
34 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
35 |
+
*.manifest
|
36 |
+
*.spec
|
37 |
+
|
38 |
+
# Installer logs
|
39 |
+
pip-log.txt
|
40 |
+
pip-delete-this-directory.txt
|
41 |
+
|
42 |
+
# Unit test / coverage reports
|
43 |
+
htmlcov/
|
44 |
+
.tox/
|
45 |
+
.nox/
|
46 |
+
.coverage
|
47 |
+
.coverage.*
|
48 |
+
.cache
|
49 |
+
nosetests.xml
|
50 |
+
coverage.xml
|
51 |
+
*.cover
|
52 |
+
*.py,cover
|
53 |
+
.hypothesis/
|
54 |
+
.pytest_cache/
|
55 |
+
cover/
|
56 |
+
|
57 |
+
# Translations
|
58 |
+
*.mo
|
59 |
+
*.pot
|
60 |
+
|
61 |
+
# Django stuff:
|
62 |
+
*.log
|
63 |
+
local_settings.py
|
64 |
+
db.sqlite3
|
65 |
+
db.sqlite3-journal
|
66 |
+
|
67 |
+
# Flask stuff:
|
68 |
+
instance/
|
69 |
+
.webassets-cache
|
70 |
+
|
71 |
+
# Scrapy stuff:
|
72 |
+
.scrapy
|
73 |
+
|
74 |
+
# Sphinx documentation
|
75 |
+
docs/_build/
|
76 |
+
|
77 |
+
# PyBuilder
|
78 |
+
.pybuilder/
|
79 |
+
target/
|
80 |
+
|
81 |
+
# Jupyter Notebook
|
82 |
+
.ipynb_checkpoints
|
83 |
+
|
84 |
+
# IPython
|
85 |
+
profile_default/
|
86 |
+
ipython_config.py
|
87 |
+
|
88 |
+
# pyenv
|
89 |
+
# For a library or package, you might want to ignore these files since the code is
|
90 |
+
# intended to run in multiple environments; otherwise, check them in:
|
91 |
+
# .python-version
|
92 |
+
|
93 |
+
# pipenv
|
94 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
95 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
96 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
97 |
+
# install all needed dependencies.
|
98 |
+
#Pipfile.lock
|
99 |
+
|
100 |
+
# poetry
|
101 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
102 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
103 |
+
# commonly ignored for libraries.
|
104 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
105 |
+
#poetry.lock
|
106 |
+
|
107 |
+
# pdm
|
108 |
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
109 |
+
#pdm.lock
|
110 |
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
111 |
+
# in version control.
|
112 |
+
# https://pdm.fming.dev/#use-with-ide
|
113 |
+
.pdm.toml
|
114 |
+
|
115 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
116 |
+
__pypackages__/
|
117 |
+
|
118 |
+
# Celery stuff
|
119 |
+
celerybeat-schedule
|
120 |
+
celerybeat.pid
|
121 |
+
|
122 |
+
# SageMath parsed files
|
123 |
+
*.sage.py
|
124 |
+
|
125 |
+
# Environments
|
126 |
+
.env
|
127 |
+
.venv
|
128 |
+
env/
|
129 |
+
venv/
|
130 |
+
ENV/
|
131 |
+
env.bak/
|
132 |
+
venv.bak/
|
133 |
+
|
134 |
+
# Spyder project settings
|
135 |
+
.spyderproject
|
136 |
+
.spyproject
|
137 |
+
|
138 |
+
# Rope project settings
|
139 |
+
.ropeproject
|
140 |
+
|
141 |
+
# mkdocs documentation
|
142 |
+
/site
|
143 |
+
|
144 |
+
# mypy
|
145 |
+
.mypy_cache/
|
146 |
+
.dmypy.json
|
147 |
+
dmypy.json
|
148 |
+
|
149 |
+
# Pyre type checker
|
150 |
+
.pyre/
|
151 |
+
|
152 |
+
# pytype static type analyzer
|
153 |
+
.pytype/
|
154 |
+
|
155 |
+
# Cython debug symbols
|
156 |
+
cython_debug/
|
157 |
+
|
158 |
+
# PyCharm
|
159 |
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
160 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
161 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
162 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
163 |
+
#.idea/
|
.gitmodules
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
[submodule "TEXTurePaper"]
|
2 |
+
path = TEXTurePaper
|
3 |
+
url = https://github.com/TEXTurePaper/TEXTurePaper
|
.pre-commit-config.yaml
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
exclude: patch
|
2 |
+
repos:
|
3 |
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
4 |
+
rev: v4.2.0
|
5 |
+
hooks:
|
6 |
+
- id: check-executables-have-shebangs
|
7 |
+
- id: check-json
|
8 |
+
- id: check-merge-conflict
|
9 |
+
- id: check-shebang-scripts-are-executable
|
10 |
+
- id: check-toml
|
11 |
+
- id: check-yaml
|
12 |
+
- id: double-quote-string-fixer
|
13 |
+
- id: end-of-file-fixer
|
14 |
+
- id: mixed-line-ending
|
15 |
+
args: ['--fix=lf']
|
16 |
+
- id: requirements-txt-fixer
|
17 |
+
- id: trailing-whitespace
|
18 |
+
- repo: https://github.com/myint/docformatter
|
19 |
+
rev: v1.4
|
20 |
+
hooks:
|
21 |
+
- id: docformatter
|
22 |
+
args: ['--in-place']
|
23 |
+
- repo: https://github.com/pycqa/isort
|
24 |
+
rev: 5.12.0
|
25 |
+
hooks:
|
26 |
+
- id: isort
|
27 |
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
28 |
+
rev: v0.991
|
29 |
+
hooks:
|
30 |
+
- id: mypy
|
31 |
+
args: ['--ignore-missing-imports']
|
32 |
+
- repo: https://github.com/google/yapf
|
33 |
+
rev: v0.32.0
|
34 |
+
hooks:
|
35 |
+
- id: yapf
|
36 |
+
args: ['--parallel', '--in-place']
|
.style.yapf
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
[style]
|
2 |
+
based_on_style = pep8
|
3 |
+
blank_line_before_nested_class_or_def = false
|
4 |
+
spaces_before_comment = 2
|
5 |
+
split_before_logical_operator = true
|
Dockerfile
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM nvidia/cuda:11.7.1-cudnn8-devel-ubuntu22.04
|
2 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
3 |
+
RUN apt-get update && \
|
4 |
+
apt-get upgrade -y && \
|
5 |
+
apt-get install -y --no-install-recommends \
|
6 |
+
git \
|
7 |
+
wget \
|
8 |
+
curl \
|
9 |
+
zip \
|
10 |
+
# ffmpeg \
|
11 |
+
ffmpeg \
|
12 |
+
x264 \
|
13 |
+
# python build dependencies \
|
14 |
+
build-essential \
|
15 |
+
libssl-dev \
|
16 |
+
zlib1g-dev \
|
17 |
+
libbz2-dev \
|
18 |
+
libreadline-dev \
|
19 |
+
libsqlite3-dev \
|
20 |
+
libncursesw5-dev \
|
21 |
+
xz-utils \
|
22 |
+
tk-dev \
|
23 |
+
libxml2-dev \
|
24 |
+
libxmlsec1-dev \
|
25 |
+
libffi-dev \
|
26 |
+
liblzma-dev && \
|
27 |
+
apt-get clean && \
|
28 |
+
rm -rf /var/lib/apt/lists/*
|
29 |
+
|
30 |
+
RUN useradd -m -u 1000 user
|
31 |
+
USER user
|
32 |
+
ENV HOME=/home/user \
|
33 |
+
PATH=/home/user/.local/bin:${PATH}
|
34 |
+
WORKDIR ${HOME}/app
|
35 |
+
|
36 |
+
RUN curl https://pyenv.run | bash
|
37 |
+
ENV PATH=${HOME}/.pyenv/shims:${HOME}/.pyenv/bin:${PATH}
|
38 |
+
ENV PYTHON_VERSION=3.9.16
|
39 |
+
RUN pyenv install ${PYTHON_VERSION} && \
|
40 |
+
pyenv global ${PYTHON_VERSION} && \
|
41 |
+
pyenv rehash && \
|
42 |
+
pip install --no-cache-dir -U pip setuptools wheel
|
43 |
+
|
44 |
+
RUN pip install --no-cache-dir -U torch==1.12.1+cu113 torchvision==0.13.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113
|
45 |
+
COPY --chown=1000 requirements.txt /tmp
|
46 |
+
RUN pip install --no-cache-dir -r /tmp/requirements.txt
|
47 |
+
RUN pip install --no-cache-dir -U kaolin==0.13.0 -f https://nvidia-kaolin.s3.us-east-2.amazonaws.com/torch-1.12.1_cu113.html
|
48 |
+
RUN pip install --no-cache-dir -U gradio==3.17.1
|
49 |
+
|
50 |
+
COPY --chown=1000 . ${HOME}/app
|
51 |
+
RUN cd TEXTurePaper && patch -p1 < ../patch
|
52 |
+
ENV PYTHONPATH=${HOME}/app \
|
53 |
+
PYTHONUNBUFFERED=1 \
|
54 |
+
GRADIO_ALLOW_FLAGGING=never \
|
55 |
+
GRADIO_NUM_PORTS=1 \
|
56 |
+
GRADIO_SERVER_NAME=0.0.0.0 \
|
57 |
+
GRADIO_THEME=huggingface \
|
58 |
+
SYSTEM=spaces
|
59 |
+
CMD ["python", "app.py"]
|
TEXTurePaper
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
Subproject commit 3f393aa2b91cdb58f571d37a6304e068d791af10
|
app.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
|
3 |
+
from __future__ import annotations
|
4 |
+
|
5 |
+
import pathlib
|
6 |
+
|
7 |
+
import gradio as gr
|
8 |
+
|
9 |
+
from model import Model
|
10 |
+
|
11 |
+
DESCRIPTION = '''# TEXTure
|
12 |
+
|
13 |
+
This is an unofficial demo for [https://github.com/TEXTurePaper/TEXTurePaper](https://github.com/TEXTurePaper/TEXTurePaper).
|
14 |
+
|
15 |
+
This demo only accepts as input `.obj` files with less than 100,000 faces.
|
16 |
+
|
17 |
+
Inference takes about 10 minutes on a T4 GPU.
|
18 |
+
'''
|
19 |
+
|
20 |
+
model = Model()
|
21 |
+
|
22 |
+
with gr.Blocks(css='style.css') as demo:
|
23 |
+
gr.Markdown(DESCRIPTION)
|
24 |
+
with gr.Row():
|
25 |
+
with gr.Column():
|
26 |
+
input_shape = gr.Model3D(label='Input 3D mesh')
|
27 |
+
text = gr.Text(label='Text')
|
28 |
+
seed = gr.Slider(label='Seed',
|
29 |
+
minimum=0,
|
30 |
+
maximum=100000,
|
31 |
+
value=3,
|
32 |
+
step=1)
|
33 |
+
guidance_scale = gr.Slider(label='Guidance scale',
|
34 |
+
minimum=0,
|
35 |
+
maximum=50,
|
36 |
+
value=7.5,
|
37 |
+
step=0.1)
|
38 |
+
run_button = gr.Button('Run')
|
39 |
+
with gr.Column():
|
40 |
+
result = gr.Video(label='Result')
|
41 |
+
output_file = gr.File(label='Output mesh file')
|
42 |
+
with gr.Row():
|
43 |
+
examples = [
|
44 |
+
['shapes/dragon1.obj', 'a photo of a dragon', 0, 7.5],
|
45 |
+
['shapes/dragon2.obj', 'a photo of a dragon', 0, 7.5],
|
46 |
+
['shapes/eagle.obj', 'a photo of an eagle', 0, 7.5],
|
47 |
+
['shapes/napoleon.obj', 'a photo of Napoleon Bonaparte', 3, 7.5],
|
48 |
+
['shapes/nascar.obj', 'A next gen nascar', 2, 10],
|
49 |
+
]
|
50 |
+
gr.Examples(examples=examples,
|
51 |
+
inputs=[input_shape, text, seed, guidance_scale],
|
52 |
+
outputs=[result, output_file],
|
53 |
+
cache_examples=False)
|
54 |
+
|
55 |
+
run_button.click(fn=model.run,
|
56 |
+
inputs=[
|
57 |
+
input_shape,
|
58 |
+
text,
|
59 |
+
seed,
|
60 |
+
guidance_scale,
|
61 |
+
],
|
62 |
+
outputs=[
|
63 |
+
result,
|
64 |
+
output_file,
|
65 |
+
])
|
66 |
+
|
67 |
+
demo.queue(max_size=5).launch()
|
model.py
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from __future__ import annotations
|
2 |
+
|
3 |
+
import datetime
|
4 |
+
import pathlib
|
5 |
+
import shlex
|
6 |
+
import subprocess
|
7 |
+
import sys
|
8 |
+
|
9 |
+
import gradio as gr
|
10 |
+
|
11 |
+
sys.path.append('TEXTurePaper')
|
12 |
+
|
13 |
+
from src.configs.train_config import GuideConfig, LogConfig, TrainConfig
|
14 |
+
from src.training.trainer import TEXTure
|
15 |
+
|
16 |
+
|
17 |
+
class Model:
|
18 |
+
def __init__(self):
|
19 |
+
self.max_num_faces = 100000
|
20 |
+
|
21 |
+
def load_config(self, shape_path: str, text: str, seed: int,
|
22 |
+
guidance_scale: float) -> TrainConfig:
|
23 |
+
text += ', {} view'
|
24 |
+
|
25 |
+
log = LogConfig(exp_name=self.gen_exp_name())
|
26 |
+
guide = GuideConfig(text=text)
|
27 |
+
guide.background_img = 'TEXTurePaper/textures/brick_wall.png'
|
28 |
+
guide.shape_path = 'TEXTurePaper/shapes/spot_triangulated.obj'
|
29 |
+
config = TrainConfig(log=log, guide=guide)
|
30 |
+
|
31 |
+
config.guide.shape_path = shape_path
|
32 |
+
config.optim.seed = seed
|
33 |
+
config.guide.guidance_scale = guidance_scale
|
34 |
+
return config
|
35 |
+
|
36 |
+
def gen_exp_name(self) -> str:
|
37 |
+
now = datetime.datetime.now()
|
38 |
+
return now.strftime('%Y-%m-%d-%H-%M-%S')
|
39 |
+
|
40 |
+
def check_num_faces(self, path: str) -> bool:
|
41 |
+
with open(path) as f:
|
42 |
+
lines = [line for line in f.readlines() if line.startswith('f')]
|
43 |
+
return len(lines) <= self.max_num_faces
|
44 |
+
|
45 |
+
def zip_results(self, exp_dir: pathlib.Path) -> str:
|
46 |
+
mesh_dir = exp_dir / 'mesh'
|
47 |
+
out_path = f'{exp_dir.name}.zip'
|
48 |
+
subprocess.run(shlex.split(f'zip -r {out_path} {mesh_dir}'))
|
49 |
+
return out_path
|
50 |
+
|
51 |
+
def run(self, shape_path: str, text: str, seed: int,
|
52 |
+
guidance_scale: float) -> tuple[str, str]:
|
53 |
+
if not shape_path.endswith('.obj'):
|
54 |
+
raise gr.Error('The input file is not .obj file.')
|
55 |
+
if not self.check_num_faces(shape_path):
|
56 |
+
raise gr.Error('The number of faces is over 100,000.')
|
57 |
+
|
58 |
+
config = self.load_config(shape_path, text, seed, guidance_scale)
|
59 |
+
trainer = TEXTure(config)
|
60 |
+
trainer.paint()
|
61 |
+
video_path = config.log.exp_dir / 'results' / 'step_00010_rgb.mp4'
|
62 |
+
zip_path = self.zip_results(config.log.exp_dir)
|
63 |
+
return video_path.as_posix(), zip_path
|
patch
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
diff --git a/src/models/textured_mesh.py b/src/models/textured_mesh.py
|
2 |
+
index 75ffb6d..40d30e6 100644
|
3 |
+
--- a/src/models/textured_mesh.py
|
4 |
+
+++ b/src/models/textured_mesh.py
|
5 |
+
@@ -122,7 +122,7 @@ class TexturedMeshModel(nn.Module):
|
6 |
+
|
7 |
+
self.renderer = Renderer(device=self.device, dim=(render_grid_size, render_grid_size),
|
8 |
+
interpolation_mode=self.opt.texture_interpolation_mode)
|
9 |
+
- self.env_sphere, self.mesh = self.init_meshes()
|
10 |
+
+ self.env_sphere, self.mesh = self.init_meshes(opt.shape_path)
|
11 |
+
self.default_color = [0.8, 0.1, 0.8]
|
12 |
+
self.background_sphere_colors, self.texture_img = self.init_paint()
|
13 |
+
self.meta_texture_img = nn.Parameter(torch.zeros_like(self.texture_img))
|
14 |
+
diff --git a/src/stable_diffusion_depth.py b/src/stable_diffusion_depth.py
|
15 |
+
index 610d2de..e172080 100644
|
16 |
+
--- a/src/stable_diffusion_depth.py
|
17 |
+
+++ b/src/stable_diffusion_depth.py
|
18 |
+
@@ -1,3 +1,5 @@
|
19 |
+
+import os
|
20 |
+
+
|
21 |
+
from diffusers import AutoencoderKL, UNet2DConditionModel, PNDMScheduler
|
22 |
+
from huggingface_hub import hf_hub_download
|
23 |
+
from transformers import CLIPTextModel, CLIPTokenizer, logging
|
24 |
+
@@ -24,9 +26,7 @@ class StableDiffusion(nn.Module):
|
25 |
+
super().__init__()
|
26 |
+
|
27 |
+
try:
|
28 |
+
- with open('./TOKEN', 'r') as f:
|
29 |
+
- self.token = f.read().replace('\n', '') # remove the last \n!
|
30 |
+
- logger.info(f'loaded hugging face access token from ./TOKEN!')
|
31 |
+
+ self.token = os.environ['HF_TOKEN']
|
32 |
+
except FileNotFoundError as e:
|
33 |
+
self.token = True
|
34 |
+
logger.warning(
|
requirements.txt
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
accelerate==0.16.0
|
2 |
+
diffusers==0.12.1
|
3 |
+
einops==0.6.0
|
4 |
+
huggingface-hub==0.12.0
|
5 |
+
imageio[ffmpeg,pyav]==2.25.0
|
6 |
+
loguru==0.6.0
|
7 |
+
matplotlib==3.6.3
|
8 |
+
ninja==1.11.1
|
9 |
+
opencv-python-headless==4.7.0.68
|
10 |
+
pyrallis==0.3.1
|
11 |
+
torch==1.12.1
|
12 |
+
torchvision==0.13.1
|
13 |
+
tqdm==4.64.1
|
14 |
+
transformers==4.26.0
|
15 |
+
xatlas==0.0.7
|
shapes/dragon1.obj
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2b8c4ed26150539c33c15db2711e3f682621dccbcb500a69951e9a506442219a
|
3 |
+
size 7186630
|
shapes/dragon2.obj
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:75fafd97c70db71f6635d21357aaf8c86864e999d04a809ded62659aa0999eb9
|
3 |
+
size 7176659
|
shapes/eagle.obj
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b31932d34387664fa740f8792abe47213ed37372d9471cd3adbe2ce8fdde960f
|
3 |
+
size 7282898
|
shapes/napoleon.obj
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2f2adeafaa5c50398ca8a75552332414564b0de5bcecb81a0fc89eb52cfed60b
|
3 |
+
size 7249885
|
shapes/nascar.obj
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:343014429d93c7bc0bbf7586b22e96fe84db773beb74feae99976a65e1ce3f77
|
3 |
+
size 483133
|
shapes/shell.obj
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:20a239e4c10392da488f6fdd6ef53f326537f341a04e97b09a6ad067fe8f05cc
|
3 |
+
size 7176643
|
style.css
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
h1 {
|
2 |
+
text-align: center;
|
3 |
+
}
|