Spaces:
Paused
Paused
update model
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- app.py+10-6
- trellis/__pycache__/__init__.cpython-310.pyc
- trellis/models/__init__.py+2-1
- trellis/models/__pycache__/__init__.cpython-310.pyc
- trellis/models/__pycache__/sparse_structure_flow.cpython-310.pyc
- trellis/models/__pycache__/sparse_structure_vae.cpython-310.pyc
- trellis/models/__pycache__/structured_latent_flow.cpython-310.pyc
- trellis/models/structured_latent_flow.py+65-9
- trellis/models/structured_latent_vae/__pycache__/__init__.cpython-310.pyc
- trellis/models/structured_latent_vae/__pycache__/base.cpython-310.pyc
- trellis/models/structured_latent_vae/__pycache__/decoder_gs.cpython-310.pyc
- trellis/models/structured_latent_vae/__pycache__/decoder_mesh.cpython-310.pyc
- trellis/models/structured_latent_vae/__pycache__/encoder.cpython-310.pyc
- trellis/modules/__pycache__/norm.cpython-310.pyc
- trellis/modules/__pycache__/spatial.cpython-310.pyc
- trellis/modules/__pycache__/utils.cpython-310.pyc
- trellis/modules/attention/__pycache__/__init__.cpython-310.pyc
- trellis/modules/attention/__pycache__/full_attn.cpython-310.pyc
- trellis/modules/attention/__pycache__/modules.cpython-310.pyc
- trellis/modules/sparse/__pycache__/__init__.cpython-310.pyc
- trellis/modules/sparse/__pycache__/basic.cpython-310.pyc
- trellis/modules/sparse/__pycache__/linear.cpython-310.pyc
- trellis/modules/sparse/__pycache__/nonlinearity.cpython-310.pyc
- trellis/modules/sparse/__pycache__/norm.cpython-310.pyc
- trellis/modules/sparse/__pycache__/spatial.cpython-310.pyc
- trellis/modules/sparse/attention/__pycache__/__init__.cpython-310.pyc
- trellis/modules/sparse/attention/__pycache__/full_attn.cpython-310.pyc
- trellis/modules/sparse/attention/__pycache__/modules.cpython-310.pyc
- trellis/modules/sparse/attention/__pycache__/serialized_attn.cpython-310.pyc
- trellis/modules/sparse/attention/__pycache__/windowed_attn.cpython-310.pyc
- trellis/modules/sparse/conv/__pycache__/__init__.cpython-310.pyc
- trellis/modules/sparse/conv/__pycache__/conv_spconv.cpython-310.pyc
- trellis/modules/sparse/transformer/__pycache__/__init__.cpython-310.pyc
- trellis/modules/sparse/transformer/__pycache__/blocks.cpython-310.pyc
- trellis/modules/sparse/transformer/__pycache__/modulated.cpython-310.pyc
- trellis/modules/sparse/transformer/modulated.py+8-2
- trellis/modules/transformer/__pycache__/__init__.cpython-310.pyc
- trellis/modules/transformer/__pycache__/blocks.cpython-310.pyc
- trellis/modules/transformer/__pycache__/modulated.cpython-310.pyc
- trellis/modules/transformer/modulated.py+8-3
- trellis/pipelines/__pycache__/__init__.cpython-310.pyc
- trellis/pipelines/__pycache__/base.cpython-310.pyc
- trellis/pipelines/__pycache__/trellis_image_to_3d.cpython-310.pyc
- trellis/pipelines/base.py+3
- trellis/pipelines/samplers/__pycache__/__init__.cpython-310.pyc
- trellis/pipelines/samplers/__pycache__/base.cpython-310.pyc
- trellis/pipelines/samplers/__pycache__/classifier_free_guidance_mixin.cpython-310.pyc
- trellis/pipelines/samplers/__pycache__/flow_euler.cpython-310.pyc
- trellis/pipelines/samplers/__pycache__/flow_euler_old.cpython-310.pyc
- trellis/pipelines/samplers/__pycache__/guidance_interval_mixin.cpython-310.pyc
192 unmodified lines19319419519619719819910 unmodified lines210211212213214215115 unmodified lines33133233333433533633733833934093 unmodified lines434435436437438439440192 unmodified linesimage_files = [image[0] for image in multiimages]# Generate 3D modeloutputs = pipeline.run(image=image_files,seed=seed,formats=["gaussian", "mesh"],10 unmodified lines)# Render videovideo = render_utils.render_video(outputs['gaussian'][0], num_frames=120)['color']video_geo = render_utils.render_video(outputs['mesh'][0], num_frames=120)['normal']video = [np.concatenate([video[i], video_geo[i]], axis=1) for i in range(len(video))]115 unmodified linesimage_prompt = gr.Image(label="Image Prompt", format="png", visible=False, image_mode="RGBA", type="pil", height=300)multiimage_prompt = gr.Gallery(label="Image Prompt", format="png", type="pil", height=300, columns=3)gr.Markdown("""Input different views of the object in separate images.*NOTE: this is an experimental algorithm without training a specialized model. It may not produce the best results for all images, especially those having different poses or inconsistent details.*""")with gr.Accordion(label="Generation Settings", open=False):seed = gr.Slider(0, MAX_SEED, label="Seed", value=0, step=1)93 unmodified lines# Launch the Gradio appif __name__ == "__main__":pipeline = TrellisVGGTTo3DPipeline.from_pretrained("Stable-X/trellis-vggt-v0-1")pipeline.cuda()pipeline.VGGT_model.cuda()pipeline.birefnet_model.cuda()192 unmodified lines19319419519619719819910 unmodified lines210211212213214215216217218219220221115 unmodified lines33733833934034134234334493 unmodified lines438439440441442443444192 unmodified linesimage_files = [image[0] for image in multiimages]# Generate 3D modeloutputs, _, _ = pipeline.run(image=image_files,seed=seed,formats=["gaussian", "mesh"],10 unmodified lines)# Render video# import uuid# output_id = str(uuid.uuid4())# os.makedirs(f"{TMP_DIR}/{output_id}", exist_ok=True)# video_path = f"{TMP_DIR}/{output_id}/preview.mp4"# glb_path = f"{TMP_DIR}/{output_id}/mesh.glb"video = render_utils.render_video(outputs['gaussian'][0], num_frames=120)['color']video_geo = render_utils.render_video(outputs['mesh'][0], num_frames=120)['normal']video = [np.concatenate([video[i], video_geo[i]], axis=1) for i in range(len(video))]115 unmodified linesimage_prompt = gr.Image(label="Image Prompt", format="png", visible=False, image_mode="RGBA", type="pil", height=300)multiimage_prompt = gr.Gallery(label="Image Prompt", format="png", type="pil", height=300, columns=3)gr.Markdown("""Input different views of the object in separate images.""")with gr.Accordion(label="Generation Settings", open=False):seed = gr.Slider(0, MAX_SEED, label="Seed", value=0, step=1)93 unmodified lines# Launch the Gradio appif __name__ == "__main__":pipeline = TrellisVGGTTo3DPipeline.from_pretrained("Stable-X/trellis-vggt-v0-2")pipeline.cuda()pipeline.VGGT_model.cuda()pipeline.birefnet_model.cuda()
8 unmodified lines9101112131470 unmodified lines858687888 unmodified lines'SLatMeshDecoder': 'structured_latent_vae','SLatFlowModel': 'structured_latent_flow','ModulatedMultiViewCond': 'sparse_structure_flow',}__submodules = []70 unmodified linesfrom .sparse_structure_vae import SparseStructureEncoder, SparseStructureDecoderfrom .sparse_structure_flow import SparseStructureFlowModel, ModulatedMultiViewCondfrom .structured_latent_vae import SLatEncoder, SLatGaussianDecoder, SLatMeshDecoderfrom .structured_latent_flow import SLatFlowModel8 unmodified lines910111213141570 unmodified lines868788898 unmodified lines'SLatMeshDecoder': 'structured_latent_vae','SLatFlowModel': 'structured_latent_flow','ModulatedMultiViewCond': 'sparse_structure_flow','ModulatedSLATMultiViewCond': 'structured_latent_flow',}__submodules = []70 unmodified linesfrom .sparse_structure_vae import SparseStructureEncoder, SparseStructureDecoderfrom .sparse_structure_flow import SparseStructureFlowModel, ModulatedMultiViewCondfrom .structured_latent_vae import SLatEncoder, SLatGaussianDecoder, SLatMeshDecoderfrom .structured_latent_flow import SLatFlowModel, ModulatedSLATMultiViewCond
310 unmodified lines3113123133143153163 unmodified lines3203213223233243253263273283293303313323333345 unmodified lines340341342310 unmodified linest_emb = self.adaLN_modulation(t_emb)t_emb = t_emb.type(self.dtype)skips = []# pack with input blocksfor block in self.input_blocks:3 unmodified linesif self.pe_mode == "ape":h = h + self.pos_embedder(h.coords[:, 1:]).type(self.dtype)if isinstance(cond, list):for i in range(len(cond)):cond_tmp = cond[i].type(self.dtype)for block in self.blocks:h = block(h, t_emb, cond_tmp)else:cond = cond.type(self.dtype)for block in self.blocks:h = block(h, t_emb, cond)# unpack with output blocksfor block, skip in zip(self.out_blocks, reversed(skips)):5 unmodified linesh = h.replace(F.layer_norm(h.feats, h.feats.shape[-1:]))h = self.out_layer(h.type(x.dtype))return h310 unmodified lines3113123133143153163173183193203213 unmodified lines3253263273283293303313325 unmodified lines338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398310 unmodified linest_emb = self.adaLN_modulation(t_emb)t_emb = t_emb.type(self.dtype)if isinstance(cond, list):cond = [c.type(self.dtype) for c in cond]else:cond = cond.type(self.dtype)skips = []# pack with input blocksfor block in self.input_blocks:3 unmodified linesif self.pe_mode == "ape":h = h + self.pos_embedder(h.coords[:, 1:]).type(self.dtype)for block in self.blocks:h = block(h, t_emb, cond)# unpack with output blocksfor block, skip in zip(self.out_blocks, reversed(skips)):5 unmodified linesh = h.replace(F.layer_norm(h.feats, h.feats.shape[-1:]))h = self.out_layer(h.type(x.dtype))return hclass ModulatedSLATMultiViewCond(nn.Module):"""Transformer cross-attention block (MSA + MCA + FFN) with adaptive layer norm conditioning."""def __init__(self,channels: int,ctx_channels: int,dtype: Optional[torch.dtype] = torch.float32,use_fp16: bool = True,):super().__init__()self.linear_blocks = nn.ModuleList([nn.Sequential(nn.Linear(ctx_channels, channels, bias=True),nn.ReLU(),)for _ in range(4)])self.fuse_blocks = nn.ModuleList([nn.Sequential(nn.Linear(ctx_channels, channels, bias=True),nn.ReLU(),)for _ in range(4)])self.use_fp16 = use_fp16if use_fp16:self.dtype = torch.float16else:self.dtype = dtypeself.intermediate_layer_idx = [4, 11, 17, 23]if use_fp16:self.convert_to_fp16()def convert_to_fp16(self) -> None:"""Convert the torso of the model to float16."""self.use_fp16 = Trueself.dtype = torch.float16self.linear_blocks.apply(convert_module_to_f16)def forward(self, aggregated_tokens_list: List, image_cond: torch.Tensor):b, n, _, _ = aggregated_tokens_list[0].shapeidx = 0cond = image_cond.reshape(b*n, -1, 1024).to(self.dtype)for layer_idx in self.intermediate_layer_idx:x = aggregated_tokens_list[layer_idx]# x = x.reshape(b, -1, 2048) + torch.cat([image_cond.reshape(b, -1, 1024), image_cond.reshape(b, -1, 1024)],dim=-1)x = torch.cat([x.reshape(b*n, -1, 2048), cond.reshape(b*n, -1, 1024)],dim=-1).to(self.dtype)x = self.linear_blocks[idx](x)cond = x + image_cond.reshape(b*n, -1, 1024).to(self.dtype)idx = idx + 1return cond
149 unmodified lines150151152153154155156157149 unmodified linesh = h * gate_msax = x + hh = x.replace(self.norm2(x.feats))h = self.cross_attn(h, context)x = x + hh = x.replace(self.norm3(x.feats))h = h * (1 + scale_mlp) + shift_mlph = self.mlp(h)149 unmodified lines150151152153154155156157158159160161162163149 unmodified linesh = h * gate_msax = x + hh = x.replace(self.norm2(x.feats))# h = self.cross_attn(h, context)# x = x + hif isinstance(context, list):for ctx in context:x = x + self.cross_attn(h, ctx) / len(context)else:h = self.cross_attn(h, context)x = x + hh = x.replace(self.norm3(x.feats))h = h * (1 + scale_mlp) + shift_mlph = self.mlp(h)
137 unmodified lines138139140141142143144145146147148149150137 unmodified linesshift_msa, scale_msa, gate_msa, shift_mlp, scale_mlp, gate_mlp = self.adaLN_modulation(mod).chunk(6, dim=1)h = self.norm1(x)h = h * (1 + scale_msa.unsqueeze(1)) + shift_msa.unsqueeze(1)# h = torch.utils.checkpoint.checkpoint(self.self_attn, h)h = self.self_attn(h)h = h * gate_msa.unsqueeze(1)x = x + hh = self.norm2(x)h = self.cross_attn(h, context)x = x + hh = self.norm3(x)h = h * (1 + scale_mlp.unsqueeze(1)) + shift_mlp.unsqueeze(1)h = self.mlp(h)137 unmodified lines138139140141142143144145146147148149150151152153154155137 unmodified linesshift_msa, scale_msa, gate_msa, shift_mlp, scale_mlp, gate_mlp = self.adaLN_modulation(mod).chunk(6, dim=1)h = self.norm1(x)h = h * (1 + scale_msa.unsqueeze(1)) + shift_msa.unsqueeze(1)h = self.self_attn(h)h = h * gate_msa.unsqueeze(1)x = x + hh = self.norm2(x)# h = self.cross_attn(h, context)# x = x + hif isinstance(context, list):for ctx in context:x = x + self.cross_attn(h, ctx) / len(context)else:h = self.cross_attn(h, context)x = x + hh = self.norm3(x)h = h * (1 + scale_mlp.unsqueeze(1)) + shift_mlp.unsqueeze(1)h = self.mlp(h)
23 unmodified lines24252627282923 unmodified linesself.sparse_structure_flow_model = self.models['sparse_structure_flow_model']if 'sparse_structure_vggt_cond' in self.models:self.sparse_structure_vggt_cond = self.models['sparse_structure_vggt_cond']@staticmethoddef from_pretrained(path: str) -> "Pipeline":"""23 unmodified lines24252627282930313223 unmodified linesself.sparse_structure_flow_model = self.models['sparse_structure_flow_model']if 'sparse_structure_vggt_cond' in self.models:self.sparse_structure_vggt_cond = self.models['sparse_structure_vggt_cond']if 'slat_vggt_cond' in self.models:self.slat_vggt_cond = self.models['slat_vggt_cond']@staticmethoddef from_pretrained(path: str) -> "Pipeline":"""
app.py+10-6
trellis/__pycache__/__init__.cpython-310.pyc
trellis/models/__init__.py+2-1
trellis/models/__pycache__/__init__.cpython-310.pyc
trellis/models/__pycache__/sparse_structure_flow.cpython-310.pyc
trellis/models/__pycache__/sparse_structure_vae.cpython-310.pyc
trellis/models/__pycache__/structured_latent_flow.cpython-310.pyc
trellis/models/structured_latent_flow.py+65-9
trellis/models/structured_latent_vae/__pycache__/__init__.cpython-310.pyc
trellis/models/structured_latent_vae/__pycache__/base.cpython-310.pyc
trellis/models/structured_latent_vae/__pycache__/decoder_gs.cpython-310.pyc
trellis/models/structured_latent_vae/__pycache__/decoder_mesh.cpython-310.pyc
trellis/models/structured_latent_vae/__pycache__/encoder.cpython-310.pyc
trellis/modules/__pycache__/norm.cpython-310.pyc
trellis/modules/__pycache__/spatial.cpython-310.pyc
trellis/modules/__pycache__/utils.cpython-310.pyc
trellis/modules/attention/__pycache__/__init__.cpython-310.pyc
trellis/modules/attention/__pycache__/full_attn.cpython-310.pyc
trellis/modules/attention/__pycache__/modules.cpython-310.pyc
trellis/modules/sparse/__pycache__/__init__.cpython-310.pyc
trellis/modules/sparse/__pycache__/basic.cpython-310.pyc
trellis/modules/sparse/__pycache__/linear.cpython-310.pyc
trellis/modules/sparse/__pycache__/nonlinearity.cpython-310.pyc
trellis/modules/sparse/__pycache__/norm.cpython-310.pyc
trellis/modules/sparse/__pycache__/spatial.cpython-310.pyc
trellis/modules/sparse/attention/__pycache__/__init__.cpython-310.pyc
trellis/modules/sparse/attention/__pycache__/full_attn.cpython-310.pyc
trellis/modules/sparse/attention/__pycache__/modules.cpython-310.pyc
trellis/modules/sparse/attention/__pycache__/serialized_attn.cpython-310.pyc
trellis/modules/sparse/attention/__pycache__/windowed_attn.cpython-310.pyc
trellis/modules/sparse/conv/__pycache__/__init__.cpython-310.pyc
trellis/modules/sparse/conv/__pycache__/conv_spconv.cpython-310.pyc
trellis/modules/sparse/transformer/__pycache__/__init__.cpython-310.pyc
trellis/modules/sparse/transformer/__pycache__/blocks.cpython-310.pyc
trellis/modules/sparse/transformer/__pycache__/modulated.cpython-310.pyc
trellis/modules/sparse/transformer/modulated.py+8-2
trellis/modules/transformer/__pycache__/__init__.cpython-310.pyc
trellis/modules/transformer/__pycache__/blocks.cpython-310.pyc
trellis/modules/transformer/__pycache__/modulated.cpython-310.pyc
trellis/modules/transformer/modulated.py+8-3
trellis/pipelines/__pycache__/__init__.cpython-310.pyc
trellis/pipelines/__pycache__/base.cpython-310.pyc
trellis/pipelines/__pycache__/trellis_image_to_3d.cpython-310.pyc
trellis/pipelines/base.py+3
trellis/pipelines/samplers/__pycache__/__init__.cpython-310.pyc
trellis/pipelines/samplers/__pycache__/base.cpython-310.pyc
trellis/pipelines/samplers/__pycache__/classifier_free_guidance_mixin.cpython-310.pyc
trellis/pipelines/samplers/__pycache__/flow_euler.cpython-310.pyc
trellis/pipelines/samplers/__pycache__/flow_euler_old.cpython-310.pyc
trellis/pipelines/samplers/__pycache__/guidance_interval_mixin.cpython-310.pyc