vision3d 0.1.0__tar.gz

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 (78) hide show
  1. vision3d-0.1.0/LICENSE +29 -0
  2. vision3d-0.1.0/MANIFEST.in +2 -0
  3. vision3d-0.1.0/PKG-INFO +20 -0
  4. vision3d-0.1.0/README.md +0 -0
  5. vision3d-0.1.0/pyproject.toml +82 -0
  6. vision3d-0.1.0/setup.cfg +4 -0
  7. vision3d-0.1.0/setup.py +83 -0
  8. vision3d-0.1.0/src/vision3d/__init__.py +0 -0
  9. vision3d-0.1.0/src/vision3d/_extension.py +30 -0
  10. vision3d-0.1.0/src/vision3d/datasets/__init__.py +21 -0
  11. vision3d-0.1.0/src/vision3d/datasets/_types.py +73 -0
  12. vision3d-0.1.0/src/vision3d/datasets/collate.py +22 -0
  13. vision3d-0.1.0/src/vision3d/datasets/kitti.py +381 -0
  14. vision3d-0.1.0/src/vision3d/datasets/nuscenes.py +324 -0
  15. vision3d-0.1.0/src/vision3d/metrics/__init__.py +14 -0
  16. vision3d-0.1.0/src/vision3d/metrics/_mean_average_precision_3d.py +402 -0
  17. vision3d-0.1.0/src/vision3d/metrics/_types.py +34 -0
  18. vision3d-0.1.0/src/vision3d/ops/__init__.py +19 -0
  19. vision3d-0.1.0/src/vision3d/ops/_box3d_convert.py +26 -0
  20. vision3d-0.1.0/src/vision3d/ops/_box3d_corners.py +64 -0
  21. vision3d-0.1.0/src/vision3d/ops/_box3d_iou.py +46 -0
  22. vision3d-0.1.0/src/vision3d/ops/_box3d_overlap.py +85 -0
  23. vision3d-0.1.0/src/vision3d/ops/_meta_registrations.py +23 -0
  24. vision3d-0.1.0/src/vision3d/ops/_nms_3d.py +85 -0
  25. vision3d-0.1.0/src/vision3d/ops/_points_in_boxes_3d.py +173 -0
  26. vision3d-0.1.0/src/vision3d/ops/_project.py +46 -0
  27. vision3d-0.1.0/src/vision3d/ops/boxes3d.py +47 -0
  28. vision3d-0.1.0/src/vision3d/ops/csrc/iou_box3d/iou_box3d.cu +181 -0
  29. vision3d-0.1.0/src/vision3d/ops/csrc/iou_box3d/iou_box3d.h +50 -0
  30. vision3d-0.1.0/src/vision3d/ops/csrc/iou_box3d/iou_box3d_cpu.cpp +124 -0
  31. vision3d-0.1.0/src/vision3d/ops/csrc/iou_box3d/iou_utils.cuh +736 -0
  32. vision3d-0.1.0/src/vision3d/ops/csrc/iou_box3d/iou_utils.h +737 -0
  33. vision3d-0.1.0/src/vision3d/ops/csrc/iou_box3d.cpp +29 -0
  34. vision3d-0.1.0/src/vision3d/ops/csrc/utils/float_math.cuh +160 -0
  35. vision3d-0.1.0/src/vision3d/ops/csrc/utils/pytorch3d_cutils.h +21 -0
  36. vision3d-0.1.0/src/vision3d/ops/csrc/utils/vec3.h +74 -0
  37. vision3d-0.1.0/src/vision3d/py.typed +0 -0
  38. vision3d-0.1.0/src/vision3d/tensors/__init__.py +17 -0
  39. vision3d-0.1.0/src/vision3d/tensors/_bounding_boxes_3d.py +154 -0
  40. vision3d-0.1.0/src/vision3d/tensors/_camera.py +284 -0
  41. vision3d-0.1.0/src/vision3d/tensors/_point_cloud_3d.py +60 -0
  42. vision3d-0.1.0/src/vision3d/tensors/_wrap.py +36 -0
  43. vision3d-0.1.0/src/vision3d/transforms/__init__.py +19 -0
  44. vision3d-0.1.0/src/vision3d/transforms/_copy_paste_3d.py +810 -0
  45. vision3d-0.1.0/src/vision3d/transforms/_geometry.py +188 -0
  46. vision3d-0.1.0/src/vision3d/transforms/_point_cloud.py +113 -0
  47. vision3d-0.1.0/src/vision3d/transforms/_range_filter.py +102 -0
  48. vision3d-0.1.0/src/vision3d/transforms/_transform.py +122 -0
  49. vision3d-0.1.0/src/vision3d/transforms/functional/__init__.py +51 -0
  50. vision3d-0.1.0/src/vision3d/transforms/functional/_geometry.py +487 -0
  51. vision3d-0.1.0/src/vision3d/transforms/functional/_point_cloud.py +92 -0
  52. vision3d-0.1.0/src/vision3d/transforms/functional/_registry.py +84 -0
  53. vision3d-0.1.0/src/vision3d/viz/__init__.py +15 -0
  54. vision3d-0.1.0/src/vision3d/viz/_logging.py +274 -0
  55. vision3d-0.1.0/src/vision3d.egg-info/PKG-INFO +20 -0
  56. vision3d-0.1.0/src/vision3d.egg-info/SOURCES.txt +76 -0
  57. vision3d-0.1.0/src/vision3d.egg-info/dependency_links.txt +1 -0
  58. vision3d-0.1.0/src/vision3d.egg-info/requires.txt +11 -0
  59. vision3d-0.1.0/src/vision3d.egg-info/top_level.txt +1 -0
  60. vision3d-0.1.0/test/test_bounding_boxes_3d.py +326 -0
  61. vision3d-0.1.0/test/test_camera.py +188 -0
  62. vision3d-0.1.0/test/test_copy_paste_3d.py +619 -0
  63. vision3d-0.1.0/test/test_datasets.py +205 -0
  64. vision3d-0.1.0/test/test_metrics_map3d.py +385 -0
  65. vision3d-0.1.0/test/test_ops.py +95 -0
  66. vision3d-0.1.0/test/test_ops_box3d_corners.py +124 -0
  67. vision3d-0.1.0/test/test_ops_box3d_iou.py +274 -0
  68. vision3d-0.1.0/test/test_ops_nms_3d.py +221 -0
  69. vision3d-0.1.0/test/test_ops_points_in_boxes.py +147 -0
  70. vision3d-0.1.0/test/test_ops_project.py +72 -0
  71. vision3d-0.1.0/test/test_point_cloud_3d.py +235 -0
  72. vision3d-0.1.0/test/test_registry.py +164 -0
  73. vision3d-0.1.0/test/test_transforms.py +1131 -0
  74. vision3d-0.1.0/test/test_transforms_compose.py +231 -0
  75. vision3d-0.1.0/test/test_transforms_point_cloud.py +267 -0
  76. vision3d-0.1.0/test/test_transforms_range_filter.py +202 -0
  77. vision3d-0.1.0/test/test_tv_kernels.py +321 -0
  78. vision3d-0.1.0/version.txt +1 -0
vision3d-0.1.0/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2026, Peter Siegel.
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,2 @@
1
+ include version.txt
2
+ recursive-include src/vision3d/ops/csrc *.h *.cuh *.cpp *.cu
@@ -0,0 +1,20 @@
1
+ Metadata-Version: 2.4
2
+ Name: vision3d
3
+ Version: 0.1.0
4
+ Summary: A 3D extension of torchvision.
5
+ Author: Peter Siegel
6
+ License-Expression: BSD-3-Clause
7
+ Project-URL: Homepage, https://github.com/yeetypete/vision3d
8
+ Project-URL: Issues, https://github.com/yeetypete/vision3d/issues
9
+ Project-URL: Repository, https://github.com/yeetypete/vision3d
10
+ Requires-Python: >=3.12
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: torch>=2.10
14
+ Requires-Dist: torchvision>=0.25
15
+ Requires-Dist: typing-extensions>=4.13; python_version < "3.13"
16
+ Provides-Extra: nuscenes
17
+ Requires-Dist: nuscenes-devkit>=1.1.9; extra == "nuscenes"
18
+ Provides-Extra: viz
19
+ Requires-Dist: rerun-sdk>=0.31.1; extra == "viz"
20
+ Dynamic: license-file
File without changes
@@ -0,0 +1,82 @@
1
+ [project]
2
+ name = "vision3d"
3
+ description = "A 3D extension of torchvision."
4
+ readme = "README.md"
5
+ requires-python = ">=3.12"
6
+ license = "BSD-3-Clause"
7
+ license-files = ["LICENSE"]
8
+ authors = [{ name = "Peter Siegel" }]
9
+ dependencies = [
10
+ "torch>=2.10",
11
+ "torchvision>=0.25",
12
+ "typing-extensions>=4.13; python_version < '3.13'",
13
+ ]
14
+ dynamic = ["version"]
15
+
16
+ [project.urls]
17
+ Homepage = "https://github.com/yeetypete/vision3d"
18
+ Issues = "https://github.com/yeetypete/vision3d/issues"
19
+ Repository = "https://github.com/yeetypete/vision3d"
20
+
21
+ [project.optional-dependencies]
22
+ nuscenes = [
23
+ "nuscenes-devkit>=1.1.9",
24
+ ]
25
+ viz = [
26
+ "rerun-sdk>=0.31.1",
27
+ ]
28
+
29
+ [dependency-groups]
30
+ dev = [
31
+ "pyrefly>=0.59.1",
32
+ "pytest>=9.0.2",
33
+ "ruff>=0.15.9",
34
+ ]
35
+
36
+ [build-system]
37
+ requires = ["numpy>=2", "setuptools<82", "torch>=2.10"]
38
+ build-backend = "setuptools.build_meta"
39
+
40
+ [tool.pyrefly]
41
+ min-severity = "ignore"
42
+ search-path = ["examples", "test"]
43
+
44
+ [tool.pyrefly.errors]
45
+ # Pyrefly does not yet have a strict mode, so we manually set all diagnostics
46
+ # with "ignore" severity levels to "warn".
47
+ implicit-abstract-class = "warn"
48
+ implicit-any = "warn"
49
+ implicitly-defined-attribute = "warn"
50
+ missing-override-decorator = "warn"
51
+ missing-source = "warn"
52
+ not-required-key-access = "warn"
53
+ open-unpacking = "warn"
54
+ unannotated-attribute = "warn"
55
+ unannotated-parameter = "warn"
56
+ unannotated-return = "warn"
57
+ untyped-import = "warn"
58
+ unused-ignore = "warn"
59
+
60
+ [tool.ruff.lint]
61
+ preview = true
62
+ extend-select = ["D", "DOC", "PT", "TC"]
63
+ ignore = [
64
+ "D104", # TODO: remove, missing docstring in placeholder __init__.py packages
65
+ "D107", # __init__ args documented in class docstring (Google style)
66
+ ]
67
+
68
+ [tool.ruff.lint.per-file-ignores]
69
+ "test/**" = ["D"]
70
+ "examples/**" = ["D"]
71
+
72
+ [tool.ruff.lint.pydocstyle]
73
+ convention = "google"
74
+
75
+ [tool.ruff.format]
76
+ docstring-code-format = true
77
+
78
+ [tool.pytest.ini_options]
79
+ filterwarnings = [
80
+ # Unrelated warning from ``@torch.jit.script_method`` in torch/utils/mkldnn.py.
81
+ "ignore:.*torch\\.jit\\.script_method.*:DeprecationWarning",
82
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,83 @@
1
+ """setuptools entry point for vision3d."""
2
+
3
+ import os
4
+ import subprocess
5
+ from pathlib import Path
6
+ from typing import override
7
+
8
+ import torch
9
+ from setuptools import setup
10
+ from setuptools.command.sdist import sdist
11
+ from torch.utils.cpp_extension import (
12
+ CUDA_HOME,
13
+ BuildExtension,
14
+ CppExtension,
15
+ CUDAExtension,
16
+ )
17
+
18
+ _ROOT = Path(__file__).resolve().parent
19
+
20
+
21
+ def get_version() -> str:
22
+ """Return the project version.
23
+
24
+ If the ``BUILD_VERSION`` environment variable is set, it fully overrides the
25
+ base version read from ``version.txt``. Otherwise, for local builds the
26
+ the short git commit SHA is appened as a PEP 440 local version identifier.
27
+ """
28
+ if build_version := os.getenv("BUILD_VERSION"):
29
+ return build_version
30
+
31
+ with open(_ROOT / "version.txt") as f:
32
+ version = f.readline().strip()
33
+
34
+ if "+" in version:
35
+ return version
36
+
37
+ try:
38
+ sha = (
39
+ subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=str(_ROOT))
40
+ .decode("ascii")
41
+ .strip()
42
+ )
43
+ except (subprocess.CalledProcessError, FileNotFoundError):
44
+ return version
45
+
46
+ return f"{version}+{sha[:7]}"
47
+
48
+
49
+ class VersionedSdist(sdist):
50
+ """Bake the fully-resolved version into the sdist's ``version.txt``."""
51
+
52
+ @override
53
+ def make_release_tree(self, base_dir: str, files: list[str]) -> None:
54
+ """Write the resolved version into ``version.txt`` in the release tree."""
55
+ super().make_release_tree(base_dir, files)
56
+ (Path(base_dir) / "version.txt").write_text(f"{get_version()}\n")
57
+
58
+
59
+ FORCE_CUDA = os.getenv("FORCE_CUDA", "0") == "1"
60
+ _HAS_CUDA = (torch.cuda.is_available() and CUDA_HOME is not None) or FORCE_CUDA
61
+
62
+ _CSRC = _ROOT / "src/vision3d/ops/csrc"
63
+ _SOURCES = [
64
+ "src/vision3d/ops/csrc/iou_box3d.cpp",
65
+ "src/vision3d/ops/csrc/iou_box3d/iou_box3d_cpu.cpp",
66
+ ]
67
+ if _HAS_CUDA:
68
+ _SOURCES.append("src/vision3d/ops/csrc/iou_box3d/iou_box3d.cu")
69
+
70
+ Extension = CUDAExtension if _HAS_CUDA else CppExtension
71
+
72
+ setup(
73
+ version=get_version(),
74
+ ext_modules=[
75
+ Extension(
76
+ name="vision3d._C",
77
+ sources=_SOURCES,
78
+ include_dirs=[str(_CSRC)],
79
+ define_macros=[("WITH_CUDA", None)] if _HAS_CUDA else [],
80
+ ),
81
+ ],
82
+ cmdclass={"build_ext": BuildExtension, "sdist": VersionedSdist},
83
+ )
File without changes
@@ -0,0 +1,30 @@
1
+ """Load vision3d's compiled C++/CUDA extension.
2
+
3
+ Importing this module has the side effect of loading the ops into the dispatcher.
4
+ """
5
+
6
+ import importlib.machinery
7
+ import os
8
+
9
+ import torch
10
+
11
+
12
+ def _get_extension_path(lib_name: str) -> str:
13
+ lib_dir = os.path.dirname(__file__)
14
+ loader_details = (
15
+ importlib.machinery.ExtensionFileLoader,
16
+ importlib.machinery.EXTENSION_SUFFIXES,
17
+ )
18
+ extfinder = importlib.machinery.FileFinder(lib_dir, loader_details)
19
+ ext_specs = extfinder.find_spec(lib_name)
20
+ if ext_specs is None or ext_specs.origin is None:
21
+ msg = f"Could not find module '{lib_name}' in {lib_dir}."
22
+ raise ImportError(msg)
23
+ return ext_specs.origin
24
+
25
+
26
+ def _load_library(lib_name: str) -> None:
27
+ torch.ops.load_library(_get_extension_path(lib_name))
28
+
29
+
30
+ _load_library("_C")
@@ -0,0 +1,21 @@
1
+ from ._types import (
2
+ CameraInputs,
3
+ FusionInputs,
4
+ LidarInputs,
5
+ SampleInputs,
6
+ SampleTargets,
7
+ )
8
+ from .collate import collate_fn
9
+ from .kitti import Kitti3D
10
+ from .nuscenes import NuScenes3D
11
+
12
+ __all__ = [
13
+ "CameraInputs",
14
+ "FusionInputs",
15
+ "Kitti3D",
16
+ "LidarInputs",
17
+ "NuScenes3D",
18
+ "SampleInputs",
19
+ "SampleTargets",
20
+ "collate_fn",
21
+ ]
@@ -0,0 +1,73 @@
1
+ """Types for :mod:`vision3d.datasets` samples."""
2
+
3
+ import sys
4
+ from typing import NotRequired, Required, TypedDict
5
+
6
+ from torch import Tensor
7
+
8
+ if sys.version_info >= (3, 13):
9
+ from typing import ReadOnly
10
+ else:
11
+ from typing_extensions import ReadOnly
12
+
13
+ from vision3d.tensors import (
14
+ BoundingBoxes3D,
15
+ CameraExtrinsics,
16
+ CameraImages,
17
+ CameraIntrinsics,
18
+ PointCloud3D,
19
+ )
20
+
21
+
22
+ class SampleInputs(TypedDict):
23
+ """Per-frame model inputs; base contract with all fields optional.
24
+
25
+ Fields are :data:`ReadOnly` so dataset-specific subclasses can
26
+ tighten them from :data:`NotRequired` to :data:`Required`.
27
+
28
+ Attributes:
29
+ points: Lidar point cloud for the frame.
30
+ images: Multi-camera image tensor, one row per camera.
31
+ extrinsics: Lidar-to-camera transforms, one row per camera.
32
+ intrinsics: Per-camera pinhole intrinsic matrices.
33
+ """
34
+
35
+ points: NotRequired[ReadOnly[PointCloud3D]]
36
+ images: NotRequired[ReadOnly[CameraImages]]
37
+ extrinsics: NotRequired[ReadOnly[CameraExtrinsics]]
38
+ intrinsics: NotRequired[ReadOnly[CameraIntrinsics]]
39
+
40
+
41
+ class LidarInputs(SampleInputs):
42
+ """Lidar-only sample: points always present."""
43
+
44
+ points: Required[PointCloud3D]
45
+
46
+
47
+ class CameraInputs(SampleInputs):
48
+ """Camera-only sample: images, intrinsics, and extrinsics always present."""
49
+
50
+ images: Required[CameraImages]
51
+ intrinsics: Required[CameraIntrinsics]
52
+ extrinsics: Required[CameraExtrinsics]
53
+
54
+
55
+ class FusionInputs(SampleInputs):
56
+ """Fusion sample: lidar plus multi-camera, every field present."""
57
+
58
+ points: Required[PointCloud3D]
59
+ images: Required[CameraImages]
60
+ extrinsics: Required[CameraExtrinsics]
61
+ intrinsics: Required[CameraIntrinsics]
62
+
63
+
64
+ class SampleTargets(TypedDict):
65
+ """Per-frame ground-truth annotations.
66
+
67
+ Attributes:
68
+ boxes: 3D bounding boxes in the lidar frame.
69
+ labels: Integer class labels, one per box.
70
+ """
71
+
72
+ boxes: BoundingBoxes3D
73
+ labels: Tensor
@@ -0,0 +1,22 @@
1
+ """Collation utilities for DataLoader."""
2
+
3
+ from typing import Any
4
+
5
+
6
+ def collate_fn(
7
+ batch: list[tuple[Any, Any]],
8
+ ) -> tuple[tuple[Any, ...], tuple[Any, ...]]:
9
+ """Collate a batch of ``(inputs, targets)`` without stacking.
10
+
11
+ Variable-size tensors (point clouds, bounding boxes) cannot be stacked
12
+ into a single tensor. This collate function groups them as tuples,
13
+ matching torchvision's detection collate pattern.
14
+
15
+ Args:
16
+ batch: List of ``(inputs, targets)`` from the dataset.
17
+
18
+ Returns:
19
+ Tuple of ``(inputs_tuple, targets_tuple)``.
20
+ """
21
+ inputs, targets = zip(*batch)
22
+ return tuple(inputs), tuple(targets)