XCalib 0.1.0__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.
Files changed (68) hide show
  1. xcalib/__init__.py +75 -0
  2. xcalib/cfg/calibrefine_a9_dataset_r02_s01.yaml +10 -0
  3. xcalib/cfg/calibrefine_utc3.yaml +10 -0
  4. xcalib/cfg/calibrefine_utc4.yaml +10 -0
  5. xcalib/cfg/crlite_2dpe_a9_dataset_r02_s01.yaml +13 -0
  6. xcalib/cfg/crlite_2dpe_utc3.yaml +13 -0
  7. xcalib/cfg/crlite_2dpe_utc4.yaml +13 -0
  8. xcalib/cfg/crlite_a9_dataset_r02_s01.yaml +13 -0
  9. xcalib/cfg/crlite_utc3.yaml +13 -0
  10. xcalib/cfg/crlite_utc4.yaml +13 -0
  11. xcalib/cfg/crlite_vit_exp1_a9_dataset_r02_s01.yaml +19 -0
  12. xcalib/cfg/crlite_vit_exp1_utc3.yaml +19 -0
  13. xcalib/cfg/crlite_vit_exp1_utc4.yaml +19 -0
  14. xcalib/cfg/crlite_vit_exp3_a9_dataset_r02_s01.yaml +21 -0
  15. xcalib/cfg/crlite_vit_exp3_utc3.yaml +21 -0
  16. xcalib/cfg/crlite_vit_exp3_utc4.yaml +21 -0
  17. xcalib/cfg/crlite_vit_exp4_utc3.yaml +32 -0
  18. xcalib/cfg/crlite_vit_exp4_utc4.yaml +32 -0
  19. xcalib/cli.py +303 -0
  20. xcalib/data/__init__.py +42 -0
  21. xcalib/data/crops.py +247 -0
  22. xcalib/data/hdf5_loader.py +192 -0
  23. xcalib/engine/__init__.py +4 -0
  24. xcalib/engine/exporter.py +516 -0
  25. xcalib/engine/matcher.py +562 -0
  26. xcalib/engine/trainer.py +507 -0
  27. xcalib/engine/trt.py +328 -0
  28. xcalib/engine/wrappers.py +310 -0
  29. xcalib/hub/__init__.py +53 -0
  30. xcalib/hub/datasets.py +171 -0
  31. xcalib/hub/weights.py +174 -0
  32. xcalib/models/__init__.py +17 -0
  33. xcalib/models/_base.py +74 -0
  34. xcalib/models/backbones/__init__.py +20 -0
  35. xcalib/models/backbones/_pointnet2_ops.py +166 -0
  36. xcalib/models/backbones/pointnet.py +69 -0
  37. xcalib/models/backbones/pointnet2.py +119 -0
  38. xcalib/models/backbones/resnet_bottleneck.py +122 -0
  39. xcalib/models/backbones/resnet_deep.py +61 -0
  40. xcalib/models/backbones/vit_crop.py +110 -0
  41. xcalib/models/calibrefine.py +152 -0
  42. xcalib/models/crlite.py +323 -0
  43. xcalib/models/crlite_2dpe.py +23 -0
  44. xcalib/models/crlite_vit_exp1.py +145 -0
  45. xcalib/models/crlite_vit_exp3.py +195 -0
  46. xcalib/models/crlite_vit_exp4.py +274 -0
  47. xcalib/models/gnn.py +405 -0
  48. xcalib/models/position_encoding.py +157 -0
  49. xcalib/models/registry.py +52 -0
  50. xcalib/oneshot/__init__.py +49 -0
  51. xcalib/oneshot/adapter.py +239 -0
  52. xcalib/oneshot/calibration.py +319 -0
  53. xcalib/oneshot/memory.py +166 -0
  54. xcalib/oneshot/pseudo_labels.py +151 -0
  55. xcalib/oneshot/session.py +443 -0
  56. xcalib/protocol.py +353 -0
  57. xcalib/py.typed +0 -0
  58. xcalib/utils/__init__.py +4 -0
  59. xcalib/utils/config.py +72 -0
  60. xcalib/utils/io.py +97 -0
  61. xcalib/utils/metrics.py +161 -0
  62. xcalib/utils/torch_check.py +89 -0
  63. xcalib/visualization.py +285 -0
  64. xcalib-0.1.0.dist-info/METADATA +331 -0
  65. xcalib-0.1.0.dist-info/RECORD +68 -0
  66. xcalib-0.1.0.dist-info/WHEEL +4 -0
  67. xcalib-0.1.0.dist-info/entry_points.txt +2 -0
  68. xcalib-0.1.0.dist-info/licenses/LICENSE +201 -0
xcalib/__init__.py ADDED
@@ -0,0 +1,75 @@
1
+ """xcalib — camera-LiDAR cross-modal matching, calibration, and adaptation.
2
+
3
+ Public API (everything else is internal and may change without notice):
4
+
5
+ from xcalib import Matcher
6
+
7
+ matcher = Matcher.from_pretrained("crlite", site="a9_dataset_r02_s01")
8
+ result = matcher.pair(image, point_cloud, bboxes_2d, bboxes_3d)
9
+ calib = matcher.calibrate(image, point_cloud, bboxes_2d, bboxes_3d,
10
+ intrinsics=K)
11
+ matcher.build("onnx", output_dir="onnx/crlite_a9")
12
+
13
+ `Matcher` covers pairing/matching, targetless calibration, one-shot
14
+ adaptation, ONNX/TensorRT export, fine-tuning (`.train()`), and pretrained
15
+ weight loading. The module-level `train` / `load_dataset` helpers cover HDF5
16
+ training and public A9 dataset loading; the protocol types document and
17
+ enforce the input contract.
18
+ """
19
+
20
+ # Verify torch is importable before any sub-module pulls it in, so the
21
+ # partner sees a Jetson-specific install hint instead of a bare
22
+ # ModuleNotFoundError. No-op when torch is already installed.
23
+ from .utils.torch_check import ensure_torch as _ensure_torch
24
+ _ensure_torch()
25
+
26
+ from .engine.exporter import BuildResult
27
+ from .engine.matcher import Matcher, MatchResult
28
+ from .oneshot.calibration import CalibrationResult
29
+ from .protocol import (
30
+ PROTOCOL_VERSION,
31
+ CameraIntrinsics,
32
+ ProtocolError,
33
+ ProtocolViolation,
34
+ validate_frame_inputs,
35
+ )
36
+ from .visualization import draw_calibration_overlay, draw_matching_overlay
37
+
38
+ __version__ = "0.1.0"
39
+
40
+ __all__ = [
41
+ "__version__",
42
+ # Core entry point
43
+ "Matcher",
44
+ # Lab-side helpers (lazy: keep optional deps out of the base import)
45
+ "train",
46
+ "load_dataset",
47
+ # Result dataclasses
48
+ "MatchResult",
49
+ "BuildResult",
50
+ "CalibrationResult",
51
+ # Input protocol (partner-facing contract)
52
+ "PROTOCOL_VERSION",
53
+ "CameraIntrinsics",
54
+ "ProtocolError",
55
+ "ProtocolViolation",
56
+ "validate_frame_inputs",
57
+ # Visualization helpers
58
+ "draw_matching_overlay",
59
+ "draw_calibration_overlay",
60
+ ]
61
+
62
+
63
+ def __getattr__(name: str):
64
+ # PEP 562 lazy exports: `train` pulls h5py (the [train] extra) and
65
+ # `load_dataset` pulls huggingface_hub network helpers — neither should
66
+ # tax `import xcalib` for inference-only users.
67
+ if name == "train":
68
+ from .engine.trainer import train
69
+
70
+ return train
71
+ if name == "load_dataset":
72
+ from .hub.datasets import load_dataset
73
+
74
+ return load_dataset
75
+ raise AttributeError(f"module 'xcalib' has no attribute {name!r}")
@@ -0,0 +1,10 @@
1
+ # CalibRefine (Pairwise baseline: Bottleneck ResNet + PointNet2 + 2D PE) — A9 r02_s01.
2
+ model: calibrefine
3
+ device: auto
4
+ num_classes: 10
5
+ crop_size: 32
6
+ point_cloud_size: 1024
7
+ token_len: 256
8
+ num_blocks: [2, 2, 2, 2]
9
+ bbox_expansion: 1.25
10
+ weights_path: checkpoints/calibrefine_a9_dataset_r02_s01_best.pth
@@ -0,0 +1,10 @@
1
+ # CalibRefine (Pairwise baseline: Bottleneck ResNet + PointNet2 + 2D PE) — UTC3.
2
+ model: calibrefine
3
+ device: auto
4
+ num_classes: 10
5
+ crop_size: 32
6
+ point_cloud_size: 1024
7
+ token_len: 256
8
+ num_blocks: [2, 2, 2, 2]
9
+ bbox_expansion: 1.05
10
+ weights_path: checkpoints/calibrefine_utc3_best.pth
@@ -0,0 +1,10 @@
1
+ # CalibRefine (Pairwise baseline: Bottleneck ResNet + PointNet2 + 2D PE) — UTC4.
2
+ model: calibrefine
3
+ device: auto
4
+ num_classes: 10
5
+ crop_size: 32
6
+ point_cloud_size: 1024
7
+ token_len: 256
8
+ num_blocks: [2, 2, 2, 2]
9
+ bbox_expansion: 1.05
10
+ weights_path: checkpoints/calibrefine_utc4_best.pth
@@ -0,0 +1,13 @@
1
+ # CRLite-2DPE (ResNet + only 2D sinusoidal PE branch, R1 #6 ablation) — A9 r02_s01.
2
+ model: crlite_2dpe
3
+ device: auto
4
+ num_classes: 10
5
+ crop_size: 32
6
+ point_cloud_size: 1024
7
+ embed_dim: 256
8
+ token_len: 256
9
+ top_k: 10
10
+ max_depth: 100.0
11
+ pe_mode: 2d_only # forced by CRLite2DPEModel; left here for visibility
12
+ bbox_expansion: 1.25
13
+ weights_path: checkpoints/crlite_2dpe_a9_dataset_r02_s01_best.pth
@@ -0,0 +1,13 @@
1
+ # CRLite-2DPE (ResNet + only 2D sinusoidal PE branch, R1 #6 ablation) — UTC3.
2
+ model: crlite_2dpe
3
+ device: auto
4
+ num_classes: 10
5
+ crop_size: 32
6
+ point_cloud_size: 1024
7
+ embed_dim: 256
8
+ token_len: 256
9
+ top_k: 10
10
+ max_depth: 100.0
11
+ pe_mode: 2d_only
12
+ bbox_expansion: 1.05
13
+ weights_path: checkpoints/crlite_2dpe_utc3_best.pth
@@ -0,0 +1,13 @@
1
+ # CRLite-2DPE (ResNet + only 2D sinusoidal PE branch, R1 #6 ablation) — UTC4.
2
+ model: crlite_2dpe
3
+ device: auto
4
+ num_classes: 10
5
+ crop_size: 32
6
+ point_cloud_size: 1024
7
+ embed_dim: 256
8
+ token_len: 256
9
+ top_k: 10
10
+ max_depth: 100.0
11
+ pe_mode: 2d_only # forced by CRLite2DPEModel; left here for visibility
12
+ bbox_expansion: 1.05
13
+ weights_path: checkpoints/crlite_2dpe_utc4_best.pth
@@ -0,0 +1,13 @@
1
+ # CRLite (Hybrid two-stage + Enhanced 3D PE) — A9 r02_s01 weights.
2
+ model: crlite
3
+ device: auto
4
+ num_classes: 10
5
+ crop_size: 32
6
+ point_cloud_size: 1024
7
+ embed_dim: 256
8
+ token_len: 256
9
+ top_k: 10
10
+ max_depth: 100.0
11
+ pe_mode: full
12
+ bbox_expansion: 1.25
13
+ weights_path: checkpoints/crlite_a9_dataset_r02_s01_best.pth
@@ -0,0 +1,13 @@
1
+ # CRLite (Hybrid two-stage + Enhanced 3D PE) — UTC3 weights.
2
+ model: crlite
3
+ device: auto
4
+ num_classes: 10
5
+ crop_size: 32
6
+ point_cloud_size: 1024
7
+ embed_dim: 256
8
+ token_len: 256
9
+ top_k: 10
10
+ max_depth: 100.0
11
+ pe_mode: full
12
+ bbox_expansion: 1.05
13
+ weights_path: checkpoints/crlite_utc3_best.pth
@@ -0,0 +1,13 @@
1
+ # CRLite (Hybrid two-stage + Enhanced 3D PE) — UTC4 weights.
2
+ model: crlite
3
+ device: auto
4
+ num_classes: 10
5
+ crop_size: 32
6
+ point_cloud_size: 1024
7
+ embed_dim: 256
8
+ token_len: 256
9
+ top_k: 10
10
+ max_depth: 100.0
11
+ pe_mode: full
12
+ bbox_expansion: 1.05
13
+ weights_path: checkpoints/crlite_utc4_best.pth
@@ -0,0 +1,19 @@
1
+ # CRLite-ViT Exp1 (Crop ViT + PointNet, no PE) — A9 r02_s01.
2
+ model: crlite_vit_exp1
3
+ device: auto
4
+ num_classes: 10
5
+ crop_size: 64
6
+ point_cloud_size: 1024
7
+ embed_dim: 256
8
+ top_k: 10
9
+ vit:
10
+ patch_size: 8
11
+ embed_dim: 256
12
+ depth: 6
13
+ num_heads: 8
14
+ mlp_ratio: 4.0
15
+ dropout: 0.0
16
+ attention_dropout: 0.0
17
+ pool: cls
18
+ bbox_expansion: 1.25
19
+ weights_path: checkpoints/crlite_vit_exp1_a9_dataset_r02_s01_best.pth
@@ -0,0 +1,19 @@
1
+ # CRLite-ViT Exp1 (Crop ViT + PointNet, no PE) — UTC3.
2
+ model: crlite_vit_exp1
3
+ device: auto
4
+ num_classes: 10
5
+ crop_size: 64
6
+ point_cloud_size: 1024
7
+ embed_dim: 256
8
+ top_k: 10
9
+ vit:
10
+ patch_size: 8
11
+ embed_dim: 256
12
+ depth: 6
13
+ num_heads: 8
14
+ mlp_ratio: 4.0
15
+ dropout: 0.0
16
+ attention_dropout: 0.0
17
+ pool: cls
18
+ bbox_expansion: 1.05
19
+ weights_path: checkpoints/crlite_vit_exp1_utc3_best.pth
@@ -0,0 +1,19 @@
1
+ # CRLite-ViT Exp1 (Crop ViT + PointNet, no PE) — UTC4.
2
+ model: crlite_vit_exp1
3
+ device: auto
4
+ num_classes: 10
5
+ crop_size: 64
6
+ point_cloud_size: 1024
7
+ embed_dim: 256
8
+ top_k: 10
9
+ vit:
10
+ patch_size: 8
11
+ embed_dim: 256
12
+ depth: 6
13
+ num_heads: 8
14
+ mlp_ratio: 4.0
15
+ dropout: 0.0
16
+ attention_dropout: 0.0
17
+ pool: cls
18
+ bbox_expansion: 1.05
19
+ weights_path: checkpoints/crlite_vit_exp1_utc4_best.pth
@@ -0,0 +1,21 @@
1
+ # CRLite-ViT Exp3 (Crop ViT + PointNet + Enhanced 3D PE) — A9 r02_s01.
2
+ model: crlite_vit_exp3
3
+ device: auto
4
+ num_classes: 10
5
+ crop_size: 64
6
+ point_cloud_size: 1024
7
+ embed_dim: 256
8
+ token_len: 256
9
+ max_depth: 100.0
10
+ top_k: 10
11
+ vit:
12
+ patch_size: 8
13
+ embed_dim: 256
14
+ depth: 6
15
+ num_heads: 8
16
+ mlp_ratio: 4.0
17
+ dropout: 0.0
18
+ attention_dropout: 0.0
19
+ pool: cls
20
+ bbox_expansion: 1.25
21
+ weights_path: checkpoints/crlite_vit_exp3_a9_dataset_r02_s01_best.pth
@@ -0,0 +1,21 @@
1
+ # CRLite-ViT Exp3 (Crop ViT + PointNet + Enhanced 3D PE) — UTC3.
2
+ model: crlite_vit_exp3
3
+ device: auto
4
+ num_classes: 10
5
+ crop_size: 64
6
+ point_cloud_size: 1024
7
+ embed_dim: 256
8
+ token_len: 256
9
+ max_depth: 100.0
10
+ top_k: 10
11
+ vit:
12
+ patch_size: 8
13
+ embed_dim: 256
14
+ depth: 6
15
+ num_heads: 8
16
+ mlp_ratio: 4.0
17
+ dropout: 0.0
18
+ attention_dropout: 0.0
19
+ pool: cls
20
+ bbox_expansion: 1.05
21
+ weights_path: checkpoints/crlite_vit_exp3_utc3_best.pth
@@ -0,0 +1,21 @@
1
+ # CRLite-ViT Exp3 (Crop ViT + PointNet + Enhanced 3D PE) — UTC4.
2
+ model: crlite_vit_exp3
3
+ device: auto
4
+ num_classes: 10
5
+ crop_size: 64
6
+ point_cloud_size: 1024
7
+ embed_dim: 256
8
+ token_len: 256
9
+ max_depth: 100.0
10
+ top_k: 10
11
+ vit:
12
+ patch_size: 8
13
+ embed_dim: 256
14
+ depth: 6
15
+ num_heads: 8
16
+ mlp_ratio: 4.0
17
+ dropout: 0.0
18
+ attention_dropout: 0.0
19
+ pool: cls
20
+ bbox_expansion: 1.05
21
+ weights_path: checkpoints/crlite_vit_exp3_utc4_best.pth
@@ -0,0 +1,32 @@
1
+ # CRLite-ViT Exp4 (ViT + Structure-Aware GNN), UTC3 weights.
2
+ #
3
+ # Replaces absolute position encoding with two relational GNNs (camera-side
4
+ # over 2D bboxes, LiDAR-side over 3D centers). State-dict keys match the
5
+ # trained checkpoint exactly.
6
+ model: crlite_vit_exp4
7
+ device: auto
8
+ crop_size: 64
9
+ point_cloud_size: 1024
10
+ embed_dim: 256
11
+ top_k: 10
12
+ image_width: 1920
13
+ image_height: 1080
14
+
15
+ vit:
16
+ patch_size: 8
17
+ embed_dim: 256
18
+ depth: 6
19
+ num_heads: 8
20
+ mlp_ratio: 4.0
21
+ dropout: 0.0
22
+ attention_dropout: 0.0
23
+ pool: cls
24
+
25
+ gnn:
26
+ edge_dim: 8
27
+ hidden_dim: 128
28
+ num_layers: 2
29
+ k_neighbors: 4
30
+ dropout: 0.1
31
+
32
+ weights_path: checkpoints/crlite_vit_exp4_utc3_best.pth
@@ -0,0 +1,32 @@
1
+ # CRLite-ViT Exp4 (ViT + Structure-Aware GNN), UTC4 weights.
2
+ #
3
+ # Replaces absolute position encoding with two relational GNNs (camera-side
4
+ # over 2D bboxes, LiDAR-side over 3D centers). State-dict keys match the
5
+ # trained checkpoint exactly.
6
+ model: crlite_vit_exp4
7
+ device: auto
8
+ crop_size: 64
9
+ point_cloud_size: 1024
10
+ embed_dim: 256
11
+ top_k: 10
12
+ image_width: 1920
13
+ image_height: 1080
14
+
15
+ vit:
16
+ patch_size: 8
17
+ embed_dim: 256
18
+ depth: 6
19
+ num_heads: 8
20
+ mlp_ratio: 4.0
21
+ dropout: 0.0
22
+ attention_dropout: 0.0
23
+ pool: cls
24
+
25
+ gnn:
26
+ edge_dim: 8
27
+ hidden_dim: 128
28
+ num_layers: 2
29
+ k_neighbors: 4
30
+ dropout: 0.1
31
+
32
+ weights_path: checkpoints/crlite_vit_exp4_utc4_best.pth