Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

docs: follow-up fixes to the site revamp (#4173)

Dmytro Mishkine096943818ff
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 266485799..54a357841 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -142,6 +142,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Bug fixes
+* Follow-up fixes to the documentation revamp (#4155): the landing page's filtering card quoted the combined
+ `filters`/`color`/`enhance`/`morphology` count next to a `kornia.filters` label, the "Why Kornia?" hero carousel
+ resumed after a visitor picked a tab, the Community page linked to the now-unregistered `librecv.org`, and the
+ GPU page promised CUDA measurements the committed benchmark runs do not yet contain. `pydata-sphinx-theme` is now
+ version-bounded, since the site's CSS and JS target theme internals. (#4173)
* Reset an automatic augmentation policy's cached transformation matrix before applying it again, both for a
sub-policy inside `TrivialAugment`, `RandAugment` and `AutoAugment` and for those policies nested inside
`AugmentationSequential`. Consecutive calls that selected the same geometric policy could transform the input with
diff --git a/docs/fetch_dependents.py b/docs/fetch_dependents.py
index d68cbd646..8111ca4f6 100644
--- a/docs/fetch_dependents.py
+++ b/docs/fetch_dependents.py
@@ -133,9 +133,9 @@ def crawl(kind: str, max_pages: int) -> tuple[int | None, list[dict], bool]:
time.sleep(DELAY_S)
-def load_existing() -> dict:
- if OUT.exists():
- return json.loads(OUT.read_text())
+def load_existing(path: Path = OUT) -> dict:
+ if path.exists():
+ return json.loads(path.read_text())
return {}
@@ -165,7 +165,7 @@ def main(argv: list[str] | None = None) -> int:
parser.add_argument("--out", type=Path, default=OUT)
args = parser.parse_args(argv)
- data = load_existing()
+ data = load_existing(args.out)
for kind in args.kind or ["repositories", "packages"]:
print(f"crawling {kind}...", file=sys.stderr)
total, rows, complete = crawl(kind, args.max_pages)
diff --git a/docs/generate_adoption.py b/docs/generate_adoption.py
index 0235c63c0..7553fb13b 100644
--- a/docs/generate_adoption.py
+++ b/docs/generate_adoption.py
@@ -61,7 +61,8 @@ def _round_headline(count: int) -> str:
if count >= 10_000:
return f"{count // 1000}K"
if count >= 1_000:
- return f"{count / 1000:.1f}K".replace(".0K", "K")
+ # Truncate rather than round: 1,290 is "1.2K", and 9,999 must not become "10K".
+ return f"{count // 100 / 10:.1f}K".replace(".0K", "K")
return str(count)
diff --git a/docs/generate_benchmarks.py b/docs/generate_benchmarks.py
index 99a4aabaf..c1bed71fe 100644
--- a/docs/generate_benchmarks.py
+++ b/docs/generate_benchmarks.py
@@ -156,7 +156,7 @@ def hero_figures(results_root: Path) -> dict | None:
continue
cpu = _throughput(devices["cpu"], HERO["op"], HERO["batch"], HERO["backend"])
gpu = _throughput(devices[accelerators[0]], HERO["op"], HERO["batch"], HERO["backend"])
- if cpu is None or gpu is None or cpu <= 0:
+ if cpu is None or gpu is None or cpu <= 0 or gpu <= 0:
continue
meta = devices[accelerators[0]]["metadata"]
return {
diff --git a/docs/generate_examples.py b/docs/generate_examples.py
index a67542aba..c39ca38e3 100644
--- a/docs/generate_examples.py
+++ b/docs/generate_examples.py
@@ -755,14 +755,16 @@ def main():
with torch.no_grad():
detections = face_detector(K.color.bgr_to_rgb(img_crowd) * 255.0)[0]
faces = [K.contrib.FaceDetectorResult(d) for d in detections]
- boxes = torch.stack([torch.cat([f.top_left, f.bottom_right]) for f in faces if f.score > 0.7])[None]
+ confident = [torch.cat([f.top_left, f.bottom_right]) for f in faces if f.score > 0.7]
out = img_crowd.clone()
- for pad in (0, 1, 2): # three passes give a 3 px outline
- out = K.image.draw_rectangle(
- out, boxes + torch.tensor([-pad, -pad, pad, pad]), color=torch.tensor([0.4, 1.0, 0.2])
- )
+ if confident:
+ boxes = torch.stack(confident)[None]
+ for pad in (0, 1, 2): # three passes give a 3 px outline
+ out = K.image.draw_rectangle(
+ out, boxes + torch.tensor([-pad, -pad, pad, pad]), color=torch.tensor([0.4, 1.0, 0.2])
+ )
cv2.imwrite(str(OUTPUT_PATH / "face_detection.png"), K.image.tensor_to_image((out[0] * 255.0).byte()))
- print(f"Generated image example for FaceDetector. {boxes.shape[1]} faces")
+ print(f"Generated image example for FaceDetector. {len(confident)} faces")
if __name__ == "__main__":
diff --git a/docs/source/_static/css/pydata.css b/docs/source/_static/css/pydata.css
index 90858a95b..da863109a 100644
--- a/docs/source/_static/css/pydata.css
+++ b/docs/source/_static/css/pydata.css
@@ -843,8 +843,7 @@ html[data-theme="dark"] .bd-content .sd-tab-set .sd-tab-content {
z-index: 1060;
}
-.kornia-navbar-dropdown:hover .kornia-navbar-dropdown__menu,
-.kornia-navbar-dropdown:focus-within .kornia-navbar-dropdown__menu {
+.kornia-navbar-dropdown.is-open .kornia-navbar-dropdown__menu {
display: block;
}
@@ -867,7 +866,7 @@ html[data-theme="dark"] .bd-content .sd-tab-set .sd-tab-content {
transition: transform 120ms ease-in-out;
}
-.kornia-navbar-dropdown:hover .kornia-navbar-dropdown__caret {
+.kornia-navbar-dropdown.is-open .kornia-navbar-dropdown__caret {
transform: rotate(180deg);
}
@@ -878,8 +877,7 @@ html[data-theme="dark"] .bd-content .sd-tab-set .sd-tab-content {
padding: 0.6rem 0.4rem;
}
-.kornia-navbar-dropdown:hover .kornia-navbar-dropdown__menu--mega,
-.kornia-navbar-dropdown:focus-within .kornia-navbar-dropdown__menu--mega {
+.kornia-navbar-dropdown.is-open .kornia-navbar-dropdown__menu--mega {
display: block;
}
diff --git a/docs/source/_static/js/custom.js b/docs/source/_static/js/custom.js
index ce05d910b..5cd35e15a 100644
--- a/docs/source/_static/js/custom.js
+++ b/docs/source/_static/js/custom.js
@@ -165,6 +165,7 @@ document.addEventListener("DOMContentLoaded", function () {
let startedAt = 0;
let remaining = PERIOD_MS;
let paused = false;
+ let stopped = false;
function advance() {
if (document.hidden) {
@@ -182,19 +183,24 @@ document.addEventListener("DOMContentLoaded", function () {
timer = setTimeout(advance, remaining);
}
function pause() {
- if (paused || timer === null) return;
+ if (stopped || paused || timer === null) return;
paused = true;
clearTimeout(timer);
remaining = Math.max(200, remaining - (Date.now() - startedAt));
tabSet.classList.add("is-paused");
}
function resume() {
- if (!paused) return;
+ if (stopped || !paused) return;
paused = false;
tabSet.classList.remove("is-paused");
schedule();
}
+ // Choosing a tab ends the cycle for good. A click always arrives as pointerenter -> change ->
+ // pointerleave, so without ``stopped`` the trailing pointerleave would resume the carousel the
+ // visitor just took over; the same holds for focusin -> change -> focusout on the keyboard.
function stop() {
+ stopped = true;
+ paused = false;
clearTimeout(timer);
timer = null;
tabSet.classList.remove("is-autoplaying", "is-paused");
@@ -227,6 +233,52 @@ document.addEventListener("DOMContentLoaded", function () {
const caret = document.createElement("i");
caret.className = "fa-solid fa-chevron-down kornia-navbar-dropdown__caret";
link.appendChild(caret);
+
+ // Keep the panel's explicit open class and the trigger's ARIA state in sync. The inline sidebar
+ // copy is always expanded, so it announces as such and needs no listeners.
+ link.setAttribute("aria-haspopup", "true");
+ link.setAttribute("aria-expanded", inline ? "true" : "false");
+ if (inline) return;
+ let hovered = false;
+ let focusWithin = false;
+ let dismissed = false;
+ function syncOpenState() {
+ const open = !dismissed && (hovered || focusWithin);
+ li.classList.toggle("is-open", open);
+ link.setAttribute("aria-expanded", String(open));
+ }
+ li.addEventListener("pointerenter", function () {
+ hovered = true;
+ dismissed = false;
+ syncOpenState();
+ });
+ li.addEventListener("pointerleave", function () {
+ hovered = false;
+ syncOpenState();
+ });
+ li.addEventListener("focusin", function () {
+ focusWithin = true;
+ dismissed = false;
+ syncOpenState();
+ });
+ li.addEventListener("focusout", function (e) {
+ if (li.contains(e.relatedTarget)) return;
+ focusWithin = false;
+ dismissed = false;
+ syncOpenState();
+ });
+ // Escape closes the menu and returns focus to its trigger. ``dismissed`` keeps a hovered item
+ // closed until the pointer re-enters or focus leaves and returns.
+ li.addEventListener("keydown", function (e) {
+ if (e.key !== "Escape") return;
+ const active = document.activeElement;
+ if (!li.contains(active)) return;
+ e.preventDefault();
+ e.stopPropagation();
+ link.focus();
+ dismissed = true;
+ syncOpenState();
+ });
}
function menuFrom(items) {
@@ -286,6 +338,9 @@ document.addEventListener("DOMContentLoaded", function () {
const link = document.createElement("a");
link.className = "nav-link";
link.href = "#";
+ // It opens a menu instead of navigating, so announce it as a button rather than as a link
+ // that goes nowhere; ``href`` stays for keyboard focusability.
+ link.setAttribute("role", "button");
link.textContent = "Ecosystem";
link.addEventListener("click", (e) => e.preventDefault());
li.appendChild(link);
diff --git a/docs/source/community/community.rst b/docs/source/community/community.rst
index a0c76c1f0..6a1b734f3 100644
--- a/docs/source/community/community.rst
+++ b/docs/source/community/community.rst
@@ -2,7 +2,7 @@ Community
=========
.. meta::
- :description: Join the Kornia community: Discord for chat, GitHub for development, Twitter/X, LinkedIn and YouTube for news, the Chinese community on QQ and Zhihu, and the wider LibreCV ecosystem.
+ :description: Join the Kornia community: Discord for chat, GitHub for development, Twitter/X, LinkedIn and YouTube for news, the Chinese community on QQ and Zhihu, and the wider Kornia AI ecosystem.
Kornia is built by people who talk to each other in the open. Pick your channel:
@@ -43,8 +43,8 @@ Kornia is built by people who talk to each other in the open. Pick your channel:
A newsletter is under construction β€” announcements land on the channels above in the meantime.
-Kornia is part of a wider open ecosystem: the `LibreCV <https://librecv.org>`_ community,
-`Kornia AI <https://kornia.org>`_ (the non-profit behind the library, see :doc:`the governance page
+Kornia is part of a wider open ecosystem: `Kornia AI <https://kornia.org>`_ (the non-profit behind
+the library, see :doc:`the governance page
</get-started/governance>`), and integrations such as the `OpenCV AI Kit
<https://docs.luxonis.com/en/latest/pages/tutorials/creating-custom-nn-models/#kornia>`_ and
:doc:`kornia-rs </get-started/edge>`.
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 2b8616ac4..66ce424bd 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -132,7 +132,7 @@ def _public_operator_count() -> int:
contextlib.redirect_stderr(io.StringIO()),
):
warnings.simplefilter("ignore")
- for info in pkgutil.walk_packages(kornia.__path__, "kornia."):
+ for info in pkgutil.walk_packages(kornia.__path__, "kornia.", onerror=lambda name: None):
if skip.search(info.name) or any(part.startswith("_") for part in info.name.split(".")[1:]):
continue
try:
@@ -158,34 +158,28 @@ def _landing_page_counts() -> dict[str, str]:
The public-name counts read the stable-core inventory that ``tests/test_api_surface.py`` pins;
``kornia.feature`` and ``kornia.models`` are outside it, so they are counted from the live
- package and from the model pages under ``docs/source/models/``. ``operators`` is the
- library-wide total from :func:`_public_operator_count`, floored to the hundred below it so the
- page can say "1,000+" and stay true between releases.
+ package and from the model pages under ``docs/source/models/``. Each count names exactly the
+ module the card it appears on links to. ``operators-floor`` is the library-wide total from
+ :func:`_public_operator_count`, floored to the hundred below it so the page can say "1,000+"
+ and stay true between releases.
"""
with open("../../tests/api_surface.json", encoding="utf-8") as handle:
surface = {name: len(names) for name, names in json.load(handle).items()}
import kornia.feature
operators = _public_operator_count()
- image_processing = sum(
- surface[name] for name in ("kornia.filters", "kornia.color", "kornia.enhance", "kornia.morphology")
- )
- losses_metrics = surface["kornia.losses"] + surface["kornia.metrics"]
model_pages = [entry for entry in os.listdir("models") if entry.endswith(".rst") and entry != "index.rst"]
+ # Every entry here is quoted by a page; a substitution nothing references is dead weight that
+ # reads as an available figure, so add one when a page needs it rather than ahead of time.
return {
"geometry": str(surface["kornia.geometry"]),
"feature": str(len(kornia.feature.__all__)),
- "image-processing": str(image_processing),
- "losses-metrics": str(losses_metrics),
+ "filters": str(surface["kornia.filters"]),
"augmentation": str(surface["kornia.augmentation"]),
"models": str(len(model_pages)),
- "operators": f"{operators:,}",
"operators-floor": f"{operators // 100 * 100:,}",
"dependents": f"{_adoption['repositories']:,}",
- "dependents-listed": f"{_adoption['repositories_listed']:,}",
- "dependents-rounded": str(_adoption["repositories_rounded"]),
"dependent-packages": f"{_adoption['packages']:,}",
- "dependents-date": str(_adoption["generated_at"]),
}
diff --git a/docs/source/get-started/gpu-acceleration.rst b/docs/source/get-started/gpu-acceleration.rst
index f75e0cd6f..65ba81708 100644
--- a/docs/source/get-started/gpu-acceleration.rst
+++ b/docs/source/get-started/gpu-acceleration.rst
@@ -32,7 +32,8 @@ Three habits make GPU pipelines fast:
Augmentations are the typical win: a :class:`~kornia.augmentation.AugmentationSequential` pipeline samples and
applies transforms for the entire batch on the GPU, inside the training loop, and most operators also run under
``torch.compile`` for kernel fusion. The :doc:`performance page <performance>` shows measured eager-mode
-comparisons against torchvision, albumentations, OpenCV and PIL on CPU, CUDA and Apple silicon, and the
+comparisons against torchvision, albumentations, OpenCV and PIL on the devices the committed benchmark runs
+cover -- CPU and Apple silicon today, with more hardware being added -- and the
:doc:`precision page <precision>` documents ``float16``/``bfloat16`` support.
Apple silicon (``device="mps"``) is supported as well. PyTorch's MPS backend has no ``float64`` tensors, so keep
diff --git a/docs/source/index.rst b/docs/source/index.rst
index e047b64f8..fe6827474 100644
--- a/docs/source/index.rst
+++ b/docs/source/index.rst
@@ -233,7 +233,7 @@ models. Six places to start below; the full map is the :doc:`API reference <api>
or inside a loss.
+++
- |count-image-processing| operators Β· ``kornia.filters`` :octicon:`arrow-right`
+ |count-filters| operators Β· ``kornia.filters`` :octicon:`arrow-right`
.. grid-item-card:: Augment everything
:img-top: _static/img/AugmentationSequential.png
diff --git a/pyproject.toml b/pyproject.toml
index a273e4995..6776466e7 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -57,7 +57,7 @@ dev = [
]
docs = [
"furo",
- "pydata-sphinx-theme",
+ "pydata-sphinx-theme>=0.21,<0.22", # _static/css/pydata.css and js/custom.js target theme internals
"ivy>=1.0.0.0",
"kornia_moons",
"matplotlib",
diff --git a/uv.lock b/uv.lock
index 6fb7f8bc8..ab2b708ce 100644
--- a/uv.lock
+++ b/uv.lock
@@ -1027,7 +1027,7 @@ requires-dist = [
{ name = "packaging" },
{ name = "pillow", marker = "extra == 'dev'" },
{ name = "pre-commit", marker = "extra == 'dev'" },
- { name = "pydata-sphinx-theme", marker = "extra == 'docs'" },
+ { name = "pydata-sphinx-theme", marker = "extra == 'docs'", specifier = ">=0.21,<0.22" },
{ name = "pytest", marker = "extra == 'dev'" },
{ name = "pytest-cov", marker = "extra == 'dev'" },
{ name = "pytest-timeout", marker = "extra == 'dev'" },