visbench 0.2.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 (120) hide show
  1. visbench-0.2.0/.github/workflows/ci.yml +77 -0
  2. visbench-0.2.0/.github/workflows/slow.yml +86 -0
  3. visbench-0.2.0/.gitignore +28 -0
  4. visbench-0.2.0/CHANGELOG.md +764 -0
  5. visbench-0.2.0/CLAUDE.md +632 -0
  6. visbench-0.2.0/LICENSE +21 -0
  7. visbench-0.2.0/NOTICE +96 -0
  8. visbench-0.2.0/PKG-INFO +604 -0
  9. visbench-0.2.0/README.md +548 -0
  10. visbench-0.2.0/assets/visbench-icon-dark.svg +13 -0
  11. visbench-0.2.0/assets/visbench-icon-light.svg +13 -0
  12. visbench-0.2.0/assets/visbench-logo-dark.svg +14 -0
  13. visbench-0.2.0/assets/visbench-logo-light.svg +14 -0
  14. visbench-0.2.0/conftest.py +7 -0
  15. visbench-0.2.0/examples/classify.py +114 -0
  16. visbench-0.2.0/examples/correspond.py +154 -0
  17. visbench-0.2.0/examples/depth.py +146 -0
  18. visbench-0.2.0/examples/normals.py +162 -0
  19. visbench-0.2.0/examples/retrieve.py +97 -0
  20. visbench-0.2.0/examples/segment.py +166 -0
  21. visbench-0.2.0/examples/segment_semantic.py +226 -0
  22. visbench-0.2.0/examples/similarity.py +141 -0
  23. visbench-0.2.0/pyproject.toml +103 -0
  24. visbench-0.2.0/tests/backbones/test_base_backbone.py +223 -0
  25. visbench-0.2.0/tests/backbones/test_clip.py +240 -0
  26. visbench-0.2.0/tests/backbones/test_clip_quickgelu.py +117 -0
  27. visbench-0.2.0/tests/backbones/test_custom.py +386 -0
  28. visbench-0.2.0/tests/backbones/test_dinov2.py +200 -0
  29. visbench-0.2.0/tests/backbones/test_multilayer.py +234 -0
  30. visbench-0.2.0/tests/backbones/test_timm.py +250 -0
  31. visbench-0.2.0/tests/cache/test_feature_cache.py +648 -0
  32. visbench-0.2.0/tests/cache/test_streaming.py +251 -0
  33. visbench-0.2.0/tests/cli/conftest.py +101 -0
  34. visbench-0.2.0/tests/cli/test_commands.py +465 -0
  35. visbench-0.2.0/tests/cli/test_parser.py +204 -0
  36. visbench-0.2.0/tests/conftest.py +181 -0
  37. visbench-0.2.0/tests/data/test_dense_dataset.py +627 -0
  38. visbench-0.2.0/tests/data/test_image_folder.py +224 -0
  39. visbench-0.2.0/tests/data/test_pair_dataset.py +208 -0
  40. visbench-0.2.0/tests/data/test_pair_views.py +136 -0
  41. visbench-0.2.0/tests/data/test_subset.py +162 -0
  42. visbench-0.2.0/tests/data/test_triplet.py +188 -0
  43. visbench-0.2.0/tests/heads/test_heads.py +314 -0
  44. visbench-0.2.0/tests/results/test_results.py +287 -0
  45. visbench-0.2.0/tests/tasks/test_2afc_metrics.py +141 -0
  46. visbench-0.2.0/tests/tasks/test_base_task.py +196 -0
  47. visbench-0.2.0/tests/tasks/test_classification.py +250 -0
  48. visbench-0.2.0/tests/tasks/test_correspondence.py +557 -0
  49. visbench-0.2.0/tests/tasks/test_dense_metrics.py +238 -0
  50. visbench-0.2.0/tests/tasks/test_depth.py +567 -0
  51. visbench-0.2.0/tests/tasks/test_generic_segmentation.py +303 -0
  52. visbench-0.2.0/tests/tasks/test_normal_metrics.py +217 -0
  53. visbench-0.2.0/tests/tasks/test_retrieval.py +179 -0
  54. visbench-0.2.0/tests/tasks/test_segmentation_metrics.py +123 -0
  55. visbench-0.2.0/tests/tasks/test_semantic_metrics.py +211 -0
  56. visbench-0.2.0/tests/tasks/test_semantic_segmentation.py +287 -0
  57. visbench-0.2.0/tests/tasks/test_similarity.py +192 -0
  58. visbench-0.2.0/tests/tasks/test_surface_normal.py +532 -0
  59. visbench-0.2.0/tests/test_end_to_end.py +298 -0
  60. visbench-0.2.0/tests/test_registry.py +181 -0
  61. visbench-0.2.0/tests/test_run.py +267 -0
  62. visbench-0.2.0/tests/test_scaffold.py +68 -0
  63. visbench-0.2.0/uv.lock +2028 -0
  64. visbench-0.2.0/visbench/__init__.py +104 -0
  65. visbench-0.2.0/visbench/backbones/__init__.py +28 -0
  66. visbench-0.2.0/visbench/backbones/base.py +334 -0
  67. visbench-0.2.0/visbench/backbones/clip.py +247 -0
  68. visbench-0.2.0/visbench/backbones/custom.py +311 -0
  69. visbench-0.2.0/visbench/backbones/dinov2.py +206 -0
  70. visbench-0.2.0/visbench/backbones/pooling.py +127 -0
  71. visbench-0.2.0/visbench/backbones/timm_backbone.py +224 -0
  72. visbench-0.2.0/visbench/cache/__init__.py +7 -0
  73. visbench-0.2.0/visbench/cache/feature_cache.py +728 -0
  74. visbench-0.2.0/visbench/cache/keys.py +97 -0
  75. visbench-0.2.0/visbench/cache/streaming.py +120 -0
  76. visbench-0.2.0/visbench/cli/__init__.py +24 -0
  77. visbench-0.2.0/visbench/cli/datasets.py +488 -0
  78. visbench-0.2.0/visbench/cli/main.py +245 -0
  79. visbench-0.2.0/visbench/data/__init__.py +32 -0
  80. visbench-0.2.0/visbench/data/base.py +167 -0
  81. visbench-0.2.0/visbench/data/dense.py +505 -0
  82. visbench-0.2.0/visbench/data/image_folder.py +159 -0
  83. visbench-0.2.0/visbench/data/pair_dataset.py +392 -0
  84. visbench-0.2.0/visbench/data/triplet.py +220 -0
  85. visbench-0.2.0/visbench/heads/__init__.py +20 -0
  86. visbench-0.2.0/visbench/heads/base.py +126 -0
  87. visbench-0.2.0/visbench/heads/dpt.py +255 -0
  88. visbench-0.2.0/visbench/heads/linear.py +87 -0
  89. visbench-0.2.0/visbench/metrics/__init__.py +34 -0
  90. visbench-0.2.0/visbench/metrics/classification.py +44 -0
  91. visbench-0.2.0/visbench/metrics/correspondence.py +162 -0
  92. visbench-0.2.0/visbench/metrics/dense.py +525 -0
  93. visbench-0.2.0/visbench/metrics/retrieval.py +72 -0
  94. visbench-0.2.0/visbench/metrics/similarity.py +85 -0
  95. visbench-0.2.0/visbench/registry.py +214 -0
  96. visbench-0.2.0/visbench/results/__init__.py +9 -0
  97. visbench-0.2.0/visbench/results/schema.py +160 -0
  98. visbench-0.2.0/visbench/results/writer.py +75 -0
  99. visbench-0.2.0/visbench/runner.py +232 -0
  100. visbench-0.2.0/visbench/tasks/__init__.py +17 -0
  101. visbench-0.2.0/visbench/tasks/base.py +182 -0
  102. visbench-0.2.0/visbench/tasks/dense_base.py +554 -0
  103. visbench-0.2.0/visbench/tasks/high_level/__init__.py +13 -0
  104. visbench-0.2.0/visbench/tasks/high_level/classification.py +217 -0
  105. visbench-0.2.0/visbench/tasks/high_level/detection.py +27 -0
  106. visbench-0.2.0/visbench/tasks/high_level/retrieval.py +123 -0
  107. visbench-0.2.0/visbench/tasks/high_level/semantic_segmentation.py +189 -0
  108. visbench-0.2.0/visbench/tasks/low_level/README.md +26 -0
  109. visbench-0.2.0/visbench/tasks/low_level/__init__.py +8 -0
  110. visbench-0.2.0/visbench/tasks/mid_level/__init__.py +23 -0
  111. visbench-0.2.0/visbench/tasks/mid_level/correspondence.py +347 -0
  112. visbench-0.2.0/visbench/tasks/mid_level/depth.py +222 -0
  113. visbench-0.2.0/visbench/tasks/mid_level/generic_segmentation.py +171 -0
  114. visbench-0.2.0/visbench/tasks/mid_level/similarity.py +149 -0
  115. visbench-0.2.0/visbench/tasks/mid_level/surface_normal.py +299 -0
  116. visbench-0.2.0/visbench/types.py +131 -0
  117. visbench-0.2.0/visbench/utils/__init__.py +6 -0
  118. visbench-0.2.0/visbench/utils/device.py +19 -0
  119. visbench-0.2.0/visbench/utils/image.py +33 -0
  120. visbench-0.2.0/visbench/utils/seed.py +43 -0
@@ -0,0 +1,77 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ workflow_dispatch:
8
+
9
+ concurrency:
10
+ group: ${{ github.workflow }}-${{ github.ref }}
11
+ cancel-in-progress: true
12
+
13
+ jobs:
14
+ lint:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v5
18
+ - uses: actions/setup-python@v6
19
+ with:
20
+ # Keep equal to [tool.mypy] python_version in pyproject.toml. mypy
21
+ # parses dependency stubs under that version, and numpy 2.x's require
22
+ # 3.12; a lower one fails inside numpy before reaching this package.
23
+ python-version: "3.12"
24
+ - run: pip install "ruff>=0.4,<1.0" "mypy>=1.8,<2.0" torch torchvision numpy pillow scikit-learn --extra-index-url https://download.pytorch.org/whl/cpu
25
+ - name: ruff check
26
+ run: ruff check visbench/ tests/ conftest.py examples/
27
+ - name: ruff format --check
28
+ run: ruff format --check visbench/ tests/ conftest.py examples/
29
+ - name: mypy
30
+ # Gating. It was continue-on-error while everything was stubs, which
31
+ # made it a check that could never fail -- worse than not running it.
32
+ run: mypy visbench/ examples/ --ignore-missing-imports
33
+
34
+ test:
35
+ runs-on: ubuntu-latest
36
+ strategy:
37
+ fail-fast: false
38
+ matrix:
39
+ # Both ends of the supported range from pyproject `requires-python`.
40
+ python-version: ["3.10", "3.12"]
41
+ steps:
42
+ - uses: actions/checkout@v5
43
+ - uses: actions/setup-python@v6
44
+ with:
45
+ python-version: ${{ matrix.python-version }}
46
+ cache: pip
47
+ - name: Install (CPU-only torch)
48
+ # The GPU wheels are ~2 GB and CI never runs a backbone forward pass.
49
+ run: |
50
+ pip install --upgrade pip
51
+ pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
52
+ pip install -e ".[dev]"
53
+ - name: pytest
54
+ run: pytest tests/ -v
55
+
56
+ lock:
57
+ # A lockfile that has drifted from pyproject.toml is worse than none: it
58
+ # looks like a reproducibility guarantee and is not one.
59
+ runs-on: ubuntu-latest
60
+ steps:
61
+ - uses: actions/checkout@v5
62
+ - uses: astral-sh/setup-uv@v9.0.0
63
+ - name: uv.lock matches pyproject.toml
64
+ run: uv lock --check
65
+
66
+ build:
67
+ # Guards the PyPI target: catches a broken pyproject (missing LICENSE,
68
+ # bad metadata) long before a release is attempted.
69
+ runs-on: ubuntu-latest
70
+ steps:
71
+ - uses: actions/checkout@v5
72
+ - uses: actions/setup-python@v6
73
+ with:
74
+ python-version: "3.11"
75
+ - run: pip install build twine
76
+ - run: python -m build
77
+ - run: twine check dist/*
@@ -0,0 +1,86 @@
1
+ name: Slow tests
2
+
3
+ # The suite that downloads real backbone weights. It is deliberately NOT part of
4
+ # CI's gating jobs: `addopts = "-m 'not slow'"` deselects these, and a plain
5
+ # `pytest` therefore never runs them, so for the whole life of the project
6
+ # nothing on main executed a single real forward pass.
7
+ #
8
+ # That is not a theoretical gap. Two bugs shipped to main under a green tick
9
+ # because of it (#2):
10
+ # - the CLIP QuickGELU guard filtered on a phrase open_clip never emits, so it
11
+ # was dead code from the day it was written. Its test existed, failed
12
+ # correctly, and had never once run (#3).
13
+ # - DINOv2 was unusable on Python 3.9 for three days while the 3.9 job -- whose
14
+ # entire purpose was to prove that floor worked -- reported success, because
15
+ # every backbone-loading test is marked slow (#1).
16
+ #
17
+ # Both would have been caught here within a day.
18
+
19
+ on:
20
+ # Catches the commit that broke it, while it is still attributable. Every
21
+ # commit in this repo lands on main directly, so this is the real gate.
22
+ push:
23
+ branches: [main]
24
+ # Catches drift no commit causes: an open_clip release rewording the warning
25
+ # the QuickGELU guard matches on would silently re-break it, and no push would
26
+ # be to blame.
27
+ schedule:
28
+ - cron: "0 3 * * *"
29
+ workflow_dispatch:
30
+
31
+ # Not on pull_request on purpose. These tests pull ~1.7 GB of weights and take
32
+ # minutes; making every PR wait on that would trade a lot of friction for very
33
+ # little, given the push-to-main trigger above covers the same commits.
34
+
35
+ concurrency:
36
+ group: ${{ github.workflow }}-${{ github.ref }}
37
+ cancel-in-progress: true
38
+
39
+ jobs:
40
+ slow:
41
+ runs-on: ubuntu-latest
42
+ # Generous: a cold cache downloads DINOv2 ViT-S/B, both CLIP ViT-Bs and two
43
+ # ResNets. A warm one should finish in a few minutes.
44
+ timeout-minutes: 30
45
+ steps:
46
+ - uses: actions/checkout@v5
47
+
48
+ - uses: actions/setup-python@v6
49
+ with:
50
+ # The floor, where a version-specific import failure would show up.
51
+ python-version: "3.10"
52
+ cache: pip
53
+
54
+ - name: Read the pinned DINOv2 ref
55
+ id: pins
56
+ # HUB_REF pins the upstream repo and feeds cache_key(), so it is exactly
57
+ # the right thing to key downloaded weights on: change the ref and the
58
+ # old download is the wrong code, not merely stale.
59
+ run: |
60
+ echo "hub_ref=$(grep -oP 'HUB_REF = "\K[0-9a-f]+' visbench/backbones/dinov2.py)" >> "$GITHUB_OUTPUT"
61
+
62
+ - name: Cache backbone weights
63
+ uses: actions/cache@v4
64
+ with:
65
+ # Three separate homes: torch.hub and its checkpoints, open_clip's
66
+ # OpenAI weights, and timm's via huggingface_hub.
67
+ path: |
68
+ ~/.cache/torch
69
+ ~/.cache/clip
70
+ ~/.cache/huggingface
71
+ key: weights-${{ runner.os }}-${{ steps.pins.outputs.hub_ref }}
72
+ restore-keys: weights-${{ runner.os }}-
73
+
74
+ - name: Install (CPU-only torch, all extras)
75
+ # `.[all,dev]` rather than the gating job's `.[dev]`: without the clip
76
+ # and timm extras their backbones are skipped in the registry rather
77
+ # than failing, and this suite would quietly test half of what it claims.
78
+ run: |
79
+ pip install --upgrade pip
80
+ pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu
81
+ pip install -e ".[all,dev]"
82
+
83
+ - name: pytest -m slow
84
+ # An explicit -m on the command line overrides addopts, since pytest
85
+ # honours the last one given.
86
+ run: pytest -m slow -v --durations=10
@@ -0,0 +1,28 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ build/
6
+ dist/
7
+ # No trailing slash: the venv may be a symlink to storage outside the home
8
+ # quota, and a trailing slash matches directories only -- git treats a symlink
9
+ # as a file, so `.venv/` would leave it untracked-but-visible.
10
+ .venv
11
+ venv/
12
+
13
+ # Tooling
14
+ .pytest_cache/
15
+ .mypy_cache/
16
+ .ruff_cache/
17
+ .coverage
18
+ htmlcov/
19
+
20
+ # VisBench artifacts
21
+ .visbench_cache/
22
+ results/*.jsonl
23
+ checkpoints/
24
+
25
+ # Editors / OS
26
+ .vscode/
27
+ .idea/
28
+ .DS_Store