Surn commited on
Commit
f7c2109
·
1 Parent(s): a032ac3

Updates From Main Branch

Browse files
app.py CHANGED
@@ -1607,7 +1607,7 @@ with gr.Blocks(title=title, delete_cache=(21600,86400)) as hexaGrid:
1607
  gr.update(visible=(x == "Custom List")),
1608
  gr.update(visible=(x != None))
1609
  ),
1610
- inputs=add_hex_text,
1611
  outputs=[custom_text_list, custom_text_color_list, hex_text_info]
1612
  )
1613
  with gr.Row():
 
1607
  gr.update(visible=(x == "Custom List")),
1608
  gr.update(visible=(x != None))
1609
  ),
1610
+ inputs=[add_hex_text],
1611
  outputs=[custom_text_list, custom_text_color_list, hex_text_info]
1612
  )
1613
  with gr.Row():
requirements.txt CHANGED
@@ -1,10 +1,11 @@
1
  open3d
2
- git+https://github.com/huggingface/diffusers.git
3
- #diffusers[torch]==0.40.0
4
  transformers==5.17.0
5
  accelerate
6
  safetensors
7
  sentencepiece
 
8
  #invisible_watermark
9
 
10
  # -------------------------------------------------
 
1
  open3d
2
+ #git+https://github.com/huggingface/diffusers.git
3
+ diffusers[torch]==0.40.0
4
  transformers==5.17.0
5
  accelerate
6
  safetensors
7
  sentencepiece
8
+ #sentence-transformers==6.1.0
9
  #invisible_watermark
10
 
11
  # -------------------------------------------------
trellis/models/structured_latent_flow.py CHANGED
@@ -109,8 +109,9 @@ class SLatFlowModel(nn.Module):
109
  self.qk_rms_norm_cross = qk_rms_norm_cross
110
  self.dtype = torch.float16 if use_fp16 else torch.float32
111
 
112
- assert int(np.log2(patch_size)) == np.log2(patch_size), "Patch size must be a power of 2"
113
- assert np.log2(patch_size) == len(io_block_channels), "Number of IO ResBlocks must match the number of stages"
 
114
 
115
  self.t_embedder = TimestepEmbedder(model_channels)
116
  if share_mod:
@@ -122,25 +123,27 @@ class SLatFlowModel(nn.Module):
122
  if pe_mode == "ape":
123
  self.pos_embedder = AbsolutePositionEmbedder(model_channels)
124
 
125
- self.input_layer = sp.SparseLinear(in_channels, io_block_channels[0])
 
126
  self.input_blocks = nn.ModuleList([])
127
- for chs, next_chs in zip(io_block_channels, io_block_channels[1:] + [model_channels]):
128
- self.input_blocks.extend([
129
- SparseResBlock3d(
130
- chs,
131
- model_channels,
132
- out_channels=chs,
133
- )
134
- for _ in range(num_io_res_blocks-1)
135
- ])
136
- self.input_blocks.append(
137
- SparseResBlock3d(
138
- chs,
139
- model_channels,
140
- out_channels=next_chs,
141
- downsample=True,
 
 
142
  )
143
- )
144
 
145
  self.blocks = nn.ModuleList([
146
  ModulatedSparseTransformerCrossBlock(
@@ -159,24 +162,26 @@ class SLatFlowModel(nn.Module):
159
  ])
160
 
161
  self.out_blocks = nn.ModuleList([])
162
- for chs, prev_chs in zip(reversed(io_block_channels), [model_channels] + list(reversed(io_block_channels[1:]))):
163
- self.out_blocks.append(
164
- SparseResBlock3d(
165
- prev_chs * 2 if self.use_skip_connection else prev_chs,
166
- model_channels,
167
- out_channels=chs,
168
- upsample=True,
 
 
169
  )
170
- )
171
- self.out_blocks.extend([
172
- SparseResBlock3d(
173
- chs * 2 if self.use_skip_connection else chs,
174
- model_channels,
175
- out_channels=chs,
176
- )
177
- for _ in range(num_io_res_blocks-1)
178
- ])
179
- self.out_layer = sp.SparseLinear(io_block_channels[0], out_channels)
180
 
181
  self.initialize_weights()
182
  if use_fp16:
@@ -260,3 +265,4 @@ class SLatFlowModel(nn.Module):
260
  h = h.replace(F.layer_norm(h.feats, h.feats.shape[-1:]))
261
  h = self.out_layer(h.type(x.dtype))
262
  return h
 
 
109
  self.qk_rms_norm_cross = qk_rms_norm_cross
110
  self.dtype = torch.float16 if use_fp16 else torch.float32
111
 
112
+ if self.io_block_channels is not None:
113
+ assert int(np.log2(patch_size)) == np.log2(patch_size), "Patch size must be a power of 2"
114
+ assert np.log2(patch_size) == len(io_block_channels), "Number of IO ResBlocks must match the number of stages"
115
 
116
  self.t_embedder = TimestepEmbedder(model_channels)
117
  if share_mod:
 
123
  if pe_mode == "ape":
124
  self.pos_embedder = AbsolutePositionEmbedder(model_channels)
125
 
126
+ self.input_layer = sp.SparseLinear(in_channels, model_channels if io_block_channels is None else io_block_channels[0])
127
+
128
  self.input_blocks = nn.ModuleList([])
129
+ if io_block_channels is not None:
130
+ for chs, next_chs in zip(io_block_channels, io_block_channels[1:] + [model_channels]):
131
+ self.input_blocks.extend([
132
+ SparseResBlock3d(
133
+ chs,
134
+ model_channels,
135
+ out_channels=chs,
136
+ )
137
+ for _ in range(num_io_res_blocks-1)
138
+ ])
139
+ self.input_blocks.append(
140
+ SparseResBlock3d(
141
+ chs,
142
+ model_channels,
143
+ out_channels=next_chs,
144
+ downsample=True,
145
+ )
146
  )
 
147
 
148
  self.blocks = nn.ModuleList([
149
  ModulatedSparseTransformerCrossBlock(
 
162
  ])
163
 
164
  self.out_blocks = nn.ModuleList([])
165
+ if io_block_channels is not None:
166
+ for chs, prev_chs in zip(reversed(io_block_channels), [model_channels] + list(reversed(io_block_channels[1:]))):
167
+ self.out_blocks.append(
168
+ SparseResBlock3d(
169
+ prev_chs * 2 if self.use_skip_connection else prev_chs,
170
+ model_channels,
171
+ out_channels=chs,
172
+ upsample=True,
173
+ )
174
  )
175
+ self.out_blocks.extend([
176
+ SparseResBlock3d(
177
+ chs * 2 if self.use_skip_connection else chs,
178
+ model_channels,
179
+ out_channels=chs,
180
+ )
181
+ for _ in range(num_io_res_blocks-1)
182
+ ])
183
+
184
+ self.out_layer = sp.SparseLinear(model_channels if io_block_channels is None else io_block_channels[0], out_channels)
185
 
186
  self.initialize_weights()
187
  if use_fp16:
 
265
  h = h.replace(F.layer_norm(h.feats, h.feats.shape[-1:]))
266
  h = self.out_layer(h.type(x.dtype))
267
  return h
268
+
trellis/pipelines/samplers/flow_euler.py CHANGED
@@ -37,6 +37,8 @@ class FlowEulerSampler(Sampler):
37
 
38
  def _inference_model(self, model, x_t, t, cond=None, **kwargs):
39
  t = torch.tensor([1000 * t] * x_t.shape[0], device=x_t.device, dtype=torch.float32)
 
 
40
  return model(x_t, t, cond, **kwargs)
41
 
42
  def _get_model_prediction(self, model, x_t, t, cond=None, **kwargs):
 
37
 
38
  def _inference_model(self, model, x_t, t, cond=None, **kwargs):
39
  t = torch.tensor([1000 * t] * x_t.shape[0], device=x_t.device, dtype=torch.float32)
40
+ if cond is not None and cond.shape[0] == 1 and x_t.shape[0] > 1:
41
+ cond = cond.repeat(x_t.shape[0], *([1] * (len(cond.shape) - 1)))
42
  return model(x_t, t, cond, **kwargs)
43
 
44
  def _get_model_prediction(self, model, x_t, t, cond=None, **kwargs):
trellis/pipelines/trellis_image_to_3d.py CHANGED
@@ -148,6 +148,7 @@ class TrellisImageTo3DPipeline(Pipeline):
148
  raise ValueError(f"Unsupported type of image: {type(image)}")
149
 
150
  image = self.image_cond_model_transform(image).to(self.device)
 
151
  features = self.models['image_cond_model'](image, is_training=True)['x_prenorm']
152
  patchtokens = F.layer_norm(features, features.shape[-1:])
153
  return patchtokens
 
148
  raise ValueError(f"Unsupported type of image: {type(image)}")
149
 
150
  image = self.image_cond_model_transform(image).to(self.device)
151
+ self.models['image_cond_model'].to(self.device)
152
  features = self.models['image_cond_model'](image, is_training=True)['x_prenorm']
153
  patchtokens = F.layer_norm(features, features.shape[-1:])
154
  return patchtokens
trellis/representations/mesh/tables.py CHANGED
@@ -1,10 +1,17 @@
1
- # Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 
2
  #
3
- # NVIDIA CORPORATION & AFFILIATES and its licensors retain all intellectual property
4
- # and proprietary rights in and to this software, related documentation
5
- # and any modifications thereto. Any use, reproduction, disclosure or
6
- # distribution of this software and related documentation without an express
7
- # license agreement from NVIDIA CORPORATION & AFFILIATES is strictly prohibited.
 
 
 
 
 
 
8
  dmc_table = [
9
  [[-1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1]],
10
  [[0, 3, 8, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1]],
 
1
+ # Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES.
2
+ # All rights reserved.
3
  #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
  dmc_table = [
16
  [[-1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1]],
17
  [[0, 3, 8, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1], [-1, -1, -1, -1, -1, -1, -1]],
utils/misc.py CHANGED
@@ -116,10 +116,10 @@ def update_dimensions_on_ratio(aspect_ratio_str, base_height):
116
  new_width, new_height = convert_ratio_to_dimensions(aspect_ratio, base_height)
117
  return new_width, new_height
118
 
119
- def install_torch():
120
  print("\nInstalling PyTorch with CUDA support...")
121
  # Define the package and index URL
122
- package = "torch==2.4.0"
123
  index_url = "https://download.pytorch.org/whl/cu124"
124
  # Construct the pip install command
125
  command = [
@@ -130,7 +130,7 @@ def install_torch():
130
  subprocess.run(command, check=True)
131
  print("\nPyTorch installation completed.")
132
  print("\nInstalling torchvision...")
133
- package = "torchvision==0.19.0"
134
  index_url = "https://download.pytorch.org/whl/cu124"
135
  # Construct the pip install command
136
  command = [
@@ -148,13 +148,13 @@ def _get_output(cmd):
148
  logging.exception(ex)
149
  return None
150
 
151
- def install_cuda_toolkit():
152
  #CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run"
153
  # CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda_12.2.0_535.54.03_linux.run"
154
- CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/12.4.1/local_installers/cuda_12.4.1_550.54.15_linux.run"
155
- CUDA_TOOLKIT_FILE = "/tmp/%s" % os.path.basename(CUDA_TOOLKIT_URL)
156
- print("\nDownloading CUDA Toolkit from %s" % CUDA_TOOLKIT_URL)
157
- subprocess.call(["wget", "-q", CUDA_TOOLKIT_URL, "-O", CUDA_TOOLKIT_FILE])
158
  subprocess.call(["chmod", "+x", CUDA_TOOLKIT_FILE])
159
  subprocess.call([CUDA_TOOLKIT_FILE, "--silent", "--toolkit"])
160
  os.environ["CUDA_HOME"] = "/usr/local/cuda"
 
116
  new_width, new_height = convert_ratio_to_dimensions(aspect_ratio, base_height)
117
  return new_width, new_height
118
 
119
+ def install_torch(torch_version="2.4.0", torchvision_version = "0.19.0"):
120
  print("\nInstalling PyTorch with CUDA support...")
121
  # Define the package and index URL
122
+ package = f"torch=={torch_version}"
123
  index_url = "https://download.pytorch.org/whl/cu124"
124
  # Construct the pip install command
125
  command = [
 
130
  subprocess.run(command, check=True)
131
  print("\nPyTorch installation completed.")
132
  print("\nInstalling torchvision...")
133
+ package = f"torchvision=={torchvision_version}"
134
  index_url = "https://download.pytorch.org/whl/cu124"
135
  # Construct the pip install command
136
  command = [
 
148
  logging.exception(ex)
149
  return None
150
 
151
+ def install_cuda_toolkit(cuda_toolkit_file ="https://developer.download.nvidia.com/compute/cuda/12.4.1/local_installers/cuda_12.4.1_550.54.15_linux.run"):
152
  #CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run"
153
  # CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda_12.2.0_535.54.03_linux.run"
154
+ # CUDA_TOOLKIT_URL = "https://developer.download.nvidia.com/compute/cuda/12.4.1/local_installers/cuda_12.4.1_550.54.15_linux.run"
155
+ CUDA_TOOLKIT_FILE = "/tmp/%s" % os.path.basename(cuda_toolkit_file)
156
+ print("\nDownloading CUDA Toolkit from %s" % cuda_toolkit_file)
157
+ subprocess.call(["wget", "-q", cuda_toolkit_file, "-O", CUDA_TOOLKIT_FILE])
158
  subprocess.call(["chmod", "+x", CUDA_TOOLKIT_FILE])
159
  subprocess.call([CUDA_TOOLKIT_FILE, "--silent", "--toolkit"])
160
  os.environ["CUDA_HOME"] = "/usr/local/cuda"