diff --git a/.gitignore b/.gitignore index 0530ca6e7c9a971f62e2e67a6dab1bc898f18df2..0e0398be6634bd501b7439e4cfa832692252d0df 100644 --- a/.gitignore +++ b/.gitignore @@ -166,3 +166,5 @@ cython_debug/ /__pycache__ /temp_models /.vscode/settings.json +**/*.pyc +**/__pycache__/ \ No newline at end of file diff --git a/app.py b/app.py index b94e124d4b35d0a1f4a21b799e1f5187ea4dc45d..bbb7fa7620a425c4c8336ec772fecfc656f9166e 100644 --- a/app.py +++ b/app.py @@ -1,6 +1,6 @@ import gradio as gr import os - +import spaces import numpy as np os.environ['SPCONV_ALGO'] = 'native' from typing import * @@ -100,7 +100,7 @@ from utils.version_info import ( #release_torch_resources, #get_torch_info ) -import spaces + input_image_palette = [] current_prerendered_image = gr.State("./images/images/Beeuty-1.png") @@ -718,6 +718,28 @@ def generate_3d_asset(depth_image_source, randomize_seed, seed, input_image, out "cfg_strength": 3.0, }, ) + + # Validate the mesh + mesh = outputs['mesh'][0] + # Depending on the mesh format (it might be a dict or an object) + if isinstance(mesh, dict): + vertices = mesh['vertices'] + faces = mesh['faces'] + else: + vertices = mesh.vertices + faces = mesh.faces + + # Check mesh properties + print(f"Mesh vertices: {vertices.shape}, faces: {faces.shape}") + if faces.max() >= vertices.shape[0]: + raise ValueError(f"Invalid mesh: face index {faces.max()} exceeds vertex count {vertices.shape[0]}") + + # Ensure data is on GPU and has correct type + if not vertices.is_cuda or not faces.is_cuda: + raise ValueError("Mesh data must be on GPU") + if vertices.dtype != torch.float32 or faces.dtype != torch.int32: + raise ValueError("Mesh vertices must be float32, faces must be int32") + # Save the video to a temporary file user_dir = os.path.join(constants.TMPDIR, str(req.session_hash)) os.makedirs(user_dir, exist_ok=True) @@ -725,7 +747,7 @@ def generate_3d_asset(depth_image_source, randomize_seed, seed, input_image, out video = render_utils.render_video(outputs['gaussian'][0], resolution=576, num_frames=60, r=1)['color'] snapshot_results = render_utils.render_snapshot(outputs['gaussian'][0], resolution=576) depth_snapshot = snapshot_results['depth'][0] - video_geo = render_utils.render_video(outputs['mesh'][0], resolution=576, num_frames=30, r=1)['normal'] + video_geo = render_utils.render_video(outputs['mesh'][0], resolution=576, num_frames=60, r=1)['normal'] video = [np.concatenate([video[i], video_geo[i]], axis=1) for i in range(len(video))] video_path = os.path.join(user_dir, f'{output_name}.mp4') imageio.mimsave(video_path, video, fps=15) diff --git a/requirements.txt b/requirements.txt index d1fa7a54a96cc0481c998d739e79529655c4f2a0..be90863f3e530ed6a3368b53c5985bd31e259a91 100644 --- a/requirements.txt +++ b/requirements.txt @@ -17,9 +17,9 @@ sentencepiece #generic Torch versions --extra-index-url https://download.pytorch.org/whl/cu124 -torch==2.6.0 +torch torchvision -#xformers #==0.0.29.post3 +xformers #==0.0.29.post3 # Other dependencies Haishoku @@ -68,9 +68,9 @@ git+https://github.com/EasternJournalist/utils3d.git@9a4eb15e4021b67b12c460c7057 spconv-cu124==2.3.8 gradio_litmodel3d==0.0.1 #linux only -#https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.0.post2/flash_attn-2.7.0.post2+cu12torch2.4cxx11abiFALSE-cp310-cp310-linux_x86_64.whl -#https://huggingface.co/spaces/JeffreyXiang/TRELLIS/resolve/main/wheels/diff_gaussian_rasterization-0.0.0-cp310-cp310-linux_x86_64.whl?download=true -#https://huggingface.co/spaces/JeffreyXiang/TRELLIS/resolve/main/wheels/nvdiffrast-0.3.3-cp310-cp310-linux_x86_64.whl?download=true +https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.3/flash_attn-2.7.3+cu12torch2.6cxx11abiFALSE-cp310-cp310-linux_x86_64.whl +https://huggingface.co/spaces/JeffreyXiang/TRELLIS/resolve/main/wheels/diff_gaussian_rasterization-0.0.0-cp310-cp310-linux_x86_64.whl?download=true +https://huggingface.co/spaces/JeffreyXiang/TRELLIS/resolve/main/wheels/nvdiffrast-0.3.3-cp310-cp310-linux_x86_64.whl?download=true #Windows only #https://huggingface.co/spaces/Surn/HexaGrid/main/wheels/flash_attn-2.7.4.post1-cp312-cp312-win_amd64.whl?download=true #https://huggingface.co/spaces/Surn/HexaGrid/main/wheels/diff_gaussian_rasterization-0.0.0-cp312-cp312-win_amd64.whl?download=true diff --git a/trellis/__pycache__/__init__.cpython-312.pyc b/trellis/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index ec0829924073627eb22d9e98acbb69ce3b54d063..0000000000000000000000000000000000000000 Binary files a/trellis/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/trellis/models/__pycache__/__init__.cpython-312.pyc b/trellis/models/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 4be796442c44b10f306438d9453acbcaf75c8cdc..0000000000000000000000000000000000000000 Binary files a/trellis/models/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/trellis/models/__pycache__/sparse_structure_flow.cpython-312.pyc b/trellis/models/__pycache__/sparse_structure_flow.cpython-312.pyc deleted file mode 100644 index 4d7e6aad0f0a49ea364de349a52b60ced0932ba0..0000000000000000000000000000000000000000 Binary files a/trellis/models/__pycache__/sparse_structure_flow.cpython-312.pyc and /dev/null differ diff --git a/trellis/models/__pycache__/sparse_structure_vae.cpython-312.pyc b/trellis/models/__pycache__/sparse_structure_vae.cpython-312.pyc deleted file mode 100644 index c271dd030c92b28e802d81cc933c50d40fe64521..0000000000000000000000000000000000000000 Binary files a/trellis/models/__pycache__/sparse_structure_vae.cpython-312.pyc and /dev/null differ diff --git a/trellis/models/__pycache__/structured_latent_flow.cpython-312.pyc b/trellis/models/__pycache__/structured_latent_flow.cpython-312.pyc deleted file mode 100644 index 0cd1be4014fcbd59089c22d1894e60f2abc57f5e..0000000000000000000000000000000000000000 Binary files a/trellis/models/__pycache__/structured_latent_flow.cpython-312.pyc and /dev/null differ diff --git a/trellis/models/structured_latent_vae/__pycache__/__init__.cpython-312.pyc b/trellis/models/structured_latent_vae/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 7aeccdae06e76b4398af107ecd446cf4a4c82366..0000000000000000000000000000000000000000 Binary files a/trellis/models/structured_latent_vae/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/trellis/models/structured_latent_vae/__pycache__/base.cpython-312.pyc b/trellis/models/structured_latent_vae/__pycache__/base.cpython-312.pyc deleted file mode 100644 index 98a0a338ce5d26e8ddc447130b1f536575dfbfd6..0000000000000000000000000000000000000000 Binary files a/trellis/models/structured_latent_vae/__pycache__/base.cpython-312.pyc and /dev/null differ diff --git a/trellis/models/structured_latent_vae/__pycache__/decoder_gs.cpython-312.pyc b/trellis/models/structured_latent_vae/__pycache__/decoder_gs.cpython-312.pyc deleted file mode 100644 index d5bd82adba79c5e479f2c7ec22bfd92ecf717315..0000000000000000000000000000000000000000 Binary files a/trellis/models/structured_latent_vae/__pycache__/decoder_gs.cpython-312.pyc and /dev/null differ diff --git a/trellis/models/structured_latent_vae/__pycache__/decoder_mesh.cpython-312.pyc b/trellis/models/structured_latent_vae/__pycache__/decoder_mesh.cpython-312.pyc deleted file mode 100644 index 40ff943c73eeb195770329a90133133872156bb2..0000000000000000000000000000000000000000 Binary files a/trellis/models/structured_latent_vae/__pycache__/decoder_mesh.cpython-312.pyc and /dev/null differ diff --git a/trellis/models/structured_latent_vae/__pycache__/decoder_rf.cpython-312.pyc b/trellis/models/structured_latent_vae/__pycache__/decoder_rf.cpython-312.pyc deleted file mode 100644 index 33f01fb649e0067f39e808d46a5e7e3f53513b16..0000000000000000000000000000000000000000 Binary files a/trellis/models/structured_latent_vae/__pycache__/decoder_rf.cpython-312.pyc and /dev/null differ diff --git a/trellis/models/structured_latent_vae/__pycache__/encoder.cpython-312.pyc b/trellis/models/structured_latent_vae/__pycache__/encoder.cpython-312.pyc deleted file mode 100644 index 9567725023ad8e86cd25c3b7ad9915d35379e4f8..0000000000000000000000000000000000000000 Binary files a/trellis/models/structured_latent_vae/__pycache__/encoder.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/__pycache__/norm.cpython-312.pyc b/trellis/modules/__pycache__/norm.cpython-312.pyc deleted file mode 100644 index 10a402d44ce4028f100cd6ffbd6178143b1c9dc2..0000000000000000000000000000000000000000 Binary files a/trellis/modules/__pycache__/norm.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/__pycache__/spatial.cpython-312.pyc b/trellis/modules/__pycache__/spatial.cpython-312.pyc deleted file mode 100644 index 7d9a43f5aac2ca32201c4135b052ff4cd7ce2490..0000000000000000000000000000000000000000 Binary files a/trellis/modules/__pycache__/spatial.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/__pycache__/utils.cpython-312.pyc b/trellis/modules/__pycache__/utils.cpython-312.pyc deleted file mode 100644 index 00b9fc1016014967d93cc8b0cd9acf918ef6c8d3..0000000000000000000000000000000000000000 Binary files a/trellis/modules/__pycache__/utils.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/attention/__pycache__/__init__.cpython-312.pyc b/trellis/modules/attention/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 64f47db78716fa034e0534862ff8c23a4407bf57..0000000000000000000000000000000000000000 Binary files a/trellis/modules/attention/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/attention/__pycache__/full_attn.cpython-312.pyc b/trellis/modules/attention/__pycache__/full_attn.cpython-312.pyc deleted file mode 100644 index 08fe0b2d9b3f12be84f70600de190cd77d65f2bf..0000000000000000000000000000000000000000 Binary files a/trellis/modules/attention/__pycache__/full_attn.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/attention/__pycache__/modules.cpython-312.pyc b/trellis/modules/attention/__pycache__/modules.cpython-312.pyc deleted file mode 100644 index 65e6d5e8bb7939a32dfea539b44f503dee6e4693..0000000000000000000000000000000000000000 Binary files a/trellis/modules/attention/__pycache__/modules.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/sparse/__pycache__/__init__.cpython-312.pyc b/trellis/modules/sparse/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index d0b1fdcadce609f59e459162b079c0ff0ed22a4c..0000000000000000000000000000000000000000 Binary files a/trellis/modules/sparse/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/sparse/__pycache__/basic.cpython-312.pyc b/trellis/modules/sparse/__pycache__/basic.cpython-312.pyc deleted file mode 100644 index fda3339ac76b83724db362b0ebf7485af2a2574a..0000000000000000000000000000000000000000 Binary files a/trellis/modules/sparse/__pycache__/basic.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/sparse/__pycache__/linear.cpython-312.pyc b/trellis/modules/sparse/__pycache__/linear.cpython-312.pyc deleted file mode 100644 index 41a9c8089b0a48b85bbd5ad6687be9411f27915f..0000000000000000000000000000000000000000 Binary files a/trellis/modules/sparse/__pycache__/linear.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/sparse/__pycache__/nonlinearity.cpython-312.pyc b/trellis/modules/sparse/__pycache__/nonlinearity.cpython-312.pyc deleted file mode 100644 index 220c9da7bd4854129f91afc214081f4aea0d05a0..0000000000000000000000000000000000000000 Binary files a/trellis/modules/sparse/__pycache__/nonlinearity.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/sparse/__pycache__/norm.cpython-312.pyc b/trellis/modules/sparse/__pycache__/norm.cpython-312.pyc deleted file mode 100644 index b13d0b84589301a7f367c871c26c4613e92f18b2..0000000000000000000000000000000000000000 Binary files a/trellis/modules/sparse/__pycache__/norm.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/sparse/__pycache__/spatial.cpython-312.pyc b/trellis/modules/sparse/__pycache__/spatial.cpython-312.pyc deleted file mode 100644 index 7650720987756cd9103c17b616b1e239eeea2192..0000000000000000000000000000000000000000 Binary files a/trellis/modules/sparse/__pycache__/spatial.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/sparse/attention/__pycache__/__init__.cpython-312.pyc b/trellis/modules/sparse/attention/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 46749db0802782f2d621ba73baa748965f5de253..0000000000000000000000000000000000000000 Binary files a/trellis/modules/sparse/attention/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/sparse/attention/__pycache__/full_attn.cpython-312.pyc b/trellis/modules/sparse/attention/__pycache__/full_attn.cpython-312.pyc deleted file mode 100644 index cd6630a9d8be4f37a7e8336563927c7f03c930dc..0000000000000000000000000000000000000000 Binary files a/trellis/modules/sparse/attention/__pycache__/full_attn.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/sparse/attention/__pycache__/modules.cpython-312.pyc b/trellis/modules/sparse/attention/__pycache__/modules.cpython-312.pyc deleted file mode 100644 index 8e6214668791c41591ceaa8d3f6e9393ea545188..0000000000000000000000000000000000000000 Binary files a/trellis/modules/sparse/attention/__pycache__/modules.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/sparse/attention/__pycache__/serialized_attn.cpython-312.pyc b/trellis/modules/sparse/attention/__pycache__/serialized_attn.cpython-312.pyc deleted file mode 100644 index d20d337fa7244f7c406bb563cc3ae777418a76f2..0000000000000000000000000000000000000000 Binary files a/trellis/modules/sparse/attention/__pycache__/serialized_attn.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/sparse/attention/__pycache__/windowed_attn.cpython-312.pyc b/trellis/modules/sparse/attention/__pycache__/windowed_attn.cpython-312.pyc deleted file mode 100644 index 437be41a56c0aaff41575d16e882d8ae86397a69..0000000000000000000000000000000000000000 Binary files a/trellis/modules/sparse/attention/__pycache__/windowed_attn.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/sparse/conv/__pycache__/__init__.cpython-312.pyc b/trellis/modules/sparse/conv/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 99b9a045f96cfbf80942966bde6bfaf593fe4622..0000000000000000000000000000000000000000 Binary files a/trellis/modules/sparse/conv/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/sparse/conv/__pycache__/conv_spconv.cpython-312.pyc b/trellis/modules/sparse/conv/__pycache__/conv_spconv.cpython-312.pyc deleted file mode 100644 index b560098b3862cea5665be02e9c5ea18fa9e19a4a..0000000000000000000000000000000000000000 Binary files a/trellis/modules/sparse/conv/__pycache__/conv_spconv.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/sparse/transformer/__pycache__/__init__.cpython-312.pyc b/trellis/modules/sparse/transformer/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index dd269ded671dfe990b726706a57d5974f5d5620d..0000000000000000000000000000000000000000 Binary files a/trellis/modules/sparse/transformer/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/sparse/transformer/__pycache__/blocks.cpython-312.pyc b/trellis/modules/sparse/transformer/__pycache__/blocks.cpython-312.pyc deleted file mode 100644 index b8bf2666e6a3812f95e53dcf76670bde402332f2..0000000000000000000000000000000000000000 Binary files a/trellis/modules/sparse/transformer/__pycache__/blocks.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/sparse/transformer/__pycache__/modulated.cpython-312.pyc b/trellis/modules/sparse/transformer/__pycache__/modulated.cpython-312.pyc deleted file mode 100644 index df6a7ee7dfee8255acbc370e802674b5d663e347..0000000000000000000000000000000000000000 Binary files a/trellis/modules/sparse/transformer/__pycache__/modulated.cpython-312.pyc and /dev/null differ diff --git a/trellis/modules/transformer/__pycache__/__init__.cpython-312.pyc b/trellis/modules/transformer/__pycache__/__init__.cpython-312.pyc index cd627b1e4f6496e04a6f2b7c5975a38767bddc02..fa72ebee29472df549e9daf285c70bc4ff71ea9f 100644 Binary files a/trellis/modules/transformer/__pycache__/__init__.cpython-312.pyc and b/trellis/modules/transformer/__pycache__/__init__.cpython-312.pyc differ diff --git a/trellis/modules/transformer/__pycache__/blocks.cpython-312.pyc b/trellis/modules/transformer/__pycache__/blocks.cpython-312.pyc index c4a46188e4ffb3c744ec08d2d31e2ff3e04c9027..9c44c4b7662c545df2bf1c3fdb3d77dce9e907b4 100644 Binary files a/trellis/modules/transformer/__pycache__/blocks.cpython-312.pyc and b/trellis/modules/transformer/__pycache__/blocks.cpython-312.pyc differ diff --git a/trellis/modules/transformer/__pycache__/modulated.cpython-312.pyc b/trellis/modules/transformer/__pycache__/modulated.cpython-312.pyc index ec14ce68719eefbc077f493353e6e3c30d826bc8..8fd938365ccb25079580d5544f028be6eb1621e6 100644 Binary files a/trellis/modules/transformer/__pycache__/modulated.cpython-312.pyc and b/trellis/modules/transformer/__pycache__/modulated.cpython-312.pyc differ diff --git a/trellis/pipelines/__pycache__/__init__.cpython-312.pyc b/trellis/pipelines/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 951938fb723b39349da43e83c3b280b4659c0d63..0000000000000000000000000000000000000000 Binary files a/trellis/pipelines/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/trellis/pipelines/__pycache__/base.cpython-312.pyc b/trellis/pipelines/__pycache__/base.cpython-312.pyc deleted file mode 100644 index 19705cd2003cd1ee855d5c135c48343f26c9d8c6..0000000000000000000000000000000000000000 Binary files a/trellis/pipelines/__pycache__/base.cpython-312.pyc and /dev/null differ diff --git a/trellis/pipelines/__pycache__/trellis_image_to_3d.cpython-312.pyc b/trellis/pipelines/__pycache__/trellis_image_to_3d.cpython-312.pyc deleted file mode 100644 index 176eda386d28706908209b938c8c7198c511cc35..0000000000000000000000000000000000000000 Binary files a/trellis/pipelines/__pycache__/trellis_image_to_3d.cpython-312.pyc and /dev/null differ diff --git a/trellis/pipelines/samplers/__pycache__/__init__.cpython-312.pyc b/trellis/pipelines/samplers/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index fb70d48651685f712a31c16481ffd2b4fbd3009f..0000000000000000000000000000000000000000 Binary files a/trellis/pipelines/samplers/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/trellis/pipelines/samplers/__pycache__/base.cpython-312.pyc b/trellis/pipelines/samplers/__pycache__/base.cpython-312.pyc deleted file mode 100644 index a7bd8979b3902b7a9dbc5d15039b737059e45319..0000000000000000000000000000000000000000 Binary files a/trellis/pipelines/samplers/__pycache__/base.cpython-312.pyc and /dev/null differ diff --git a/trellis/pipelines/samplers/__pycache__/classifier_free_guidance_mixin.cpython-312.pyc b/trellis/pipelines/samplers/__pycache__/classifier_free_guidance_mixin.cpython-312.pyc deleted file mode 100644 index e329e60d16500b58300a5321b6f19d65f509b602..0000000000000000000000000000000000000000 Binary files a/trellis/pipelines/samplers/__pycache__/classifier_free_guidance_mixin.cpython-312.pyc and /dev/null differ diff --git a/trellis/pipelines/samplers/__pycache__/flow_euler.cpython-312.pyc b/trellis/pipelines/samplers/__pycache__/flow_euler.cpython-312.pyc deleted file mode 100644 index 7aa8177c5bb44076c349203b79ff50f482e64c95..0000000000000000000000000000000000000000 Binary files a/trellis/pipelines/samplers/__pycache__/flow_euler.cpython-312.pyc and /dev/null differ diff --git a/trellis/pipelines/samplers/__pycache__/guidance_interval_mixin.cpython-312.pyc b/trellis/pipelines/samplers/__pycache__/guidance_interval_mixin.cpython-312.pyc deleted file mode 100644 index 2fc02859f816e6eda923374d2bf1b6dc900d9c7b..0000000000000000000000000000000000000000 Binary files a/trellis/pipelines/samplers/__pycache__/guidance_interval_mixin.cpython-312.pyc and /dev/null differ diff --git a/trellis/renderers/__pycache__/__init__.cpython-312.pyc b/trellis/renderers/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index c157e76ec5e600c9c1f6c0454d4d9ad4bab45757..0000000000000000000000000000000000000000 Binary files a/trellis/renderers/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/trellis/renderers/__pycache__/gaussian_render.cpython-312.pyc b/trellis/renderers/__pycache__/gaussian_render.cpython-312.pyc deleted file mode 100644 index 389aba63346bfe06745219f1da6679e75e331b16..0000000000000000000000000000000000000000 Binary files a/trellis/renderers/__pycache__/gaussian_render.cpython-312.pyc and /dev/null differ diff --git a/trellis/renderers/__pycache__/mesh_renderer.cpython-312.pyc b/trellis/renderers/__pycache__/mesh_renderer.cpython-312.pyc deleted file mode 100644 index 4757e07242a0083095cb600deb5446d03ef03062..0000000000000000000000000000000000000000 Binary files a/trellis/renderers/__pycache__/mesh_renderer.cpython-312.pyc and /dev/null differ diff --git a/trellis/renderers/__pycache__/octree_renderer.cpython-312.pyc b/trellis/renderers/__pycache__/octree_renderer.cpython-312.pyc deleted file mode 100644 index eb3b1050a370ebd8bbd6a47dc6a394f14f691fa9..0000000000000000000000000000000000000000 Binary files a/trellis/renderers/__pycache__/octree_renderer.cpython-312.pyc and /dev/null differ diff --git a/trellis/renderers/__pycache__/sh_utils.cpython-312.pyc b/trellis/renderers/__pycache__/sh_utils.cpython-312.pyc deleted file mode 100644 index 306bf5469cc94c1f16c831fbcb8de31a4c7dc14e..0000000000000000000000000000000000000000 Binary files a/trellis/renderers/__pycache__/sh_utils.cpython-312.pyc and /dev/null differ diff --git a/trellis/representations/__pycache__/__init__.cpython-312.pyc b/trellis/representations/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 82ed72d32ad0c45d9b8145a5159aa87a8dde1c84..0000000000000000000000000000000000000000 Binary files a/trellis/representations/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/trellis/representations/gaussian/__pycache__/__init__.cpython-312.pyc b/trellis/representations/gaussian/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index fa2d4e85629f04647b6626511a13aa8a912fbbf1..0000000000000000000000000000000000000000 Binary files a/trellis/representations/gaussian/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/trellis/representations/gaussian/__pycache__/gaussian_model.cpython-312.pyc b/trellis/representations/gaussian/__pycache__/gaussian_model.cpython-312.pyc deleted file mode 100644 index b7df557a449f41e63569d01547d71c0ab71b5d39..0000000000000000000000000000000000000000 Binary files a/trellis/representations/gaussian/__pycache__/gaussian_model.cpython-312.pyc and /dev/null differ diff --git a/trellis/representations/gaussian/__pycache__/general_utils.cpython-312.pyc b/trellis/representations/gaussian/__pycache__/general_utils.cpython-312.pyc deleted file mode 100644 index 7640cc49400f5a7c11ee438b760a96a567742548..0000000000000000000000000000000000000000 Binary files a/trellis/representations/gaussian/__pycache__/general_utils.cpython-312.pyc and /dev/null differ diff --git a/trellis/representations/mesh/__pycache__/__init__.cpython-312.pyc b/trellis/representations/mesh/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index dd16b9aea270405c7ad1ccef0818cfad5de0ea45..0000000000000000000000000000000000000000 Binary files a/trellis/representations/mesh/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/trellis/representations/mesh/__pycache__/cube2mesh.cpython-312.pyc b/trellis/representations/mesh/__pycache__/cube2mesh.cpython-312.pyc deleted file mode 100644 index b5e944590137ee9e28d975b179ea7ad26f5f93d1..0000000000000000000000000000000000000000 Binary files a/trellis/representations/mesh/__pycache__/cube2mesh.cpython-312.pyc and /dev/null differ diff --git a/trellis/representations/mesh/__pycache__/flexicube.cpython-312.pyc b/trellis/representations/mesh/__pycache__/flexicube.cpython-312.pyc deleted file mode 100644 index 7fac8adb13015a3596aee529819fa1f691b2018f..0000000000000000000000000000000000000000 Binary files a/trellis/representations/mesh/__pycache__/flexicube.cpython-312.pyc and /dev/null differ diff --git a/trellis/representations/mesh/__pycache__/tables.cpython-312.pyc b/trellis/representations/mesh/__pycache__/tables.cpython-312.pyc deleted file mode 100644 index 1d9ce8fa706719ab9375e73e5f05fa6e141159f5..0000000000000000000000000000000000000000 Binary files a/trellis/representations/mesh/__pycache__/tables.cpython-312.pyc and /dev/null differ diff --git a/trellis/representations/mesh/__pycache__/utils_cube.cpython-312.pyc b/trellis/representations/mesh/__pycache__/utils_cube.cpython-312.pyc deleted file mode 100644 index ee9a753f917e18b1c1c5ea79a7293acb8926867e..0000000000000000000000000000000000000000 Binary files a/trellis/representations/mesh/__pycache__/utils_cube.cpython-312.pyc and /dev/null differ diff --git a/trellis/representations/octree/__pycache__/__init__.cpython-312.pyc b/trellis/representations/octree/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index c3dd8cb8d7baf55ff4301f7fc4fee331048c5640..0000000000000000000000000000000000000000 Binary files a/trellis/representations/octree/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/trellis/representations/octree/__pycache__/octree_dfs.cpython-312.pyc b/trellis/representations/octree/__pycache__/octree_dfs.cpython-312.pyc deleted file mode 100644 index cf231a6bbfdb92d477835c455ae8279db518e2f2..0000000000000000000000000000000000000000 Binary files a/trellis/representations/octree/__pycache__/octree_dfs.cpython-312.pyc and /dev/null differ diff --git a/trellis/representations/radiance_field/__pycache__/__init__.cpython-312.pyc b/trellis/representations/radiance_field/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 973e0c12dfaf29c18c60de56ed22075a4be69e0b..0000000000000000000000000000000000000000 Binary files a/trellis/representations/radiance_field/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/trellis/representations/radiance_field/__pycache__/strivec.cpython-312.pyc b/trellis/representations/radiance_field/__pycache__/strivec.cpython-312.pyc deleted file mode 100644 index b973311b11f86bcaa1d5e814c07e91e635e483ac..0000000000000000000000000000000000000000 Binary files a/trellis/representations/radiance_field/__pycache__/strivec.cpython-312.pyc and /dev/null differ diff --git a/trellis/utils/__pycache__/__init__.cpython-312.pyc b/trellis/utils/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 0eb58ccd2a737733ebe7be294e277fd36762846c..0000000000000000000000000000000000000000 Binary files a/trellis/utils/__pycache__/__init__.cpython-312.pyc and /dev/null differ diff --git a/trellis/utils/__pycache__/postprocessing_utils.cpython-312.pyc b/trellis/utils/__pycache__/postprocessing_utils.cpython-312.pyc deleted file mode 100644 index 714a3031bc42c7e2d5fbfd9d81efa2ff9e0b8037..0000000000000000000000000000000000000000 Binary files a/trellis/utils/__pycache__/postprocessing_utils.cpython-312.pyc and /dev/null differ diff --git a/trellis/utils/__pycache__/random_utils.cpython-312.pyc b/trellis/utils/__pycache__/random_utils.cpython-312.pyc deleted file mode 100644 index 225944acbb6ca4010943853007a9055b1c42062a..0000000000000000000000000000000000000000 Binary files a/trellis/utils/__pycache__/random_utils.cpython-312.pyc and /dev/null differ diff --git a/trellis/utils/__pycache__/render_utils.cpython-312.pyc b/trellis/utils/__pycache__/render_utils.cpython-312.pyc deleted file mode 100644 index b2ac23551acf69152a66866420e994b17ec23494..0000000000000000000000000000000000000000 Binary files a/trellis/utils/__pycache__/render_utils.cpython-312.pyc and /dev/null differ diff --git a/utils/depth_estimation.py b/utils/depth_estimation.py index dfa75634211f386afa3206413dda81f2c66df961..9ee2dcc721daccb617110815f96e479cb53807ec 100644 --- a/utils/depth_estimation.py +++ b/utils/depth_estimation.py @@ -1,5 +1,5 @@ # utils/depth_estimation.py - +import os import torch import numpy as np from PIL import Image @@ -11,6 +11,7 @@ logging.getLogger("transformers.modeling_utils").setLevel(logging.ERROR) from utils.image_utils import ( resize_image_with_aspect_ratio ) +from utils.constants import TMPDIR # Load models once during module import image_processor = DPTImageProcessor.from_pretrained("Intel/dpt-large") @@ -257,4 +258,21 @@ def depth_process_image(image_path, resized_width=800, z_scale=208): torch.cuda.ipc_collect() return [img, gltf_path, gltf_path] +def get_depth_map_from_state(state): + from diff_gaussian_rasterization import GaussianRasterizer, GaussianRasterizationSettings + + settings = GaussianRasterizationSettings(image_height=1024, image_width=1024, bg_color=(1.0, 1.0, 1.0), max_num_points_per_tile=100, tile_size=32, filter_mode="linear", precompute_cov3D=True, precompute_cov2D=True, precompute_colors=True) + rasterizer = GaussianRasterizer(settings) + # Assume state has necessary data like means3D, scales, etc. + rendered_image, rendered_depth, _, _, _, _ = rasterizer(means3D=state["means3D"], means2D=state["means2D"], shs=state["shs"], colors_precomp=state["colors_precomp"], opacities=state["opacities"], scales=state["scales"], rotations=state["rotations"], cov3D_precomp=state["cov3D_precomp"]) + name = state['name'] + file_path = os.path.join(TMPDIR, f'{name}.png') + + depth_np = rendered_depth.cpu().numpy()[0] + depth_min = depth_np.min() + depth_max = depth_np.max() + depth_np = (depth_np - depth_min) / (depth_max - depth_min) * 255 + depth_np = depth_np.astype(np.uint8) + Image.fromarray(depth_np).save(file_path) + return file_path \ No newline at end of file