From bcbbc578546c390fe763d82036a1b564af24716d Mon Sep 17 00:00:00 2001 From: soumik12345 <19soumik.rakshit96@gmail.com> Date: Tue, 15 Jul 2025 16:34:22 +0530 Subject: [PATCH 1/6] chore: configure mkdocs to add mathjax support --- docs/javascripts/mathjax.js | 19 +++++++++++++++++++ mkdocs.yml | 4 ++++ 2 files changed, 23 insertions(+) create mode 100644 docs/javascripts/mathjax.js diff --git a/docs/javascripts/mathjax.js b/docs/javascripts/mathjax.js new file mode 100644 index 00000000..160fedef --- /dev/null +++ b/docs/javascripts/mathjax.js @@ -0,0 +1,19 @@ +window.MathJax = { + tex: { + inlineMath: [["\\(", "\\)"]], + displayMath: [["\\[", "\\]"]], + processEscapes: true, + processEnvironments: true + }, + options: { + ignoreHtmlClass: ".*|", + processHtmlClass: "arithmatex" + } + }; + + document$.subscribe(() => { + MathJax.startup.output.clearCache() + MathJax.typesetClear() + MathJax.texReset() + MathJax.typesetPromise() + }) diff --git a/mkdocs.yml b/mkdocs.yml index dae49493..d3120939 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -168,12 +168,16 @@ markdown_extensions: anchor_linenums: true line_spans: __span pygments_lang_class: true + - pymdownx.arithmatex: + generic: true extra_javascript: - "javascripts/init_kapa_widget.js" - "javascripts/cookbooks-card.js" - "javascripts/segment.js" + - "javascripts/mathjax.js" - "https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.0.8/purify.min.js" + - "https://unpkg.com/mathjax@3/es5/tex-mml-chtml.js" # Messages shown during document build # Reference: https://www.mkdocs.org/user-guide/configuration/#validation From 9400270e34d49a851bf67a571c52da7403444ae3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 15 Jul 2025 11:05:26 +0000 Subject: [PATCH 2/6] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto=20?= =?UTF-8?q?format=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/javascripts/mathjax.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/javascripts/mathjax.js b/docs/javascripts/mathjax.js index 160fedef..0c7803cf 100644 --- a/docs/javascripts/mathjax.js +++ b/docs/javascripts/mathjax.js @@ -10,8 +10,8 @@ window.MathJax = { processHtmlClass: "arithmatex" } }; - - document$.subscribe(() => { + + document$.subscribe(() => { MathJax.startup.output.clearCache() MathJax.typesetClear() MathJax.texReset() From af31b96199df8b0cdd487a6531a6f95061519566 Mon Sep 17 00:00:00 2001 From: soumik12345 <19soumik.rakshit96@gmail.com> Date: Tue, 15 Jul 2025 16:41:54 +0530 Subject: [PATCH 3/6] update: docstring for box_iou to add formula --- supervision/detection/utils.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/supervision/detection/utils.py b/supervision/detection/utils.py index 13c3f1a6..733775e8 100644 --- a/supervision/detection/utils.py +++ b/supervision/detection/utils.py @@ -52,11 +52,14 @@ def box_iou( box_true: Union[List[float], np.ndarray], box_detection: Union[List[float], np.ndarray], ) -> float: - """ + r""" Compute the Intersection over Union (IoU) between two bounding boxes. - Both `box_true` and `box_detection` should be in (x_min, y_min, x_max, y_max) - format. + Mathematically, it is defined as: + + \[ + \text{IoU} = \frac{|\text{box}_{\text{true}} \cap \text{box}_{\text{detection}}|}{|\text{box}_{\text{true}} \cup \text{box}_{\text{detection}}|} + \] Note: Use `box_iou` when computing IoU between two individual boxes. @@ -1473,8 +1476,7 @@ def _jaccard(box_a: List[float], box_b: List[float], is_crowd: bool) -> float: """ Calculate the Jaccard index (intersection over union) between two bounding boxes. If a gt object is marked as "iscrowd", a dt is allowed to match any subregion - of the gt. Choosing gt' in the crowd gt that best matches the dt can be done using - gt'=intersect(dt,gt). Since by definition union(gt',dt)=dt, computing + of the gt. Choosing gt'=intersect(dt,gt). Since by definition union(gt',dt)=dt, computing iou(gt,dt,iscrowd) = iou(gt',dt) = area(intersect(gt,dt)) / area(dt) Args: From 7c1168fbc6d04b3cde4feb7b495905c4f92214ec Mon Sep 17 00:00:00 2001 From: soumik12345 <19soumik.rakshit96@gmail.com> Date: Tue, 15 Jul 2025 16:46:10 +0530 Subject: [PATCH 4/6] chore: make pre-commit happy --- supervision/detection/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/supervision/detection/utils.py b/supervision/detection/utils.py index 733775e8..0c017919 100644 --- a/supervision/detection/utils.py +++ b/supervision/detection/utils.py @@ -87,7 +87,7 @@ def box_iou( sv.box_iou(box_true=box_true, box_detection=box_detection) # 0.14285814285714285 ``` - """ + """ # noqa: E501 box_true = np.array(box_true) box_detection = np.array(box_detection) @@ -1486,7 +1486,7 @@ def _jaccard(box_a: List[float], box_b: List[float], is_crowd: bool) -> float: Returns: float: Jaccard index between the two bounding boxes. - """ + """ # noqa: E501 # Smallest number to avoid division by zero EPS = np.spacing(1) From 9f3ffdd26dafedbc3dcb8447d13dfc28fea6df2d Mon Sep 17 00:00:00 2001 From: Soumik Rakshit <19soumik.rakshit96@gmail.com> Date: Tue, 15 Jul 2025 17:17:39 +0530 Subject: [PATCH 5/6] fix: typo in utils.py --- supervision/detection/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supervision/detection/utils.py b/supervision/detection/utils.py index 0c017919..e0844b75 100644 --- a/supervision/detection/utils.py +++ b/supervision/detection/utils.py @@ -52,7 +52,7 @@ def box_iou( box_true: Union[List[float], np.ndarray], box_detection: Union[List[float], np.ndarray], ) -> float: - r""" + """ Compute the Intersection over Union (IoU) between two bounding boxes. Mathematically, it is defined as: From cf179b9dfe202ebab0be85e951131505f8f4dc71 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 15 Jul 2025 11:47:55 +0000 Subject: [PATCH 6/6] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto=20?= =?UTF-8?q?format=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supervision/detection/utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/supervision/detection/utils.py b/supervision/detection/utils.py index e0844b75..c485e891 100644 --- a/supervision/detection/utils.py +++ b/supervision/detection/utils.py @@ -57,9 +57,9 @@ def box_iou( Mathematically, it is defined as: - \[ - \text{IoU} = \frac{|\text{box}_{\text{true}} \cap \text{box}_{\text{detection}}|}{|\text{box}_{\text{true}} \cup \text{box}_{\text{detection}}|} - \] + \\[ + \text{IoU} = \frac{|\text{box}_{\text{true}} \\cap \text{box}_{\text{detection}}|}{|\text{box}_{\text{true}} \\cup \text{box}_{\text{detection}}|} + \\] Note: Use `box_iou` when computing IoU between two individual boxes.