Merge pull request #1889 from roboflow/docs/mathjax

docs(supervision): configure mkdocs to add mathjax support
This commit is contained in:
Onuralp SEZER 2025-07-15 15:31:26 +03:00 committed by GitHub
commit 8a000b93b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 31 additions and 6 deletions

View File

@ -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()
})

View File

@ -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

View File

@ -94,8 +94,11 @@ def box_iou(
"""
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.
@ -123,7 +126,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)
@ -1566,8 +1569,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:
@ -1577,7 +1579,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)