ffgs 0.1.0.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ffgs/__init__.py +39 -0
- ffgs/dynamic.py +239 -0
- ffgs/geometry.py +418 -0
- ffgs/image.py +204 -0
- ffgs/models/__init__.py +2 -0
- ffgs/models/anysplat/LICENSE +1120 -0
- ffgs/models/anysplat/__init__.py +49 -0
- ffgs/models/anysplat/encoder.py +372 -0
- ffgs/models/anysplat/evaluation.py +98 -0
- ffgs/models/anysplat/gaussian_adapter.py +96 -0
- ffgs/models/anysplat/gs_head.py +166 -0
- ffgs/models/anysplat/modeling.py +95 -0
- ffgs/models/anysplat/processing.py +249 -0
- ffgs/models/anysplat/vggt/__init__.py +0 -0
- ffgs/models/anysplat/vggt/heads/__init__.py +0 -0
- ffgs/models/anysplat/vggt/heads/camera_head.py +181 -0
- ffgs/models/anysplat/vggt/heads/dpt_head.py +612 -0
- ffgs/models/anysplat/vggt/heads/head_act.py +134 -0
- ffgs/models/anysplat/vggt/heads/utils.py +126 -0
- ffgs/models/anysplat/vggt/layers/__init__.py +28 -0
- ffgs/models/anysplat/vggt/layers/attention.py +92 -0
- ffgs/models/anysplat/vggt/layers/block.py +157 -0
- ffgs/models/anysplat/vggt/layers/drop_path.py +42 -0
- ffgs/models/anysplat/vggt/layers/layer_scale.py +32 -0
- ffgs/models/anysplat/vggt/layers/mlp.py +45 -0
- ffgs/models/anysplat/vggt/layers/patch_embed.py +106 -0
- ffgs/models/anysplat/vggt/layers/rope.py +211 -0
- ffgs/models/anysplat/vggt/layers/swiglu_ffn.py +77 -0
- ffgs/models/anysplat/vggt/layers/vision_transformer.py +463 -0
- ffgs/models/anysplat/vggt/models/__init__.py +0 -0
- ffgs/models/anysplat/vggt/models/aggregator.py +398 -0
- ffgs/models/anysplat/vggt/utils/__init__.py +0 -0
- ffgs/models/anysplat/vggt/utils/geometry.py +230 -0
- ffgs/models/anysplat/vggt/utils/pose_enc.py +144 -0
- ffgs/models/anysplat/vggt/utils/rotation.py +148 -0
- ffgs/models/tokengs/__init__.py +43 -0
- ffgs/models/tokengs/activations.py +135 -0
- ffgs/models/tokengs/attention.py +189 -0
- ffgs/models/tokengs/enc_dec.py +323 -0
- ffgs/models/tokengs/modeling.py +173 -0
- ffgs/models/tokengs/processing.py +339 -0
- ffgs/pipeline.py +341 -0
- ffgs/processor.py +236 -0
- ffgs/registry.py +132 -0
- ffgs/render.py +111 -0
- ffgs/types.py +291 -0
- ffgs/zoo/__init__.py +234 -0
- ffgs/zoo/anysplat/default.json +34 -0
- ffgs/zoo/tokengs/dl3dv-2v.json +29 -0
- ffgs/zoo/tokengs/dl3dv-4v.json +29 -0
- ffgs/zoo/tokengs/dl3dv-6v.json +29 -0
- ffgs/zoo/tokengs/dl3dv-base.json +29 -0
- ffgs/zoo/tokengs/dl3dv-latent-2v-lpips.json +48 -0
- ffgs/zoo/tokengs/dl3dv-latent-2v-ssim.json +48 -0
- ffgs/zoo/tokengs/dl3dv-latent-4v-lpips.json +48 -0
- ffgs/zoo/tokengs/dl3dv-latent-4v-ssim.json +48 -0
- ffgs/zoo/tokengs/dl3dv-latent-6v-lpips.json +48 -0
- ffgs/zoo/tokengs/dl3dv-latent-6v-ssim.json +48 -0
- ffgs-0.1.0.dev0.dist-info/METADATA +320 -0
- ffgs-0.1.0.dev0.dist-info/RECORD +63 -0
- ffgs-0.1.0.dev0.dist-info/WHEEL +4 -0
- ffgs-0.1.0.dev0.dist-info/licenses/LICENSE +237 -0
- ffgs-0.1.0.dev0.dist-info/licenses/src/ffgs/models/anysplat/LICENSE +1120 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"model_type": "tokengs",
|
|
3
|
+
"description": "TokenGS 2026.6 latent-bottleneck model (12-layer multiscale encoder, 4096 scene latents), DL3DV, 2 input views at 256x448, L2 + 0.5 LPIPS loss (eval preset eval_dl3dv_latent_2view_lpips)",
|
|
4
|
+
"weights": {
|
|
5
|
+
"repo": "jiaweir/tokengs",
|
|
6
|
+
"file": "checkpoints_26.06/dl3dv_latent_2v_lpips.safetensors",
|
|
7
|
+
"revision": "a7eb20340b99abd29b554c29c339446aebccff36",
|
|
8
|
+
"sha256": "b11f2e87b433d39e7a94540016ba8885afd86a2be757847e0d7a46a135f559b0"
|
|
9
|
+
},
|
|
10
|
+
"model": {
|
|
11
|
+
"enc_depth": 12,
|
|
12
|
+
"dec_depth": 1,
|
|
13
|
+
"dec_patch_size": 8,
|
|
14
|
+
"clip_head_readout_std": 0.002,
|
|
15
|
+
"clip_head_z_init": 0.1,
|
|
16
|
+
"dec_init_values": 0.01,
|
|
17
|
+
"gaussian_z_offset": 0.0,
|
|
18
|
+
"opacity_bias": 2.0,
|
|
19
|
+
"gs_token_std": 0.02,
|
|
20
|
+
"use_multiscale_encoder": true,
|
|
21
|
+
"multiscale_encoder_layers": [
|
|
22
|
+
5,
|
|
23
|
+
7,
|
|
24
|
+
9,
|
|
25
|
+
11
|
|
26
|
+
],
|
|
27
|
+
"use_latent_bottleneck": true,
|
|
28
|
+
"num_latents": 4096,
|
|
29
|
+
"latent_cross_attn_depth": 12,
|
|
30
|
+
"num_gs_tokens": 4096
|
|
31
|
+
},
|
|
32
|
+
"processor": {
|
|
33
|
+
"image_shape": [
|
|
34
|
+
256,
|
|
35
|
+
448
|
|
36
|
+
],
|
|
37
|
+
"resize_mode": "bilinear",
|
|
38
|
+
"crop_mode": "crop",
|
|
39
|
+
"camera_normalization": "mean_cam",
|
|
40
|
+
"scene_scale": 0.15,
|
|
41
|
+
"num_input_views": 2
|
|
42
|
+
},
|
|
43
|
+
"source": {
|
|
44
|
+
"url": "https://github.com/nv-tlabs/TokenGS",
|
|
45
|
+
"paper": "https://arxiv.org/abs/2604.15239"
|
|
46
|
+
},
|
|
47
|
+
"license": "NVIDIA Internal Scientific Research and Development Model License"
|
|
48
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"model_type": "tokengs",
|
|
3
|
+
"description": "TokenGS 2026.6 latent-bottleneck model (12-layer multiscale encoder, 4096 scene latents), DL3DV, 2 input views at 256x448, 0.8 L1 + 0.2 SSIM loss (eval preset eval_dl3dv_latent_2view_ssim)",
|
|
4
|
+
"weights": {
|
|
5
|
+
"repo": "jiaweir/tokengs",
|
|
6
|
+
"file": "checkpoints_26.06/dl3dv_latent_2v_ssim.safetensors",
|
|
7
|
+
"revision": "a7eb20340b99abd29b554c29c339446aebccff36",
|
|
8
|
+
"sha256": "57779787fdfe3edb758b9da01bd4911295044d2213e588bf9cf985b5ae9c3743"
|
|
9
|
+
},
|
|
10
|
+
"model": {
|
|
11
|
+
"enc_depth": 12,
|
|
12
|
+
"dec_depth": 1,
|
|
13
|
+
"dec_patch_size": 8,
|
|
14
|
+
"clip_head_readout_std": 0.002,
|
|
15
|
+
"clip_head_z_init": 0.1,
|
|
16
|
+
"dec_init_values": 0.01,
|
|
17
|
+
"gaussian_z_offset": 0.0,
|
|
18
|
+
"opacity_bias": 2.0,
|
|
19
|
+
"gs_token_std": 0.02,
|
|
20
|
+
"use_multiscale_encoder": true,
|
|
21
|
+
"multiscale_encoder_layers": [
|
|
22
|
+
5,
|
|
23
|
+
7,
|
|
24
|
+
9,
|
|
25
|
+
11
|
|
26
|
+
],
|
|
27
|
+
"use_latent_bottleneck": true,
|
|
28
|
+
"num_latents": 4096,
|
|
29
|
+
"latent_cross_attn_depth": 12,
|
|
30
|
+
"num_gs_tokens": 4096
|
|
31
|
+
},
|
|
32
|
+
"processor": {
|
|
33
|
+
"image_shape": [
|
|
34
|
+
256,
|
|
35
|
+
448
|
|
36
|
+
],
|
|
37
|
+
"resize_mode": "bilinear",
|
|
38
|
+
"crop_mode": "crop",
|
|
39
|
+
"camera_normalization": "mean_cam",
|
|
40
|
+
"scene_scale": 0.15,
|
|
41
|
+
"num_input_views": 2
|
|
42
|
+
},
|
|
43
|
+
"source": {
|
|
44
|
+
"url": "https://github.com/nv-tlabs/TokenGS",
|
|
45
|
+
"paper": "https://arxiv.org/abs/2604.15239"
|
|
46
|
+
},
|
|
47
|
+
"license": "NVIDIA Internal Scientific Research and Development Model License"
|
|
48
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"model_type": "tokengs",
|
|
3
|
+
"description": "TokenGS 2026.6 latent-bottleneck model (12-layer multiscale encoder, 4096 scene latents), DL3DV, 4 input views at 256x448, L2 + 0.5 LPIPS loss (eval preset eval_dl3dv_latent_4view_lpips)",
|
|
4
|
+
"weights": {
|
|
5
|
+
"repo": "jiaweir/tokengs",
|
|
6
|
+
"file": "checkpoints_26.06/dl3dv_latent_4v_lpips.safetensors",
|
|
7
|
+
"revision": "a7eb20340b99abd29b554c29c339446aebccff36",
|
|
8
|
+
"sha256": "cee670826d27dcb8ad3a31ca6265aa88cccb3aebf0924f72b6af270a688e6abf"
|
|
9
|
+
},
|
|
10
|
+
"model": {
|
|
11
|
+
"enc_depth": 12,
|
|
12
|
+
"dec_depth": 1,
|
|
13
|
+
"dec_patch_size": 8,
|
|
14
|
+
"clip_head_readout_std": 0.002,
|
|
15
|
+
"clip_head_z_init": 0.1,
|
|
16
|
+
"dec_init_values": 0.01,
|
|
17
|
+
"gaussian_z_offset": 0.0,
|
|
18
|
+
"opacity_bias": 2.0,
|
|
19
|
+
"gs_token_std": 0.02,
|
|
20
|
+
"use_multiscale_encoder": true,
|
|
21
|
+
"multiscale_encoder_layers": [
|
|
22
|
+
5,
|
|
23
|
+
7,
|
|
24
|
+
9,
|
|
25
|
+
11
|
|
26
|
+
],
|
|
27
|
+
"use_latent_bottleneck": true,
|
|
28
|
+
"num_latents": 4096,
|
|
29
|
+
"latent_cross_attn_depth": 12,
|
|
30
|
+
"num_gs_tokens": 4096
|
|
31
|
+
},
|
|
32
|
+
"processor": {
|
|
33
|
+
"image_shape": [
|
|
34
|
+
256,
|
|
35
|
+
448
|
|
36
|
+
],
|
|
37
|
+
"resize_mode": "bilinear",
|
|
38
|
+
"crop_mode": "crop",
|
|
39
|
+
"camera_normalization": "mean_cam",
|
|
40
|
+
"scene_scale": 0.15,
|
|
41
|
+
"num_input_views": 4
|
|
42
|
+
},
|
|
43
|
+
"source": {
|
|
44
|
+
"url": "https://github.com/nv-tlabs/TokenGS",
|
|
45
|
+
"paper": "https://arxiv.org/abs/2604.15239"
|
|
46
|
+
},
|
|
47
|
+
"license": "NVIDIA Internal Scientific Research and Development Model License"
|
|
48
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"model_type": "tokengs",
|
|
3
|
+
"description": "TokenGS 2026.6 latent-bottleneck model (12-layer multiscale encoder, 4096 scene latents), DL3DV, 4 input views at 256x448, 0.8 L1 + 0.2 SSIM loss (eval preset eval_dl3dv_latent_4view_ssim)",
|
|
4
|
+
"weights": {
|
|
5
|
+
"repo": "jiaweir/tokengs",
|
|
6
|
+
"file": "checkpoints_26.06/dl3dv_latent_4v_ssim.safetensors",
|
|
7
|
+
"revision": "a7eb20340b99abd29b554c29c339446aebccff36",
|
|
8
|
+
"sha256": "a6d29102cc08826af3594b1587286a64aca512b1d6d5552151f4b82eb54afa1e"
|
|
9
|
+
},
|
|
10
|
+
"model": {
|
|
11
|
+
"enc_depth": 12,
|
|
12
|
+
"dec_depth": 1,
|
|
13
|
+
"dec_patch_size": 8,
|
|
14
|
+
"clip_head_readout_std": 0.002,
|
|
15
|
+
"clip_head_z_init": 0.1,
|
|
16
|
+
"dec_init_values": 0.01,
|
|
17
|
+
"gaussian_z_offset": 0.0,
|
|
18
|
+
"opacity_bias": 2.0,
|
|
19
|
+
"gs_token_std": 0.02,
|
|
20
|
+
"use_multiscale_encoder": true,
|
|
21
|
+
"multiscale_encoder_layers": [
|
|
22
|
+
5,
|
|
23
|
+
7,
|
|
24
|
+
9,
|
|
25
|
+
11
|
|
26
|
+
],
|
|
27
|
+
"use_latent_bottleneck": true,
|
|
28
|
+
"num_latents": 4096,
|
|
29
|
+
"latent_cross_attn_depth": 12,
|
|
30
|
+
"num_gs_tokens": 4096
|
|
31
|
+
},
|
|
32
|
+
"processor": {
|
|
33
|
+
"image_shape": [
|
|
34
|
+
256,
|
|
35
|
+
448
|
|
36
|
+
],
|
|
37
|
+
"resize_mode": "bilinear",
|
|
38
|
+
"crop_mode": "crop",
|
|
39
|
+
"camera_normalization": "mean_cam",
|
|
40
|
+
"scene_scale": 0.15,
|
|
41
|
+
"num_input_views": 4
|
|
42
|
+
},
|
|
43
|
+
"source": {
|
|
44
|
+
"url": "https://github.com/nv-tlabs/TokenGS",
|
|
45
|
+
"paper": "https://arxiv.org/abs/2604.15239"
|
|
46
|
+
},
|
|
47
|
+
"license": "NVIDIA Internal Scientific Research and Development Model License"
|
|
48
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"model_type": "tokengs",
|
|
3
|
+
"description": "TokenGS 2026.6 latent-bottleneck model (12-layer multiscale encoder, 4096 scene latents), DL3DV, 6 input views at 256x448, L2 + 0.5 LPIPS loss (eval preset eval_dl3dv_latent_6view_lpips)",
|
|
4
|
+
"weights": {
|
|
5
|
+
"repo": "jiaweir/tokengs",
|
|
6
|
+
"file": "checkpoints_26.06/dl3dv_latent_6v_lpips.safetensors",
|
|
7
|
+
"revision": "a7eb20340b99abd29b554c29c339446aebccff36",
|
|
8
|
+
"sha256": "1c48ed3a00acedd8d9d3e3341d18bcd413a68b7d2b5507a7c4442a9136952fb8"
|
|
9
|
+
},
|
|
10
|
+
"model": {
|
|
11
|
+
"enc_depth": 12,
|
|
12
|
+
"dec_depth": 1,
|
|
13
|
+
"dec_patch_size": 8,
|
|
14
|
+
"clip_head_readout_std": 0.002,
|
|
15
|
+
"clip_head_z_init": 0.1,
|
|
16
|
+
"dec_init_values": 0.01,
|
|
17
|
+
"gaussian_z_offset": 0.0,
|
|
18
|
+
"opacity_bias": 2.0,
|
|
19
|
+
"gs_token_std": 0.02,
|
|
20
|
+
"use_multiscale_encoder": true,
|
|
21
|
+
"multiscale_encoder_layers": [
|
|
22
|
+
5,
|
|
23
|
+
7,
|
|
24
|
+
9,
|
|
25
|
+
11
|
|
26
|
+
],
|
|
27
|
+
"use_latent_bottleneck": true,
|
|
28
|
+
"num_latents": 4096,
|
|
29
|
+
"latent_cross_attn_depth": 12,
|
|
30
|
+
"num_gs_tokens": 4096
|
|
31
|
+
},
|
|
32
|
+
"processor": {
|
|
33
|
+
"image_shape": [
|
|
34
|
+
256,
|
|
35
|
+
448
|
|
36
|
+
],
|
|
37
|
+
"resize_mode": "bilinear",
|
|
38
|
+
"crop_mode": "crop",
|
|
39
|
+
"camera_normalization": "mean_cam",
|
|
40
|
+
"scene_scale": 0.15,
|
|
41
|
+
"num_input_views": 6
|
|
42
|
+
},
|
|
43
|
+
"source": {
|
|
44
|
+
"url": "https://github.com/nv-tlabs/TokenGS",
|
|
45
|
+
"paper": "https://arxiv.org/abs/2604.15239"
|
|
46
|
+
},
|
|
47
|
+
"license": "NVIDIA Internal Scientific Research and Development Model License"
|
|
48
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"model_type": "tokengs",
|
|
3
|
+
"description": "TokenGS 2026.6 latent-bottleneck model (12-layer multiscale encoder, 4096 scene latents), DL3DV, 6 input views at 256x448, 0.8 L1 + 0.2 SSIM loss (eval preset eval_dl3dv_latent_6view_ssim)",
|
|
4
|
+
"weights": {
|
|
5
|
+
"repo": "jiaweir/tokengs",
|
|
6
|
+
"file": "checkpoints_26.06/dl3dv_latent_6v_ssim.safetensors",
|
|
7
|
+
"revision": "a7eb20340b99abd29b554c29c339446aebccff36",
|
|
8
|
+
"sha256": "5913da347475049cb58e552634ee1c527293c2571576806db0d4da702ce978c3"
|
|
9
|
+
},
|
|
10
|
+
"model": {
|
|
11
|
+
"enc_depth": 12,
|
|
12
|
+
"dec_depth": 1,
|
|
13
|
+
"dec_patch_size": 8,
|
|
14
|
+
"clip_head_readout_std": 0.002,
|
|
15
|
+
"clip_head_z_init": 0.1,
|
|
16
|
+
"dec_init_values": 0.01,
|
|
17
|
+
"gaussian_z_offset": 0.0,
|
|
18
|
+
"opacity_bias": 2.0,
|
|
19
|
+
"gs_token_std": 0.02,
|
|
20
|
+
"use_multiscale_encoder": true,
|
|
21
|
+
"multiscale_encoder_layers": [
|
|
22
|
+
5,
|
|
23
|
+
7,
|
|
24
|
+
9,
|
|
25
|
+
11
|
|
26
|
+
],
|
|
27
|
+
"use_latent_bottleneck": true,
|
|
28
|
+
"num_latents": 4096,
|
|
29
|
+
"latent_cross_attn_depth": 12,
|
|
30
|
+
"num_gs_tokens": 4096
|
|
31
|
+
},
|
|
32
|
+
"processor": {
|
|
33
|
+
"image_shape": [
|
|
34
|
+
256,
|
|
35
|
+
448
|
|
36
|
+
],
|
|
37
|
+
"resize_mode": "bilinear",
|
|
38
|
+
"crop_mode": "crop",
|
|
39
|
+
"camera_normalization": "mean_cam",
|
|
40
|
+
"scene_scale": 0.15,
|
|
41
|
+
"num_input_views": 6
|
|
42
|
+
},
|
|
43
|
+
"source": {
|
|
44
|
+
"url": "https://github.com/nv-tlabs/TokenGS",
|
|
45
|
+
"paper": "https://arxiv.org/abs/2604.15239"
|
|
46
|
+
},
|
|
47
|
+
"license": "NVIDIA Internal Scientific Research and Development Model License"
|
|
48
|
+
}
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: ffgs
|
|
3
|
+
Version: 0.1.0.dev0
|
|
4
|
+
Summary: Standard inference for feed-forward 3D Gaussian Splatting models
|
|
5
|
+
Project-URL: Repository, https://github.com/libgs/ffgs
|
|
6
|
+
Author: libgs contributors
|
|
7
|
+
License-Expression: Apache-2.0 AND MIT AND CC-BY-NC-4.0 AND CC-BY-NC-SA-4.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
License-File: src/ffgs/models/anysplat/LICENSE
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Requires-Dist: huggingface-hub>=0.23
|
|
14
|
+
Requires-Dist: numpy
|
|
15
|
+
Requires-Dist: pillow
|
|
16
|
+
Requires-Dist: safetensors
|
|
17
|
+
Requires-Dist: torch>=2.2
|
|
18
|
+
Requires-Dist: torchvision>=0.17
|
|
19
|
+
Provides-Extra: render
|
|
20
|
+
Requires-Dist: gsplat; extra == 'render'
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# ffgs — standard inference for feed-forward 3D Gaussian Splatting
|
|
24
|
+
|
|
25
|
+
One way to load and run feed-forward 3D Gaussian Splatting models: posed images in,
|
|
26
|
+
Gaussians out — in the model's own frame, or in **your** world frame with one call —
|
|
27
|
+
whatever model is behind it.
|
|
28
|
+
|
|
29
|
+
> Early development: the core interface, third-party loading and the model zoo
|
|
30
|
+
> are in place; see
|
|
31
|
+
> [the models](https://github.com/libgs/ffgs/blob/main/docs/models/index.md)
|
|
32
|
+
> for those shipped so far.
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from ffgs import Cameras, GSPipeline, Views
|
|
36
|
+
|
|
37
|
+
pipe = GSPipeline.from_pretrained("<family>/<variant>", device="cuda") # or a path / Hub repo
|
|
38
|
+
out = pipe(Views(images, intrinsics, c2w)) # -> GSOutput, in the model's frame
|
|
39
|
+
images = pipe.render(out, Cameras(c2w_new, k_new, (h, w)))["images"] # cameras in your frame
|
|
40
|
+
out.to_world().gaussians.save_ply("scene.ply") # standard 3DGS ply, in the frame of c2w
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Install
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install ffgs # inference
|
|
47
|
+
pip install "ffgs[render]" # + gsplat rasterisation (CUDA)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Dependencies: torch, torchvision, numpy, pillow, huggingface_hub, safetensors;
|
|
51
|
+
gsplat (the `render` extra) is imported only when rendering.
|
|
52
|
+
|
|
53
|
+
## Example
|
|
54
|
+
|
|
55
|
+
[`examples/infer_nerfstudio_scene.py`](https://github.com/libgs/ffgs/blob/main/examples/infer_nerfstudio_scene.py)
|
|
56
|
+
reconstructs a scene in the nerfstudio / DL3DV layout (`transforms.json`, OpenGL
|
|
57
|
+
camera poses) from evenly spaced frames, writes a 3DGS ply in the scene's frame and
|
|
58
|
+
renders the frames between the inputs:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
python examples/infer_nerfstudio_scene.py <scene> --model <family>/<variant> \
|
|
62
|
+
--images-dir <scene>/images_4 --out out
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Models that predict their own cameras also run on images alone. There is no world
|
|
66
|
+
frame then: the Gaussians and the predicted input cameras are both in the model's
|
|
67
|
+
frame, and renders take cameras in that frame (see [Conventions](#conventions)):
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
pipe = GSPipeline.from_pretrained("<family>/<variant>", device="cuda") # a pose-free model
|
|
71
|
+
out = pipe(Views(images)) # no intrinsics, no c2w: out.frame is None
|
|
72
|
+
out.gaussians.save_ply("scene.ply") # in the model's frame
|
|
73
|
+
renders = pipe.render(out, out.cameras)["images"] # the inputs, at the predicted cameras
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
[`examples/infer_pose_free.py`](https://github.com/libgs/ffgs/blob/main/examples/infer_pose_free.py)
|
|
77
|
+
does this for a folder of images: it writes the ply, the predicted cameras
|
|
78
|
+
(`cameras.json`: OpenCV c2w and normalised intrinsics per input image) and the
|
|
79
|
+
inputs re-rendered at them:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
python examples/infer_pose_free.py <image dir> --model <family>/<variant> \
|
|
83
|
+
--num-views 8 --out out
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Models
|
|
87
|
+
|
|
88
|
+
The shipped models, their zoo names, licenses, usage notes and results against
|
|
89
|
+
their official code are in
|
|
90
|
+
[docs/models](https://github.com/libgs/ffgs/blob/main/docs/models/index.md),
|
|
91
|
+
one page per model.
|
|
92
|
+
Check the license of a model before use: some are for non-commercial use only.
|
|
93
|
+
|
|
94
|
+
## Conventions
|
|
95
|
+
|
|
96
|
+
| | |
|
|
97
|
+
|---|---|
|
|
98
|
+
| images | float in [0, 1] (uint8 accepted), `[V, 3, H, W]` or `[B, V, 3, H, W]`, any resolution |
|
|
99
|
+
| c2w | camera-to-world, OpenCV axes (x right, y down, z forward); optional for models that predict their own cameras |
|
|
100
|
+
| intrinsics | pixel K for the image size given, or normalised K with `normalized_intrinsics=True`; optional like c2w |
|
|
101
|
+
| output | `GSOutput`: `Gaussians` (means, scales, wxyz quats, opacities, SH or RGB colours) in the model's frame, that frame (or `None`), and the input cameras the model predicted (or `None`) |
|
|
102
|
+
|
|
103
|
+
A processor reproduces its model's training preprocessing: rescale to cover the
|
|
104
|
+
model's input size, centre crop (normalised principal point kept, as in training),
|
|
105
|
+
cameras relative to the first input view, translations times a model-specific
|
|
106
|
+
`scene_scale`. The model predicts in that normalised frame, and that is where
|
|
107
|
+
`pipe(views)` leaves the Gaussians (`out.space == "model"`), exactly as the
|
|
108
|
+
model's own code produces them.
|
|
109
|
+
|
|
110
|
+
| | Gaussians in |
|
|
111
|
+
|---|---|
|
|
112
|
+
| `out = pipe(views)` | the model's frame (`out.frame`: world → model) |
|
|
113
|
+
| `out.to_world()` | the world frame of the input c2w (fp32) |
|
|
114
|
+
| `out.gaussians.save_ply(path)` | whichever frame `out` is in: `out.to_world().gaussians.save_ply(path)` for a ply that lines up with your cameras |
|
|
115
|
+
| `pipe.render(out, cameras)` | either: `cameras` are always in the world frame of the input c2w, and are taken (with near / far) into the model's frame when needed |
|
|
116
|
+
|
|
117
|
+
`to_world()` is one similarity transform for every model — rotation, uniform scale
|
|
118
|
+
and translation — applied per attribute: means fully, scales by the scale, quats by
|
|
119
|
+
the rotation, view-dependent SH colours of any degree by an exact rotation of their
|
|
120
|
+
coefficients (3DGS / gsplat basis); opacities and RGB / degree-0 colours are
|
|
121
|
+
unchanged. Input c2w whose rotation is not orthonormal or is a reflection (det < 0)
|
|
122
|
+
are rejected.
|
|
123
|
+
|
|
124
|
+
Models that need poses raise a `ValueError` naming what is missing.
|
|
125
|
+
Models that predict their own cameras accept `Views(images)` alone, and
|
|
126
|
+
`out.cameras` holds their prediction for the input views, in the same frame as
|
|
127
|
+
`out.gaussians` (`to_world()` moves both):
|
|
128
|
+
|
|
129
|
+
| views | `out.frame` | `to_world()` | `pipe.render(out, cameras)` |
|
|
130
|
+
|---|---|---|---|
|
|
131
|
+
| without c2w | `None`: there is no world frame | raises | `cameras` in the model's frame, e.g. `out.cameras`; near / far in model units |
|
|
132
|
+
| with c2w (V ≥ 2) | fitted to the given c2w | as above | as above: `cameras` in the world frame of the input c2w |
|
|
133
|
+
|
|
134
|
+
With c2w, the frame is one closed-form fit over all input views of the predicted
|
|
135
|
+
cameras onto the given ones: the rotation is the mean of the per-view rotations
|
|
136
|
+
(SVD, det +1), then scale and translation are the least-squares fit of the camera
|
|
137
|
+
centres. The given c2w do not enter the model. `out.frame.residuals` reports how
|
|
138
|
+
well they agree, per view: rotation error in degrees, centre error in world
|
|
139
|
+
units, and centre error relative to the RMS spread of the given centres. Fewer
|
|
140
|
+
than 2 views, coincident predicted centres or a fit with negative scale raise.
|
|
141
|
+
|
|
142
|
+
Resize + crop is the default, not a requirement. Processor options (in
|
|
143
|
+
`processor_config.json` or `processor_overrides=`):
|
|
144
|
+
|
|
145
|
+
| option | |
|
|
146
|
+
|---|---|
|
|
147
|
+
| `crop_mode="crop"` | cover the input shape, centre crop — the training rule (default) |
|
|
148
|
+
| `crop_mode="pad"` | fit inside the input shape and pad with `pad_value`; nothing is cut off, K follows the content |
|
|
149
|
+
| `crop_mode="none"` | inputs are already at the model's shape; used as they are |
|
|
150
|
+
| `resize_mode` | built-in kernel: `"bilinear"` (antialiased) or `"lanczos"`; a model's processor may add its own (see its page) |
|
|
151
|
+
| `resize=fn` | your own `fn(images, (h, w)) -> images`, replacing `resize_mode` (not serialised) |
|
|
152
|
+
|
|
153
|
+
```python
|
|
154
|
+
pipe = GSPipeline.from_pretrained(path, processor_overrides={"crop_mode": "pad"})
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Layers
|
|
158
|
+
|
|
159
|
+
| | |
|
|
160
|
+
|---|---|
|
|
161
|
+
| `types` | `Views`, `Cameras`, `Gaussians` (+ `save_ply`) |
|
|
162
|
+
| `processor` | per-model pre / post-processing, stored as `processor_config.json` |
|
|
163
|
+
| model | the model's own `nn.Module` with `PyTorchModelHubMixin` (`config.json` + safetensors) |
|
|
164
|
+
| `pipeline` | `GSPipeline`: `from_pretrained` dispatches on `config.json:model_type` |
|
|
165
|
+
| `render` | gsplat rasterisation of `Gaussians` at `Cameras` (gsplat imported on first use) |
|
|
166
|
+
| `zoo` | named checkpoints: `zoo/<family>/<variant>.json` pointers to pinned upstream weights |
|
|
167
|
+
|
|
168
|
+
A saved model is a directory (or Hub repo) with `config.json` (model config +
|
|
169
|
+
`model_type`), `model.safetensors` and `processor_config.json`;
|
|
170
|
+
`GSPipeline.save_pretrained` writes all three.
|
|
171
|
+
|
|
172
|
+
## Model zoo
|
|
173
|
+
|
|
174
|
+
The zoo names published checkpoints: one JSON file per variant in
|
|
175
|
+
`src/ffgs/zoo/<family>/<variant>.json`, shipped with the package. The weights stay
|
|
176
|
+
in their authors' Hub repos; an entry pins the file to a commit and a sha256.
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from ffgs import GSPipeline, zoo
|
|
180
|
+
|
|
181
|
+
zoo.list_models() # ["<family>/<variant>", ...]
|
|
182
|
+
pipe = GSPipeline.from_pretrained("<family>/<variant>", device="cuda")
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
```json
|
|
186
|
+
{
|
|
187
|
+
"model_type": "my-model",
|
|
188
|
+
"description": "My model trained on X, 2 input views",
|
|
189
|
+
"weights": {"repo": "author/repo", "file": "ckpt/model.pt",
|
|
190
|
+
"revision": "<full 40-hex commit>", "sha256": "<64-hex>"},
|
|
191
|
+
"model": {"...": "model constructor arguments"},
|
|
192
|
+
"processor": {"...": "processor_config.json"},
|
|
193
|
+
"source": {"url": "https://github.com/author/code", "paper": "https://..."},
|
|
194
|
+
"license": "license of the weights"
|
|
195
|
+
}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Loading an entry downloads the file at the pinned commit, fails if its sha256
|
|
199
|
+
differs, converts the upstream checkpoint with the model's
|
|
200
|
+
`ModelSpec.convert_state_dict` (e.g. stripping a key prefix) and loads it strictly:
|
|
201
|
+
every key must match. `.pt` checkpoints are unpickled with `weights_only=True`.
|
|
202
|
+
`save_pretrained` then writes an ordinary ffgs directory.
|
|
203
|
+
|
|
204
|
+
`from_pretrained(name)` tries, in order: an existing local directory, a zoo entry,
|
|
205
|
+
a Hub repo id. A zoo family name is reserved — `"<family>/<anything>"` never goes
|
|
206
|
+
to the Hub, and an unknown variant is an error listing the known ones. (To load a
|
|
207
|
+
Hub repo whose owner shares a family name, `huggingface_hub.snapshot_download` it
|
|
208
|
+
and pass the directory.) A zoo entry pins its own revision, so `revision=` and
|
|
209
|
+
`subfolder=` are rejected for it; `cache_dir`, `token`, `force_download` and
|
|
210
|
+
`local_files_only` apply.
|
|
211
|
+
|
|
212
|
+
Checkpoints saved with `save_pretrained` can also be published as Hub repos, one
|
|
213
|
+
per model family with variants in subfolders:
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
pipe = GSPipeline.from_pretrained("owner/family-repo", subfolder="variant",
|
|
217
|
+
revision="<commit sha>")
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Adding a model
|
|
221
|
+
|
|
222
|
+
A model is a model class with `PyTorchModelHubMixin`, a `Processor` subclass
|
|
223
|
+
(`preprocess`, returning the model input and its `ModelFrame`, or `None` when the
|
|
224
|
+
model predicts its own cameras; `postprocess`, to model-frame `Gaussians`;
|
|
225
|
+
`render_planes`, near / far in world units, or in model units when the frame is
|
|
226
|
+
`None`; for models that predict cameras, `predicted_cameras`, from the model output
|
|
227
|
+
to model-frame `Cameras`, and `output_frame`, whose default fits the frame to the
|
|
228
|
+
given c2w as above; optionally `background` and `render_settings`, the model's
|
|
229
|
+
rasteriser settings such as `radius_clip`, `rasterize_mode` or `clamp`, which
|
|
230
|
+
`pipe.render` uses unless the caller passes them) and a
|
|
231
|
+
`ModelSpec(model_type, model_cls, processor_cls)`. `from_pretrained` resolves the
|
|
232
|
+
`model_type` in `config.json` in this order:
|
|
233
|
+
|
|
234
|
+
1. **In your code** — `ffgs.register_model(spec)` before loading (built-in models
|
|
235
|
+
are registered the same way, on first use).
|
|
236
|
+
2. **An installed package** — expose the spec under the `ffgs.models` entry point
|
|
237
|
+
group, named by its `model_type`; ffgs imports the package only when that
|
|
238
|
+
`model_type` is loaded:
|
|
239
|
+
|
|
240
|
+
```toml
|
|
241
|
+
# pyproject.toml of your package
|
|
242
|
+
[project.entry-points."ffgs.models"]
|
|
243
|
+
my-model = "my_package.ffgs_model:SPEC" # a ModelSpec with model_type "my-model"
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
3. **Code in the model repo** — ship the `.py` files next to `config.json` and name
|
|
247
|
+
the classes (relative imports between the files work):
|
|
248
|
+
|
|
249
|
+
```json
|
|
250
|
+
{"model_type": "my-model",
|
|
251
|
+
"auto_map": {"model": "modeling_my.MyModel", "processor": "processing_my.MyProcessor"}}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
That code runs only with `trust_remote_code=True` (off by default); read it
|
|
255
|
+
first and pin the revision:
|
|
256
|
+
|
|
257
|
+
```python
|
|
258
|
+
pipe = GSPipeline.from_pretrained("someone/my-model", trust_remote_code=True,
|
|
259
|
+
revision="<commit sha>")
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
`save_pretrained` on such a pipeline copies the code and keeps `auto_map`.
|
|
263
|
+
To publish a model whose code lives in your own (e.g. training) codebase, keep
|
|
264
|
+
the model and processor classes in one package that imports itself only
|
|
265
|
+
relatively, and export it with the weights:
|
|
266
|
+
|
|
267
|
+
```python
|
|
268
|
+
GSPipeline(model, processor, model_type="my-model").save_pretrained(
|
|
269
|
+
"export/my-model", include_code=True) # copies the package, writes auto_map
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Imports of the rest of your codebase are refused at export time, so the
|
|
273
|
+
directory loads with `trust_remote_code=True` where your codebase is not
|
|
274
|
+
installed.
|
|
275
|
+
|
|
276
|
+
An installed model wins over repo code with the same `model_type`. Hub options
|
|
277
|
+
(`revision`, `subfolder`, `cache_dir`, `token`, `force_download`,
|
|
278
|
+
`local_files_only`) apply to every file `from_pretrained` downloads.
|
|
279
|
+
|
|
280
|
+
To add a zoo entry for a model, write its JSON (compute the sha256 of the pinned
|
|
281
|
+
file), give the model's `ModelSpec` a `convert_state_dict` if the upstream keys
|
|
282
|
+
differ from the model's, and run the tests: every shipped entry is checked to
|
|
283
|
+
parse and build offline, and `uv run pytest --network` downloads each one and
|
|
284
|
+
loads it strictly.
|
|
285
|
+
|
|
286
|
+
Document a new model in `docs/models/<family>.md` (source, licenses of code and
|
|
287
|
+
weights, zoo entries, usage notes, results against the official code; the existing
|
|
288
|
+
pages are the template) and add its row to
|
|
289
|
+
[`docs/models/index.md`](https://github.com/libgs/ffgs/blob/main/docs/models/index.md).
|
|
290
|
+
|
|
291
|
+
## Development
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
uv sync
|
|
295
|
+
uv run pytest # everything; tests marked `gpu` skip without CUDA + gsplat
|
|
296
|
+
uv run pytest -m gpu # only the GPU tests (needs CUDA and `--extra render`)
|
|
297
|
+
uv run pytest --network # also the tests that download zoo weights from the Hub
|
|
298
|
+
uv run pre-commit install
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
`uv sync` installs torch from PyPI (CUDA build). CI has no GPU and installs CPU
|
|
302
|
+
torch first (see `.github/workflows/ci.yml`). `tests/fixtures/reference.safetensors`
|
|
303
|
+
holds frozen reference outputs of the default data path; change it only together
|
|
304
|
+
with a deliberate change to that path.
|
|
305
|
+
|
|
306
|
+
## License
|
|
307
|
+
|
|
308
|
+
**The ffgs package as distributed is not entirely Apache-2.0: it includes code for
|
|
309
|
+
non-commercial use only.** Its license expression is
|
|
310
|
+
`Apache-2.0 AND MIT AND CC-BY-NC-4.0 AND CC-BY-NC-SA-4.0`:
|
|
311
|
+
|
|
312
|
+
- the core library is Apache-2.0 (see `LICENSE`); `src/ffgs/image.py` is adapted
|
|
313
|
+
from pixelSplat (MIT), whose license is included at the end of `LICENSE`;
|
|
314
|
+
- vendored model code under `src/ffgs/models/<family>/` keeps its upstream license.
|
|
315
|
+
`src/ffgs/models/anysplat/` mixes MIT, Apache-2.0 and non-commercial
|
|
316
|
+
(CC-BY-NC-4.0, CC-BY-NC-SA-4.0) files; its `LICENSE` lists the license per file;
|
|
317
|
+
- model weights are not part of the package and carry their own licenses.
|
|
318
|
+
|
|
319
|
+
The code and weight licenses of each model are listed in
|
|
320
|
+
[docs/models](https://github.com/libgs/ffgs/blob/main/docs/models/index.md).
|