Spaces:
Runtime error
Runtime error
gusgeneris
commited on
Commit
•
31ec2b7
1
Parent(s):
90c5ca2
test
Browse files- .gitattributes +0 -35
- .gitignore +0 -155
- __pycache__/inference.cpython-310.pyc +0 -0
- __pycache__/mesh.cpython-310.pyc +0 -0
- __pycache__/pipelines.cpython-310.pyc +0 -0
- app.py +4 -2
- imagedream/__pycache__/__init__.cpython-310.pyc +0 -0
- imagedream/__pycache__/model_zoo.cpython-310.pyc +0 -0
- imagedream/ldm/__pycache__/__init__.cpython-310.pyc +0 -0
- imagedream/ldm/__pycache__/interface.cpython-310.pyc +0 -0
- imagedream/ldm/__pycache__/util.cpython-310.pyc +0 -0
- imagedream/ldm/models/diffusion/ddim.py +2 -2
- imagedream/ldm/modules/__pycache__/__init__.cpython-310.pyc +0 -0
- imagedream/ldm/modules/__pycache__/attention.cpython-310.pyc +0 -0
- imagedream/ldm/modules/attention.py +41 -3
- imagedream/ldm/modules/diffusionmodules/__pycache__/__init__.cpython-310.pyc +0 -0
- imagedream/ldm/modules/diffusionmodules/__pycache__/adaptors.cpython-310.pyc +0 -0
- imagedream/ldm/modules/diffusionmodules/__pycache__/openaimodel.cpython-310.pyc +0 -0
- imagedream/ldm/modules/diffusionmodules/__pycache__/util.cpython-310.pyc +0 -0
- imagedream/ldm/modules/diffusionmodules/model.py +74 -25
- imagedream/ldm/modules/distributions/__pycache__/__init__.cpython-310.pyc +0 -0
- imagedream/ldm/modules/distributions/__pycache__/distributions.cpython-310.pyc +0 -0
- imagedream/ldm/modules/encoders/__pycache__/__init__.cpython-310.pyc +0 -0
- imagedream/ldm/modules/encoders/__pycache__/modules.cpython-310.pyc +0 -0
- imagedream/ldm/modules/encoders/modules.py +1 -1
- libs/__pycache__/base_utils.cpython-310.pyc +0 -0
- mesh.py +2 -2
- model/__pycache__/__init__.cpython-310.pyc +0 -0
- model/archs/__pycache__/__init__.cpython-310.pyc +0 -0
- model/archs/__pycache__/mlp_head.cpython-310.pyc +0 -0
- model/archs/__pycache__/unet.cpython-310.pyc +0 -0
- model/archs/decoders/__pycache__/__init__.cpython-310.pyc +0 -0
- model/archs/decoders/__pycache__/shape_texture_net.cpython-310.pyc +0 -0
- model/archs/unet.py +1 -1
- model/crm/__pycache__/model.cpython-310.pyc +0 -0
- out/preprocessed_image.png +0 -0
- pipelines.py +1 -1
- run.py +5 -3
- util/__pycache__/__init__.cpython-310.pyc +0 -0
- util/__pycache__/flexicubes.cpython-310.pyc +0 -0
- util/__pycache__/flexicubes_geometry.cpython-310.pyc +0 -0
- util/__pycache__/renderer.cpython-310.pyc +0 -0
- util/__pycache__/tables.cpython-310.pyc +0 -0
- util/__pycache__/utils.cpython-310.pyc +0 -0
- util/flexicubes.py +1 -1
- util/flexicubes_geometry.py +1 -1
- util/renderer.py +65 -11
.gitattributes
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
-
*.xz 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.gitignore
DELETED
@@ -1,155 +0,0 @@
|
|
1 |
-
# Byte-compiled / optimized / DLL files
|
2 |
-
__pycache__/
|
3 |
-
*.py[cod]
|
4 |
-
*$py.class
|
5 |
-
|
6 |
-
# C extensions
|
7 |
-
*.so
|
8 |
-
|
9 |
-
# Distribution / packaging
|
10 |
-
.Python
|
11 |
-
build/
|
12 |
-
develop-eggs/
|
13 |
-
dist/
|
14 |
-
downloads/
|
15 |
-
eggs/
|
16 |
-
.eggs/
|
17 |
-
lib/
|
18 |
-
lib64/
|
19 |
-
parts/
|
20 |
-
sdist/
|
21 |
-
var/
|
22 |
-
wheels/
|
23 |
-
share/python-wheels/
|
24 |
-
*.egg-info/
|
25 |
-
.installed.cfg
|
26 |
-
*.egg
|
27 |
-
MANIFEST
|
28 |
-
|
29 |
-
# PyInstaller
|
30 |
-
# Usually these files are written by a python script from a template
|
31 |
-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
32 |
-
*.manifest
|
33 |
-
*.spec
|
34 |
-
|
35 |
-
# Installer logs
|
36 |
-
pip-log.txt
|
37 |
-
pip-delete-this-directory.txt
|
38 |
-
|
39 |
-
# Unit test / coverage reports
|
40 |
-
htmlcov/
|
41 |
-
.tox/
|
42 |
-
.nox/
|
43 |
-
.coverage
|
44 |
-
.coverage.*
|
45 |
-
.cache
|
46 |
-
nosetests.xml
|
47 |
-
coverage.xml
|
48 |
-
*.cover
|
49 |
-
*.py,cover
|
50 |
-
.hypothesis/
|
51 |
-
.pytest_cache/
|
52 |
-
cover/
|
53 |
-
|
54 |
-
# Translations
|
55 |
-
*.mo
|
56 |
-
*.pot
|
57 |
-
|
58 |
-
# Django stuff:
|
59 |
-
*.log
|
60 |
-
local_settings.py
|
61 |
-
db.sqlite3
|
62 |
-
db.sqlite3-journal
|
63 |
-
|
64 |
-
# Flask stuff:
|
65 |
-
instance/
|
66 |
-
.webassets-cache
|
67 |
-
|
68 |
-
# Scrapy stuff:
|
69 |
-
.scrapy
|
70 |
-
|
71 |
-
# Sphinx documentation
|
72 |
-
docs/_build/
|
73 |
-
|
74 |
-
# PyBuilder
|
75 |
-
.pybuilder/
|
76 |
-
target/
|
77 |
-
|
78 |
-
# Jupyter Notebook
|
79 |
-
.ipynb_checkpoints
|
80 |
-
|
81 |
-
# IPython
|
82 |
-
profile_default/
|
83 |
-
ipython_config.py
|
84 |
-
|
85 |
-
# pyenv
|
86 |
-
# For a library or package, you might want to ignore these files since the code is
|
87 |
-
# intended to run in multiple environments; otherwise, check them in:
|
88 |
-
# .python-version
|
89 |
-
|
90 |
-
# pipenv
|
91 |
-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
92 |
-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
93 |
-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
94 |
-
# install all needed dependencies.
|
95 |
-
#Pipfile.lock
|
96 |
-
|
97 |
-
# poetry
|
98 |
-
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
99 |
-
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
100 |
-
# commonly ignored for libraries.
|
101 |
-
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
102 |
-
#poetry.lock
|
103 |
-
|
104 |
-
# pdm
|
105 |
-
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
106 |
-
#pdm.lock
|
107 |
-
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
108 |
-
# in version control.
|
109 |
-
# https://pdm.fming.dev/#use-with-ide
|
110 |
-
.pdm.toml
|
111 |
-
|
112 |
-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
113 |
-
__pypackages__/
|
114 |
-
|
115 |
-
# Celery stuff
|
116 |
-
celerybeat-schedule
|
117 |
-
celerybeat.pid
|
118 |
-
|
119 |
-
# SageMath parsed files
|
120 |
-
*.sage.py
|
121 |
-
|
122 |
-
# Environments
|
123 |
-
.env
|
124 |
-
.venv
|
125 |
-
env/
|
126 |
-
venv/
|
127 |
-
ENV/
|
128 |
-
env.bak/
|
129 |
-
venv.bak/
|
130 |
-
|
131 |
-
# Spyder project settings
|
132 |
-
.spyderproject
|
133 |
-
.spyproject
|
134 |
-
|
135 |
-
# Rope project settings
|
136 |
-
.ropeproject
|
137 |
-
|
138 |
-
# mkdocs documentation
|
139 |
-
/site
|
140 |
-
|
141 |
-
# mypy
|
142 |
-
.mypy_cache/
|
143 |
-
.dmypy.json
|
144 |
-
dmypy.json
|
145 |
-
|
146 |
-
# Pyre type checker
|
147 |
-
.pyre/
|
148 |
-
|
149 |
-
# pytype static type analyzer
|
150 |
-
.pytype/
|
151 |
-
|
152 |
-
# Cython debug symbols
|
153 |
-
cython_debug/
|
154 |
-
|
155 |
-
out/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__pycache__/inference.cpython-310.pyc
ADDED
Binary file (2.78 kB). View file
|
|
__pycache__/mesh.cpython-310.pyc
ADDED
Binary file (21.8 kB). View file
|
|
__pycache__/pipelines.cpython-310.pyc
ADDED
Binary file (6.3 kB). View file
|
|
app.py
CHANGED
@@ -121,12 +121,14 @@ parser.add_argument(
|
|
121 |
help="config for stage2",
|
122 |
)
|
123 |
|
124 |
-
parser.add_argument("--device", type=str, default="
|
125 |
args = parser.parse_args()
|
126 |
|
127 |
crm_path = hf_hub_download(repo_id="Zhengyi/CRM", filename="CRM.pth")
|
128 |
specs = json.load(open("configs/specs_objaverse_total.json"))
|
129 |
-
model = CRM(specs).to(args.device)
|
|
|
|
|
130 |
model.load_state_dict(torch.load(crm_path, map_location = args.device), strict=False)
|
131 |
|
132 |
stage1_config = OmegaConf.load(args.stage1_config).config
|
|
|
121 |
help="config for stage2",
|
122 |
)
|
123 |
|
124 |
+
parser.add_argument("--device", type=str, default="cpu")
|
125 |
args = parser.parse_args()
|
126 |
|
127 |
crm_path = hf_hub_download(repo_id="Zhengyi/CRM", filename="CRM.pth")
|
128 |
specs = json.load(open("configs/specs_objaverse_total.json"))
|
129 |
+
# model = CRM(specs).to(args.device)
|
130 |
+
model = CRM(specs).to("cpu")
|
131 |
+
|
132 |
model.load_state_dict(torch.load(crm_path, map_location = args.device), strict=False)
|
133 |
|
134 |
stage1_config = OmegaConf.load(args.stage1_config).config
|
imagedream/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (189 Bytes). View file
|
|
imagedream/__pycache__/model_zoo.cpython-310.pyc
ADDED
Binary file (1.76 kB). View file
|
|
imagedream/ldm/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (148 Bytes). View file
|
|
imagedream/ldm/__pycache__/interface.cpython-310.pyc
ADDED
Binary file (6.24 kB). View file
|
|
imagedream/ldm/__pycache__/util.cpython-310.pyc
ADDED
Binary file (6.64 kB). View file
|
|
imagedream/ldm/models/diffusion/ddim.py
CHANGED
@@ -22,8 +22,8 @@ class DDIMSampler(object):
|
|
22 |
|
23 |
def register_buffer(self, name, attr):
|
24 |
if type(attr) == torch.Tensor:
|
25 |
-
if attr.device != torch.device("
|
26 |
-
attr = attr.to(torch.device("
|
27 |
setattr(self, name, attr)
|
28 |
|
29 |
def make_schedule(
|
|
|
22 |
|
23 |
def register_buffer(self, name, attr):
|
24 |
if type(attr) == torch.Tensor:
|
25 |
+
if attr.device != torch.device("cpu"):
|
26 |
+
attr = attr.to(torch.device("cpu"))
|
27 |
setattr(self, name, attr)
|
28 |
|
29 |
def make_schedule(
|
imagedream/ldm/modules/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (156 Bytes). View file
|
|
imagedream/ldm/modules/__pycache__/attention.cpython-310.pyc
ADDED
Binary file (11 kB). View file
|
|
imagedream/ldm/modules/attention.py
CHANGED
@@ -226,6 +226,43 @@ class MemoryEfficientCrossAttention(nn.Module):
|
|
226 |
|
227 |
|
228 |
class BasicTransformerBlock(nn.Module):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
229 |
def __init__(
|
230 |
self,
|
231 |
dim,
|
@@ -239,7 +276,6 @@ class BasicTransformerBlock(nn.Module):
|
|
239 |
**kwargs
|
240 |
):
|
241 |
super().__init__()
|
242 |
-
assert XFORMERS_IS_AVAILBLE, "xformers is not available"
|
243 |
attn_cls = MemoryEfficientCrossAttention
|
244 |
self.disable_self_attn = disable_self_attn
|
245 |
self.attn1 = attn_cls(
|
@@ -248,7 +284,7 @@ class BasicTransformerBlock(nn.Module):
|
|
248 |
dim_head=d_head,
|
249 |
dropout=dropout,
|
250 |
context_dim=context_dim if self.disable_self_attn else None,
|
251 |
-
) #
|
252 |
self.ff = FeedForward(dim, dropout=dropout, glu=gated_ff)
|
253 |
self.attn2 = attn_cls(
|
254 |
query_dim=dim,
|
@@ -257,12 +293,13 @@ class BasicTransformerBlock(nn.Module):
|
|
257 |
dim_head=d_head,
|
258 |
dropout=dropout,
|
259 |
**kwargs
|
260 |
-
) #
|
261 |
self.norm1 = nn.LayerNorm(dim)
|
262 |
self.norm2 = nn.LayerNorm(dim)
|
263 |
self.norm3 = nn.LayerNorm(dim)
|
264 |
self.checkpoint = checkpoint
|
265 |
|
|
|
266 |
def forward(self, x, context=None):
|
267 |
return checkpoint(
|
268 |
self._forward, (x, context), self.parameters(), self.checkpoint
|
@@ -278,6 +315,7 @@ class BasicTransformerBlock(nn.Module):
|
|
278 |
x = self.attn2(self.norm2(x), context=context) + x
|
279 |
x = self.ff(self.norm3(x)) + x
|
280 |
return x
|
|
|
281 |
|
282 |
|
283 |
class SpatialTransformer(nn.Module):
|
|
|
226 |
|
227 |
|
228 |
class BasicTransformerBlock(nn.Module):
|
229 |
+
# def __init__(
|
230 |
+
# self,
|
231 |
+
# dim,
|
232 |
+
# n_heads,
|
233 |
+
# d_head,
|
234 |
+
# dropout=0.0,
|
235 |
+
# context_dim=None,
|
236 |
+
# gated_ff=True,
|
237 |
+
# checkpoint=True,
|
238 |
+
# disable_self_attn=False,
|
239 |
+
# **kwargs
|
240 |
+
# ):
|
241 |
+
# super().__init__()
|
242 |
+
# assert XFORMERS_IS_AVAILBLE, "xformers is not available"
|
243 |
+
# attn_cls = MemoryEfficientCrossAttention
|
244 |
+
# self.disable_self_attn = disable_self_attn
|
245 |
+
# self.attn1 = attn_cls(
|
246 |
+
# query_dim=dim,
|
247 |
+
# heads=n_heads,
|
248 |
+
# dim_head=d_head,
|
249 |
+
# dropout=dropout,
|
250 |
+
# context_dim=context_dim if self.disable_self_attn else None,
|
251 |
+
# ) # is a self-attention if not self.disable_self_attn
|
252 |
+
# self.ff = FeedForward(dim, dropout=dropout, glu=gated_ff)
|
253 |
+
# self.attn2 = attn_cls(
|
254 |
+
# query_dim=dim,
|
255 |
+
# context_dim=context_dim,
|
256 |
+
# heads=n_heads,
|
257 |
+
# dim_head=d_head,
|
258 |
+
# dropout=dropout,
|
259 |
+
# **kwargs
|
260 |
+
# ) # is self-attn if context is none
|
261 |
+
# self.norm1 = nn.LayerNorm(dim)
|
262 |
+
# self.norm2 = nn.LayerNorm(dim)
|
263 |
+
# self.norm3 = nn.LayerNorm(dim)
|
264 |
+
# self.checkpoint = checkpoint
|
265 |
+
|
266 |
def __init__(
|
267 |
self,
|
268 |
dim,
|
|
|
276 |
**kwargs
|
277 |
):
|
278 |
super().__init__()
|
|
|
279 |
attn_cls = MemoryEfficientCrossAttention
|
280 |
self.disable_self_attn = disable_self_attn
|
281 |
self.attn1 = attn_cls(
|
|
|
284 |
dim_head=d_head,
|
285 |
dropout=dropout,
|
286 |
context_dim=context_dim if self.disable_self_attn else None,
|
287 |
+
) # Self-attention if not self.disable_self_attn
|
288 |
self.ff = FeedForward(dim, dropout=dropout, glu=gated_ff)
|
289 |
self.attn2 = attn_cls(
|
290 |
query_dim=dim,
|
|
|
293 |
dim_head=d_head,
|
294 |
dropout=dropout,
|
295 |
**kwargs
|
296 |
+
) # Cross-attention if context is provided
|
297 |
self.norm1 = nn.LayerNorm(dim)
|
298 |
self.norm2 = nn.LayerNorm(dim)
|
299 |
self.norm3 = nn.LayerNorm(dim)
|
300 |
self.checkpoint = checkpoint
|
301 |
|
302 |
+
|
303 |
def forward(self, x, context=None):
|
304 |
return checkpoint(
|
305 |
self._forward, (x, context), self.parameters(), self.checkpoint
|
|
|
315 |
x = self.attn2(self.norm2(x), context=context) + x
|
316 |
x = self.ff(self.norm3(x)) + x
|
317 |
return x
|
318 |
+
|
319 |
|
320 |
|
321 |
class SpatialTransformer(nn.Module):
|
imagedream/ldm/modules/diffusionmodules/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (173 Bytes). View file
|
|
imagedream/ldm/modules/diffusionmodules/__pycache__/adaptors.cpython-310.pyc
ADDED
Binary file (4.67 kB). View file
|
|
imagedream/ldm/modules/diffusionmodules/__pycache__/openaimodel.cpython-310.pyc
ADDED
Binary file (24.7 kB). View file
|
|
imagedream/ldm/modules/diffusionmodules/__pycache__/util.cpython-310.pyc
ADDED
Binary file (11.1 kB). View file
|
|
imagedream/ldm/modules/diffusionmodules/model.py
CHANGED
@@ -220,39 +220,59 @@ class MemoryEfficientAttnBlock(nn.Module):
|
|
220 |
self.attention_op: Optional[Any] = None
|
221 |
|
222 |
def forward(self, x):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
h_ = x
|
224 |
h_ = self.norm(h_)
|
225 |
q = self.q(h_)
|
226 |
k = self.k(h_)
|
227 |
v = self.v(h_)
|
228 |
|
229 |
-
#
|
230 |
B, C, H, W = q.shape
|
231 |
-
q, k, v = map(lambda
|
232 |
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
.
|
238 |
-
.
|
239 |
-
(
|
240 |
-
)
|
241 |
-
out = xformers.ops.memory_efficient_attention(
|
242 |
-
q, k, v, attn_bias=None, op=self.attention_op
|
243 |
-
)
|
244 |
|
245 |
-
out = (
|
246 |
-
out.unsqueeze(0)
|
247 |
-
.reshape(B, 1, out.shape[1], C)
|
248 |
-
.permute(0, 2, 1, 3)
|
249 |
-
.reshape(B, out.shape[1], C)
|
250 |
-
)
|
251 |
-
out = rearrange(out, "b (h w) c -> b c h w", b=B, h=H, w=W, c=C)
|
252 |
out = self.proj_out(out)
|
253 |
return x + out
|
254 |
|
255 |
-
|
256 |
class MemoryEfficientCrossAttentionWrapper(MemoryEfficientCrossAttention):
|
257 |
def forward(self, x, context=None, mask=None):
|
258 |
b, c, h, w = x.shape
|
@@ -263,6 +283,29 @@ class MemoryEfficientCrossAttentionWrapper(MemoryEfficientCrossAttention):
|
|
263 |
|
264 |
|
265 |
def make_attn(in_channels, attn_type="vanilla", attn_kwargs=None):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
assert attn_type in [
|
267 |
"vanilla",
|
268 |
"vanilla-xformers",
|
@@ -270,16 +313,22 @@ def make_attn(in_channels, attn_type="vanilla", attn_kwargs=None):
|
|
270 |
"linear",
|
271 |
"none",
|
272 |
], f"attn_type {attn_type} unknown"
|
273 |
-
|
|
|
|
|
274 |
attn_type = "vanilla-xformers"
|
|
|
|
|
|
|
275 |
print(f"making attention of type '{attn_type}' with {in_channels} in_channels")
|
|
|
276 |
if attn_type == "vanilla":
|
277 |
assert attn_kwargs is None
|
278 |
-
return AttnBlock(in_channels)
|
279 |
elif attn_type == "vanilla-xformers":
|
280 |
print(f"building MemoryEfficientAttnBlock with {in_channels} in_channels...")
|
281 |
-
return MemoryEfficientAttnBlock(in_channels)
|
282 |
-
elif
|
283 |
attn_kwargs["query_dim"] = in_channels
|
284 |
return MemoryEfficientCrossAttentionWrapper(**attn_kwargs)
|
285 |
elif attn_type == "none":
|
|
|
220 |
self.attention_op: Optional[Any] = None
|
221 |
|
222 |
def forward(self, x):
|
223 |
+
# h_ = x
|
224 |
+
# h_ = self.norm(h_)
|
225 |
+
# q = self.q(h_)
|
226 |
+
# k = self.k(h_)
|
227 |
+
# v = self.v(h_)
|
228 |
+
|
229 |
+
# # compute attention
|
230 |
+
# B, C, H, W = q.shape
|
231 |
+
# q, k, v = map(lambda x: rearrange(x, "b c h w -> b (h w) c"), (q, k, v))
|
232 |
+
|
233 |
+
# q, k, v = map(
|
234 |
+
# lambda t: t.unsqueeze(3)
|
235 |
+
# .reshape(B, t.shape[1], 1, C)
|
236 |
+
# .permute(0, 2, 1, 3)
|
237 |
+
# .reshape(B * 1, t.shape[1], C)
|
238 |
+
# .contiguous(),
|
239 |
+
# (q, k, v),
|
240 |
+
# )
|
241 |
+
# out = xformers.ops.memory_efficient_attention(
|
242 |
+
# q, k, v, attn_bias=None, op=self.attention_op
|
243 |
+
# )
|
244 |
+
|
245 |
+
# out = (
|
246 |
+
# out.unsqueeze(0)
|
247 |
+
# .reshape(B, 1, out.shape[1], C)
|
248 |
+
# .permute(0, 2, 1, 3)
|
249 |
+
# .reshape(B, out.shape[1], C)
|
250 |
+
# )
|
251 |
+
# out = rearrange(out, "b (h w) c -> b c h w", b=B, h=H, w=W, c=C)
|
252 |
+
# out = self.proj_out(out)
|
253 |
+
# return x + out
|
254 |
h_ = x
|
255 |
h_ = self.norm(h_)
|
256 |
q = self.q(h_)
|
257 |
k = self.k(h_)
|
258 |
v = self.v(h_)
|
259 |
|
260 |
+
# Compute attention
|
261 |
B, C, H, W = q.shape
|
262 |
+
q, k, v = map(lambda t: rearrange(t, "b c h w -> b (h w) c"), (q, k, v))
|
263 |
|
264 |
+
if torch.cuda.is_available(): # Use xformers only if GPU is available
|
265 |
+
out = xformers.ops.memory_efficient_attention(q, k, v, attn_bias=None, op=self.attention_op)
|
266 |
+
else:
|
267 |
+
# CPU-friendly alternative for attention
|
268 |
+
attn_weights = torch.einsum('bqc,bkc->bqk', q, k) # Simple dot-product attention
|
269 |
+
attn_weights = torch.softmax(attn_weights, dim=-1)
|
270 |
+
out = torch.einsum('bqk,bvc->bqc', attn_weights, v)
|
|
|
|
|
|
|
|
|
271 |
|
272 |
+
out = rearrange(out, "b (h w) c -> b c h w", h=H, w=W)
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
out = self.proj_out(out)
|
274 |
return x + out
|
275 |
|
|
|
276 |
class MemoryEfficientCrossAttentionWrapper(MemoryEfficientCrossAttention):
|
277 |
def forward(self, x, context=None, mask=None):
|
278 |
b, c, h, w = x.shape
|
|
|
283 |
|
284 |
|
285 |
def make_attn(in_channels, attn_type="vanilla", attn_kwargs=None):
|
286 |
+
# assert attn_type in [
|
287 |
+
# "vanilla",
|
288 |
+
# "vanilla-xformers",
|
289 |
+
# "memory-efficient-cross-attn",
|
290 |
+
# "linear",
|
291 |
+
# "none",
|
292 |
+
# ], f"attn_type {attn_type} unknown"
|
293 |
+
# if XFORMERS_IS_AVAILBLE and attn_type == "vanilla":
|
294 |
+
# attn_type = "vanilla-xformers"
|
295 |
+
# print(f"making attention of type '{attn_type}' with {in_channels} in_channels")
|
296 |
+
# if attn_type == "vanilla":
|
297 |
+
# assert attn_kwargs is None
|
298 |
+
# return AttnBlock(in_channels)
|
299 |
+
# elif attn_type == "vanilla-xformers":
|
300 |
+
# print(f"building MemoryEfficientAttnBlock with {in_channels} in_channels...")
|
301 |
+
# return MemoryEfficientAttnBlock(in_channels)
|
302 |
+
# elif type == "memory-efficient-cross-attn":
|
303 |
+
# attn_kwargs["query_dim"] = in_channels
|
304 |
+
# return MemoryEfficientCrossAttentionWrapper(**attn_kwargs)
|
305 |
+
# elif attn_type == "none":
|
306 |
+
# return nn.Identity(in_channels)
|
307 |
+
# else:
|
308 |
+
# raise NotImplementedError()
|
309 |
assert attn_type in [
|
310 |
"vanilla",
|
311 |
"vanilla-xformers",
|
|
|
313 |
"linear",
|
314 |
"none",
|
315 |
], f"attn_type {attn_type} unknown"
|
316 |
+
|
317 |
+
# Comprobar si GPU está disponible y evitar xformers si no lo está
|
318 |
+
if torch.cuda.is_available() and XFORMERS_IS_AVAILBLE and attn_type == "vanilla":
|
319 |
attn_type = "vanilla-xformers"
|
320 |
+
else:
|
321 |
+
print("Using CPU-based attention as xformers or GPU is not available.")
|
322 |
+
|
323 |
print(f"making attention of type '{attn_type}' with {in_channels} in_channels")
|
324 |
+
|
325 |
if attn_type == "vanilla":
|
326 |
assert attn_kwargs is None
|
327 |
+
return AttnBlock(in_channels) # Atención estándar para CPU
|
328 |
elif attn_type == "vanilla-xformers":
|
329 |
print(f"building MemoryEfficientAttnBlock with {in_channels} in_channels...")
|
330 |
+
return MemoryEfficientAttnBlock(in_channels) # Atención optimizada con xformers
|
331 |
+
elif attn_type == "memory-efficient-cross-attn":
|
332 |
attn_kwargs["query_dim"] = in_channels
|
333 |
return MemoryEfficientCrossAttentionWrapper(**attn_kwargs)
|
334 |
elif attn_type == "none":
|
imagedream/ldm/modules/distributions/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (170 Bytes). View file
|
|
imagedream/ldm/modules/distributions/__pycache__/distributions.cpython-310.pyc
ADDED
Binary file (3.77 kB). View file
|
|
imagedream/ldm/modules/encoders/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (165 Bytes). View file
|
|
imagedream/ldm/modules/encoders/__pycache__/modules.cpython-310.pyc
ADDED
Binary file (10.4 kB). View file
|
|
imagedream/ldm/modules/encoders/modules.py
CHANGED
@@ -106,7 +106,7 @@ class FrozenCLIPEmbedder(AbstractEncoder):
|
|
106 |
def __init__(
|
107 |
self,
|
108 |
version="openai/clip-vit-large-patch14",
|
109 |
-
device="
|
110 |
max_length=77,
|
111 |
freeze=True,
|
112 |
layer="last",
|
|
|
106 |
def __init__(
|
107 |
self,
|
108 |
version="openai/clip-vit-large-patch14",
|
109 |
+
device="cpu",
|
110 |
max_length=77,
|
111 |
freeze=True,
|
112 |
layer="last",
|
libs/__pycache__/base_utils.cpython-310.pyc
ADDED
Binary file (3.27 kB). View file
|
|
mesh.py
CHANGED
@@ -159,7 +159,7 @@ class Mesh:
|
|
159 |
|
160 |
# device
|
161 |
if device is None:
|
162 |
-
device = torch.device("
|
163 |
|
164 |
mesh.device = device
|
165 |
|
@@ -331,7 +331,7 @@ class Mesh:
|
|
331 |
|
332 |
# device
|
333 |
if device is None:
|
334 |
-
device = torch.device("
|
335 |
|
336 |
mesh.device = device
|
337 |
|
|
|
159 |
|
160 |
# device
|
161 |
if device is None:
|
162 |
+
device = torch.device("cpu" if torch.cuda.is_available() else "cpu")
|
163 |
|
164 |
mesh.device = device
|
165 |
|
|
|
331 |
|
332 |
# device
|
333 |
if device is None:
|
334 |
+
device = torch.device("cpu" if torch.cuda.is_available() else "cpu")
|
335 |
|
336 |
mesh.device = device
|
337 |
|
model/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (182 Bytes). View file
|
|
model/archs/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (145 Bytes). View file
|
|
model/archs/__pycache__/mlp_head.cpython-310.pyc
ADDED
Binary file (1.26 kB). View file
|
|
model/archs/__pycache__/unet.cpython-310.pyc
ADDED
Binary file (1.54 kB). View file
|
|
model/archs/decoders/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (154 Bytes). View file
|
|
model/archs/decoders/__pycache__/shape_texture_net.cpython-310.pyc
ADDED
Binary file (1.84 kB). View file
|
|
model/archs/unet.py
CHANGED
@@ -40,7 +40,7 @@ class UNetPP(nn.Module):
|
|
40 |
),
|
41 |
)
|
42 |
|
43 |
-
self.unet.enable_xformers_memory_efficient_attention()
|
44 |
if in_channels > 12:
|
45 |
self.learned_plane = torch.nn.parameter.Parameter(torch.zeros([1,in_channels-12,256,256*3]))
|
46 |
|
|
|
40 |
),
|
41 |
)
|
42 |
|
43 |
+
# self.unet.enable_xformers_memory_efficient_attention()
|
44 |
if in_channels > 12:
|
45 |
self.learned_plane = torch.nn.parameter.Parameter(torch.zeros([1,in_channels-12,256,256*3]))
|
46 |
|
model/crm/__pycache__/model.cpython-310.pyc
ADDED
Binary file (6.09 kB). View file
|
|
out/preprocessed_image.png
ADDED
pipelines.py
CHANGED
@@ -15,7 +15,7 @@ class TwoStagePipeline(object):
|
|
15 |
stage2_model_config,
|
16 |
stage1_sampler_config,
|
17 |
stage2_sampler_config,
|
18 |
-
device="
|
19 |
dtype=torch.float16,
|
20 |
resize_rate=1,
|
21 |
) -> None:
|
|
|
15 |
stage2_model_config,
|
16 |
stage1_sampler_config,
|
17 |
stage2_sampler_config,
|
18 |
+
device="cpu",
|
19 |
dtype=torch.float16,
|
20 |
resize_rate=1,
|
21 |
) -> None:
|
run.py
CHANGED
@@ -125,8 +125,10 @@ if __name__ == "__main__":
|
|
125 |
|
126 |
crm_path = hf_hub_download(repo_id="Zhengyi/CRM", filename="CRM.pth")
|
127 |
specs = json.load(open("configs/specs_objaverse_total.json"))
|
128 |
-
model = CRM(specs).to("cuda")
|
129 |
-
model
|
|
|
|
|
130 |
|
131 |
stage1_config = OmegaConf.load("configs/nf7_v3_SNR_rd_size_stroke.yaml").config
|
132 |
stage2_config = OmegaConf.load("configs/stage2-v2-snr.yaml").config
|
@@ -156,5 +158,5 @@ if __name__ == "__main__":
|
|
156 |
Image.fromarray(np_imgs).save(args.outdir+"pixel_images.png")
|
157 |
Image.fromarray(np_xyzs).save(args.outdir+"xyz_images.png")
|
158 |
|
159 |
-
glb_path, obj_path = generate3d(model, np_imgs, np_xyzs, "
|
160 |
shutil.copy(obj_path, args.outdir+"output3d.zip")
|
|
|
125 |
|
126 |
crm_path = hf_hub_download(repo_id="Zhengyi/CRM", filename="CRM.pth")
|
127 |
specs = json.load(open("configs/specs_objaverse_total.json"))
|
128 |
+
# model = CRM(specs).to("cuda")
|
129 |
+
model = CRM(specs).to("cpu")
|
130 |
+
|
131 |
+
model.load_state_dict(torch.load(crm_path, map_location = "cpu"), strict=False)
|
132 |
|
133 |
stage1_config = OmegaConf.load("configs/nf7_v3_SNR_rd_size_stroke.yaml").config
|
134 |
stage2_config = OmegaConf.load("configs/stage2-v2-snr.yaml").config
|
|
|
158 |
Image.fromarray(np_imgs).save(args.outdir+"pixel_images.png")
|
159 |
Image.fromarray(np_xyzs).save(args.outdir+"xyz_images.png")
|
160 |
|
161 |
+
glb_path, obj_path = generate3d(model, np_imgs, np_xyzs, "cpu")
|
162 |
shutil.copy(obj_path, args.outdir+"output3d.zip")
|
util/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (138 Bytes). View file
|
|
util/__pycache__/flexicubes.cpython-310.pyc
ADDED
Binary file (22.6 kB). View file
|
|
util/__pycache__/flexicubes_geometry.cpython-310.pyc
ADDED
Binary file (3.7 kB). View file
|
|
util/__pycache__/renderer.cpython-310.pyc
ADDED
Binary file (1.56 kB). View file
|
|
util/__pycache__/tables.cpython-310.pyc
ADDED
Binary file (24 kB). View file
|
|
util/__pycache__/utils.cpython-310.pyc
ADDED
Binary file (7.07 kB). View file
|
|
util/flexicubes.py
CHANGED
@@ -64,7 +64,7 @@ class FlexiCubes:
|
|
64 |
The scale of weights in FlexiCubes. Should be between 0 and 1.
|
65 |
"""
|
66 |
|
67 |
-
def __init__(self, device="
|
68 |
|
69 |
self.device = device
|
70 |
self.dmc_table = torch.tensor(dmc_table, dtype=torch.long, device=device, requires_grad=False)
|
|
|
64 |
The scale of weights in FlexiCubes. Should be between 0 and 1.
|
65 |
"""
|
66 |
|
67 |
+
def __init__(self, device="cpu", qef_reg_scale=1e-3, weight_scale=0.99):
|
68 |
|
69 |
self.device = device
|
70 |
self.dmc_table = torch.tensor(dmc_table, dtype=torch.long, device=device, requires_grad=False)
|
util/flexicubes_geometry.py
CHANGED
@@ -31,7 +31,7 @@ def get_center_boundary_index(grid_res, device):
|
|
31 |
###############################################################################
|
32 |
class FlexiCubesGeometry(object):
|
33 |
def __init__(
|
34 |
-
self, grid_res=64, scale=2.0, device='
|
35 |
render_type='neural_render', args=None):
|
36 |
super(FlexiCubesGeometry, self).__init__()
|
37 |
self.grid_res = grid_res
|
|
|
31 |
###############################################################################
|
32 |
class FlexiCubesGeometry(object):
|
33 |
def __init__(
|
34 |
+
self, grid_res=64, scale=2.0, device='cpu', renderer=None,
|
35 |
render_type='neural_render', args=None):
|
36 |
super(FlexiCubesGeometry, self).__init__()
|
37 |
self.grid_res = grid_res
|
util/renderer.py
CHANGED
@@ -1,7 +1,56 @@
|
|
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import torch
|
3 |
import torch.nn as nn
|
4 |
-
import nvdiffrast.torch as dr
|
5 |
from util.flexicubes_geometry import FlexiCubesGeometry
|
6 |
|
7 |
class Renderer(nn.Module):
|
@@ -12,18 +61,19 @@ class Renderer(nn.Module):
|
|
12 |
self.camera_angle_num = camera_angle_num
|
13 |
self.scale = scale
|
14 |
self.geo_type = geo_type
|
15 |
-
|
|
|
|
|
16 |
|
17 |
if self.geo_type == "flex":
|
18 |
-
self.flexicubes = FlexiCubesGeometry(grid_res
|
19 |
-
|
20 |
-
def forward(self, data, sdf, deform, verts, tets, training=False, weight = None):
|
21 |
|
|
|
22 |
results = {}
|
23 |
|
24 |
deform = torch.tanh(deform) / self.tet_grid_size * self.scale / 0.95
|
25 |
if self.geo_type == "flex":
|
26 |
-
deform = deform *0.5
|
27 |
|
28 |
v_deformed = verts + deform
|
29 |
|
@@ -31,13 +81,17 @@ class Renderer(nn.Module):
|
|
31 |
faces_list = []
|
32 |
reg_list = []
|
33 |
n_shape = verts.shape[0]
|
34 |
-
for i in range(n_shape):
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
37 |
|
38 |
verts_list.append(verts_i)
|
39 |
faces_list.append(faces_i)
|
40 |
-
reg_list.append(reg_i)
|
|
|
41 |
verts = verts_list
|
42 |
faces = faces_list
|
43 |
|
@@ -46,4 +100,4 @@ class Renderer(nn.Module):
|
|
46 |
results["flex_surf_loss"] = flexicubes_surface_reg
|
47 |
results["flex_weight_loss"] = flexicubes_weight_reg
|
48 |
|
49 |
-
return results, verts, faces
|
|
|
1 |
|
2 |
+
# import torch
|
3 |
+
# import torch.nn as nn
|
4 |
+
# import nvdiffrast.torch as dr
|
5 |
+
# from util.flexicubes_geometry import FlexiCubesGeometry
|
6 |
+
|
7 |
+
# class Renderer(nn.Module):
|
8 |
+
# def __init__(self, tet_grid_size, camera_angle_num, scale, geo_type):
|
9 |
+
# super().__init__()
|
10 |
+
|
11 |
+
# self.tet_grid_size = tet_grid_size
|
12 |
+
# self.camera_angle_num = camera_angle_num
|
13 |
+
# self.scale = scale
|
14 |
+
# self.geo_type = geo_type
|
15 |
+
# self.glctx = dr.RasterizeCudaContext()
|
16 |
+
|
17 |
+
# if self.geo_type == "flex":
|
18 |
+
# self.flexicubes = FlexiCubesGeometry(grid_res = self.tet_grid_size)
|
19 |
+
|
20 |
+
# def forward(self, data, sdf, deform, verts, tets, training=False, weight = None):
|
21 |
+
|
22 |
+
# results = {}
|
23 |
+
|
24 |
+
# deform = torch.tanh(deform) / self.tet_grid_size * self.scale / 0.95
|
25 |
+
# if self.geo_type == "flex":
|
26 |
+
# deform = deform *0.5
|
27 |
+
|
28 |
+
# v_deformed = verts + deform
|
29 |
+
|
30 |
+
# verts_list = []
|
31 |
+
# faces_list = []
|
32 |
+
# reg_list = []
|
33 |
+
# n_shape = verts.shape[0]
|
34 |
+
# for i in range(n_shape):
|
35 |
+
# verts_i, faces_i, reg_i = self.flexicubes.get_mesh(v_deformed[i], sdf[i].squeeze(dim=-1),
|
36 |
+
# with_uv=False, indices=tets, weight_n=weight[i], is_training=training)
|
37 |
+
|
38 |
+
# verts_list.append(verts_i)
|
39 |
+
# faces_list.append(faces_i)
|
40 |
+
# reg_list.append(reg_i)
|
41 |
+
# verts = verts_list
|
42 |
+
# faces = faces_list
|
43 |
+
|
44 |
+
# flexicubes_surface_reg = torch.cat(reg_list).mean()
|
45 |
+
# flexicubes_weight_reg = (weight ** 2).mean()
|
46 |
+
# results["flex_surf_loss"] = flexicubes_surface_reg
|
47 |
+
# results["flex_weight_loss"] = flexicubes_weight_reg
|
48 |
+
|
49 |
+
# return results, verts, faces
|
50 |
+
|
51 |
import torch
|
52 |
import torch.nn as nn
|
53 |
+
# import nvdiffrast.torch as dr # Comentado porque no se usará en CPU
|
54 |
from util.flexicubes_geometry import FlexiCubesGeometry
|
55 |
|
56 |
class Renderer(nn.Module):
|
|
|
61 |
self.camera_angle_num = camera_angle_num
|
62 |
self.scale = scale
|
63 |
self.geo_type = geo_type
|
64 |
+
|
65 |
+
# Eliminar el contexto de GPU y usar una alternativa o desactivarlo
|
66 |
+
# self.glctx = dr.RasterizeCudaContext() # Comentado porque se usa GPU
|
67 |
|
68 |
if self.geo_type == "flex":
|
69 |
+
self.flexicubes = FlexiCubesGeometry(grid_res=self.tet_grid_size)
|
|
|
|
|
70 |
|
71 |
+
def forward(self, data, sdf, deform, verts, tets, training=False, weight=None):
|
72 |
results = {}
|
73 |
|
74 |
deform = torch.tanh(deform) / self.tet_grid_size * self.scale / 0.95
|
75 |
if self.geo_type == "flex":
|
76 |
+
deform = deform * 0.5
|
77 |
|
78 |
v_deformed = verts + deform
|
79 |
|
|
|
81 |
faces_list = []
|
82 |
reg_list = []
|
83 |
n_shape = verts.shape[0]
|
84 |
+
for i in range(n_shape):
|
85 |
+
# Aquí deberás adaptar el uso de FlexiCubesGeometry para que funcione sin GPU.
|
86 |
+
verts_i, faces_i, reg_i = self.flexicubes.get_mesh(
|
87 |
+
v_deformed[i], sdf[i].squeeze(dim=-1),
|
88 |
+
with_uv=False, indices=tets, weight_n=weight[i], is_training=training
|
89 |
+
)
|
90 |
|
91 |
verts_list.append(verts_i)
|
92 |
faces_list.append(faces_i)
|
93 |
+
reg_list.append(reg_i)
|
94 |
+
|
95 |
verts = verts_list
|
96 |
faces = faces_list
|
97 |
|
|
|
100 |
results["flex_surf_loss"] = flexicubes_surface_reg
|
101 |
results["flex_weight_loss"] = flexicubes_weight_reg
|
102 |
|
103 |
+
return results, verts, faces
|