diff --git a/docs/cookbooks.md b/docs/cookbooks.md index 98cfba16..dd963edb 100644 --- a/docs/cookbooks.md +++ b/docs/cookbooks.md @@ -1,5 +1,7 @@ --- template: cookbooks.html +comments: true +status: new hide: - navigation - toc diff --git a/docs/how_to/detect_and_annotate.md b/docs/how_to/detect_and_annotate.md index a0b9d82b..ca0c5666 100644 --- a/docs/how_to/detect_and_annotate.md +++ b/docs/how_to/detect_and_annotate.md @@ -44,7 +44,7 @@ Now that we have predictions from a model, we can load them into Supervision. === "Ultralytics" - We can do so using the [`sv.Detections.from_ultralytics`](/latest/detection/core/#supervision.detection.core.Detections.from_ultralytics) method, which accepts model results from both detection and segmentation models. + We can do so using the [`sv.Detections.from_ultralytics`](detection/core/#supervision.detection.core.Detections.from_ultralytics) method, which accepts model results from both detection and segmentation models. ```python import cv2 @@ -59,7 +59,7 @@ Now that we have predictions from a model, we can load them into Supervision. === "Inference" - We can do so using the [`sv.Detections.from_inference`](/latest/detection/core/#supervision.detection.core.Detections.from_inference) method, which accepts model results from both detection and segmentation models. + We can do so using the [`sv.Detections.from_inference`](detection/core/#supervision.detection.core.Detections.from_inference) method, which accepts model results from both detection and segmentation models. ```python import cv2 @@ -74,17 +74,17 @@ Now that we have predictions from a model, we can load them into Supervision. You can conveniently load predictions from other computer vision frameworks and libraries using: -- [`from_deepsparse`](/latest/detection/core/#supervision.detection.core.Detections.from_deepsparse) ([Deepsparse](https://github.com/neuralmagic/deepsparse)) -- [`from_detectron2`](/latest/detection/core/#supervision.detection.core.Detections.from_detectron2) ([Detectron2](https://github.com/facebookresearch/detectron2)) -- [`from_mmdetection`](/latest/detection/core/#supervision.detection.core.Detections.from_mmdetection) ([MMDetection](https://github.com/open-mmlab/mmdetection)) -- [`from_inference`](/latest/detection/core/#supervision.detection.core.Detections.from_inference) ([Roboflow Inference](https://github.com/roboflow/inference)) -- [`from_sam`](/latest/detection/core/#supervision.detection.core.Detections.from_sam) ([Segment Anything Model](https://github.com/facebookresearch/segment-anything)) -- [`from_transformers`](/latest/detection/core/#supervision.detection.core.Detections.from_transformers) ([HuggingFace Transformers](https://github.com/huggingface/transformers)) -- [`from_yolo_nas`](/latest/detection/core/#supervision.detection.core.Detections.from_yolo_nas) ([YOLO-NAS](https://github.com/Deci-AI/super-gradients/blob/master/YOLONAS.md)) +- [`from_deepsparse`](detection/core/#supervision.detection.core.Detections.from_deepsparse) ([Deepsparse](https://github.com/neuralmagic/deepsparse)) +- [`from_detectron2`](detection/core/#supervision.detection.core.Detections.from_detectron2) ([Detectron2](https://github.com/facebookresearch/detectron2)) +- [`from_mmdetection`](detection/core/#supervision.detection.core.Detections.from_mmdetection) ([MMDetection](https://github.com/open-mmlab/mmdetection)) +- [`from_inference`](detection/core/#supervision.detection.core.Detections.from_inference) ([Roboflow Inference](https://github.com/roboflow/inference)) +- [`from_sam`](detection/core/#supervision.detection.core.Detections.from_sam) ([Segment Anything Model](https://github.com/facebookresearch/segment-anything)) +- [`from_transformers`](detection/core/#supervision.detection.core.Detections.from_transformers) ([HuggingFace Transformers](https://github.com/huggingface/transformers)) +- [`from_yolo_nas`](detection/core/#supervision.detection.core.Detections.from_yolo_nas) ([YOLO-NAS](https://github.com/Deci-AI/super-gradients/blob/master/YOLONAS.md)) ## Annotate Image -Finally, we can annotate the image with the predictions. Since we are working with an object detection model, we will use the [`sv.BoundingBoxAnnotator`](/latest/annotators/#supervision.annotators.core.BoundingBoxAnnotator) and [`sv.LabelAnnotator`](/latest/annotators/#supervision.annotators.core.LabelAnnotator) classes. If you are running the segmentation model [`sv.MaskAnnotator`](/latest/annotators/#supervision.annotators.core.MaskAnnotator) is a drop-in replacement for [`sv.BoundingBoxAnnotator`](/latest/annotators/#supervision.annotators.core.BoundingBoxAnnotator) that will allow you to draw masks instead of boxes. +Finally, we can annotate the image with the predictions. Since we are working with an object detection model, we will use the [`sv.BoundingBoxAnnotator`](annotators/#supervision.annotators.core.BoundingBoxAnnotator) and [`sv.LabelAnnotator`](annotators/#supervision.annotators.core.LabelAnnotator) classes. If you are running the segmentation model [`sv.MaskAnnotator`](annotators/#supervision.annotators.core.MaskAnnotator) is a drop-in replacement for [`sv.BoundingBoxAnnotator`](annotators/#supervision.annotators.core.BoundingBoxAnnotator) that will allow you to draw masks instead of boxes. === "Ultralytics" @@ -138,7 +138,7 @@ Finally, we can annotate the image with the predictions. Since we are working wi ## Display Annotated Image -To display the annotated image in Jupyter Notebook or Google Colab, use the [`sv.plot_image`](/latest/utils/notebook/#supervision.utils.notebook.plot_image) function. +To display the annotated image in Jupyter Notebook or Google Colab, use the [`sv.plot_image`](utils/notebook/#supervision.utils.notebook.plot_image) function. ```python sv.plot_image(annotated_image) diff --git a/docs/javascript/cookbooks-card.js b/docs/javascript/cookbooks-card.js index 7a148916..cc9174ac 100644 --- a/docs/javascript/cookbooks-card.js +++ b/docs/javascript/cookbooks-card.js @@ -1,77 +1,118 @@ -window.addEventListener('DOMContentLoaded', async function () { - function setCard(el, name,desc,labels,version, theme) { +document.addEventListener("DOMContentLoaded", function () { - el.innerHTML = ` -
-
- - - ${name} - + async function setCard(el, name, desc, labels, version, theme, authors) { + const colorList = [ + "A351FB", "FF4040", "FFA1A0", "FF7633", "FFB633", "D1D435", "4CFB12", + "94CF1A", "40DE8A", "1B9640", "00D6C1", "2E9CAA", "00C4FF", "364797", + "6675FF", "0019EF", "863AFF", "530087", "CD3AFF", "FF97CA", "FF39C9" + ] + + let labelHTML = '' + if (labels) { + const labelArray = labels.split(',').map((label, index) => { + const color = colorList[index % colorList.length] + return `${label}` + }) + + labelHTML = labelArray.join(' ') + } + + const authorArray = authors.split(','); + const authorDataArray = await Promise.all(authorArray.map(async (author) => { + const response = await fetch(`https://api.github.com/users/${author.trim()}`); + return await response.json(); + })); + + let authorHTML = ''; + authorDataArray.forEach((authorData, index) => { + const marginLeft = index === 0 ? '0' : '-15px'; // Overlay images + const backgroundColor = theme === 'light-default' ? 'rgba(0, 0, 0, 0.5)' : 'rgba(255, 255, 255, 0.5)'; + const textColor = theme === 'light-default' ? '#fff' : '#000'; + authorHTML += ` +
+ + + + -
${desc}
-
-
-
-
+
+ `; + }); + + document.querySelectorAll('.author-container').forEach((container) => { + const tooltip = container.querySelector('.tooltip'); + container.addEventListener('mouseover', () => { + tooltip.style.visibility = 'visible'; + tooltip.style.opacity = '1'; + }); + container.addEventListener('mouseout', () => { + tooltip.style.visibility = 'hidden'; + tooltip.style.opacity = '0'; + }); + }); + + + + el.innerText = ` +
+
+ + + ${name} + +
+
${desc}
+
+ ${authorHTML} +
+
+
+
+
  ${version}
-
- -   ${labels} -
+
+   ${labelHTML}
- `; +
+ ` + + let sanitizedHTML = DOMPurify.sanitize(el.innerText); + el.innerHTML = sanitizedHTML; } const themes = { - 'light-default': { - background: 'white', - borderColor: '#e1e4e8', - color: '#586069', - linkColor: '#0366d6', - }, - 'dark-theme': { - background: '#1e2129', - borderColor: '#607D8B', - color: '#ECEFF1', - linkColor: '#9E9E9E', - } - }; + 'light-default': { + background: 'white', + borderColor: '#e1e4e8', + color: '#586069', + linkColor: '#0366d6', + }, + 'dark-theme': { + background: '#1e2129', + borderColor: '#607D8B', + color: '#ECEFF1', + linkColor: '#9E9E9E', + } + } for (const el of document.querySelectorAll('.repo-card')) { - const name = el.getAttribute('data-name'); - const desc = el.getAttribute('data-desc'); - const labels = el.getAttribute('data-labels'); - const version = el.getAttribute('data-version'); - const theme = themes[el.getAttribute('data-theme') || 'dark-theme']; - console.log(name, desc, labels, version, theme); // Check if the attributes are being read correctly + const name = el.getAttribute('data-name'); + const desc = el.getAttribute('data-desc'); + const labels = el.getAttribute('data-labels'); + const version = el.getAttribute('data-version'); + const authors = el.getAttribute('data-author'); + const palette = __md_get("__palette") + if (palette && typeof palette.color === "object") { + var theme = palette.color.scheme === "slate" ? "dark-theme" : "light-default" + } else { + var theme = "light-default" + } - setCard(el, name, desc, labels, version, theme); + setCard(el, name, desc, labels, version, theme,authors); } - - -}); - - -// listen to hash change -window.onhashchange = function() { - // get the new hash - var newHash = window.location.hash.substring(1); - // check if the new hash is the same as the old hash - if (newHash === oldHash) { - // if it is, it means the user clicked the back button - // so we can call the function that we want - // in this case, we want to close the modal - alert("Back button clicked"); - } else { - // if the new hash is different from the old hash - // it means the user clicked the back button - // so we can call the function that we want - // in this case, we want to open the modal - alert("Forward button clicked"); - } -} + }) diff --git a/docs/stylesheets/cookbooks.css b/docs/stylesheets/cookbooks.css index a45a3f8e..7d58d030 100644 --- a/docs/stylesheets/cookbooks.css +++ b/docs/stylesheets/cookbooks.css @@ -9,3 +9,11 @@ .md-typeset h1 { margin: 0 0 0.75rem; } + +.author-name { + opacity: 0; +} + +div:hover .author-name { + opacity: 1; +} diff --git a/docs/theme/cookbooks.html b/docs/theme/cookbooks.html index 831bd657..99501ab2 100644 --- a/docs/theme/cookbooks.html +++ b/docs/theme/cookbooks.html @@ -1,8 +1,8 @@ {% extends "main.html" %} {% block libs %} - - + + {% endblock %} {% block content %}
@@ -11,9 +11,9 @@

Supervision Cookbooks

-

-

-

+

+

+

diff --git a/docs/theme/main.html b/docs/theme/main.html index 6e645e24..c0c457ee 100644 --- a/docs/theme/main.html +++ b/docs/theme/main.html @@ -2,15 +2,15 @@ {% block content %} {% if page.nb_url %} - + {% endif %} {{ super() }} {% endblock content %} {% block extrahead %} - + {% endblock %} diff --git a/mkdocs.yml b/mkdocs.yml index 79e54150..7813e231 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -75,7 +75,6 @@ nav: - Deprecated: deprecated.md - License: license.md - Cookbooks: cookbooks.md - - Supervision: notebooks/demo.ipynb theme: @@ -86,7 +85,6 @@ theme: favicon: assets/supervision-lenny.png custom_dir: docs/theme features: - - navigation.instant - navigation.tracking - content.code.copy - content.action.edit