Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e52989280a | ||
|
|
621f8e4d29 | ||
|
|
7a1c3149fd | ||
|
|
5467db4447 | ||
|
|
96bdcb3dea | ||
|
|
54278ea1f0 | ||
|
|
4e9aec6d2a | ||
|
|
db79350caa | ||
|
|
a6e0177cb9 | ||
|
|
d3968822a7 | ||
|
|
b06d979525 | ||
|
|
1ed782560d | ||
|
|
3c41c9721d | ||
|
|
e805212ae6 | ||
|
|
80567df1ea | ||
|
|
fab89d2374 | ||
|
|
a937fa5100 | ||
|
|
a298ceb18c | ||
|
|
c7c02bb4de | ||
|
|
a7debec87d | ||
|
|
b4b941fe1b | ||
|
|
3ddc4bd007 |
@@ -32,7 +32,7 @@ repos:
|
||||
additional_dependencies: ["bandit[toml]"]
|
||||
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.6.2
|
||||
rev: v0.6.3
|
||||
hooks:
|
||||
- id: ruff
|
||||
args: [--fix, --exit-non-zero-on-fix]
|
||||
|
||||
@@ -295,7 +295,7 @@ We love your input! Please see our [contributing guide](https://github.com/robof
|
||||
/>
|
||||
</a>
|
||||
<img src="https://raw.githubusercontent.com/ultralytics/assets/main/social/logo-transparent.png" width="3%"/>
|
||||
<a href="https://disuss.roboflow.com">
|
||||
<a href="https://discuss.roboflow.com">
|
||||
<img
|
||||
src="https://media.roboflow.com/notebooks/template/icons/purple/forum.png?ik-sdk-version=javascript-1.4.3&updatedAt=1672949633584"
|
||||
width="3%"
|
||||
|
||||
+1
-1
@@ -368,7 +368,7 @@
|
||||
"<br>\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"In the code above we've created a`video_info` variable to pass information about the video to our `VideoSink`. The `VideoSink` is a cool little context manager that allows us to `write_frames()` to a video ouput file. We're also optionally using `tqdm` to display a progress bar with a % complete. We only scratched the surface of all of the customizable Annotators and additional features that Supervision and Inference have to offer. Stay tuned for more cookbooks on how to take advantge of them in your computer vision applications. Happy building! \ud83d\ude80"
|
||||
"In the code above we've created a`video_info` variable to pass information about the video to our `VideoSink`. The `VideoSink` is a cool little context manager that allows us to `write_frames()` to a video output file. We're also optionally using `tqdm` to display a progress bar with a % complete. We only scratched the surface of all of the customizable Annotators and additional features that Supervision and Inference have to offer. Stay tuned for more cookbooks on how to take advantage of them in your computer vision applications. Happy building! \ud83d\ude80"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
+1
-1
@@ -402,7 +402,7 @@
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"source": [
|
||||
"## Improve Vizualizations"
|
||||
"## Improve Visualizations"
|
||||
],
|
||||
"metadata": {
|
||||
"id": "HsPNfuM_3ENR"
|
||||
|
||||
Vendored
+1
-1
@@ -103,7 +103,7 @@
|
||||
"source": [
|
||||
"## Download a Video Asset\n",
|
||||
"\n",
|
||||
"Now that we have our enviornment setup, lets download a video that we can detect objects in. Supervision comes with a great utility to help us hit the ground running. We can use the below snippet to he video is save a video asset in our local directory. It can also be accessed with the variable `path_to_video` for additional application logic."
|
||||
"Now that we have our environment setup, lets download a video that we can detect objects in. Supervision comes with a great utility to help us hit the ground running. We can use the below snippet to he video is save a video asset in our local directory. It can also be accessed with the variable `path_to_video` for additional application logic."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
+1
-1
@@ -951,7 +951,7 @@
|
||||
},
|
||||
"source": [
|
||||
"#### Import your data\n",
|
||||
"To load your data back in, upload the saved file to the Colab enviorment and run the code cell."
|
||||
"To load your data back in, upload the saved file to the Colab environment and run the code cell."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Generated
+47
-53
@@ -1577,13 +1577,13 @@ test = ["jupyter-server (>=2.0.0)", "pytest (>=7.0)", "pytest-jupyter[server] (>
|
||||
|
||||
[[package]]
|
||||
name = "jupyterlab"
|
||||
version = "4.2.4"
|
||||
version = "4.2.5"
|
||||
description = "JupyterLab computational environment"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "jupyterlab-4.2.4-py3-none-any.whl", hash = "sha256:807a7ec73637744f879e112060d4b9d9ebe028033b7a429b2d1f4fc523d00245"},
|
||||
{file = "jupyterlab-4.2.4.tar.gz", hash = "sha256:343a979fb9582fd08c8511823e320703281cd072a0049bcdafdc7afeda7f2537"},
|
||||
{file = "jupyterlab-4.2.5-py3-none-any.whl", hash = "sha256:73b6e0775d41a9fee7ee756c80f58a6bed4040869ccc21411dc559818874d321"},
|
||||
{file = "jupyterlab-4.2.5.tar.gz", hash = "sha256:ae7f3a1b8cb88b4f55009ce79fa7c06f99d70cd63601ee4aa91815d054f46f75"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
@@ -2130,13 +2130,13 @@ min-versions = ["babel (==2.9.0)", "click (==7.0)", "colorama (==0.4)", "ghp-imp
|
||||
|
||||
[[package]]
|
||||
name = "mkdocs-autorefs"
|
||||
version = "1.0.1"
|
||||
version = "1.2.0"
|
||||
description = "Automatically link across pages in MkDocs."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "mkdocs_autorefs-1.0.1-py3-none-any.whl", hash = "sha256:aacdfae1ab197780fb7a2dac92ad8a3d8f7ca8049a9cbe56a4218cd52e8da570"},
|
||||
{file = "mkdocs_autorefs-1.0.1.tar.gz", hash = "sha256:f684edf847eced40b570b57846b15f0bf57fb93ac2c510450775dcf16accb971"},
|
||||
{file = "mkdocs_autorefs-1.2.0-py3-none-any.whl", hash = "sha256:d588754ae89bd0ced0c70c06f58566a4ee43471eeeee5202427da7de9ef85a2f"},
|
||||
{file = "mkdocs_autorefs-1.2.0.tar.gz", hash = "sha256:a86b93abff653521bda71cf3fc5596342b7a23982093915cb74273f67522190f"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
@@ -2215,13 +2215,13 @@ pygments = ">2.12.0"
|
||||
|
||||
[[package]]
|
||||
name = "mkdocs-material"
|
||||
version = "9.5.33"
|
||||
version = "9.5.34"
|
||||
description = "Documentation that simply works"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "mkdocs_material-9.5.33-py3-none-any.whl", hash = "sha256:dbc79cf0fdc6e2c366aa987de8b0c9d4e2bb9f156e7466786ba2fd0f9bf7ffca"},
|
||||
{file = "mkdocs_material-9.5.33.tar.gz", hash = "sha256:d23a8b5e3243c9b2f29cdfe83051104a8024b767312dc8fde05ebe91ad55d89d"},
|
||||
{file = "mkdocs_material-9.5.34-py3-none-any.whl", hash = "sha256:54caa8be708de2b75167fd4d3b9f3d949579294f49cb242515d4653dbee9227e"},
|
||||
{file = "mkdocs_material-9.5.34.tar.gz", hash = "sha256:1e60ddf716cfb5679dfd65900b8a25d277064ed82d9a53cd5190e3f894df7840"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
@@ -2257,25 +2257,25 @@ files = [
|
||||
|
||||
[[package]]
|
||||
name = "mkdocstrings"
|
||||
version = "0.25.2"
|
||||
version = "0.26.0"
|
||||
description = "Automatic documentation from sources, for MkDocs."
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "mkdocstrings-0.25.2-py3-none-any.whl", hash = "sha256:9e2cda5e2e12db8bb98d21e3410f3f27f8faab685a24b03b06ba7daa5b92abfc"},
|
||||
{file = "mkdocstrings-0.25.2.tar.gz", hash = "sha256:5cf57ad7f61e8be3111a2458b4e49c2029c9cb35525393b179f9c916ca8042dc"},
|
||||
{file = "mkdocstrings-0.26.0-py3-none-any.whl", hash = "sha256:1aa227fe94f88e80737d37514523aacd473fc4b50a7f6852ce41447ab23f2654"},
|
||||
{file = "mkdocstrings-0.26.0.tar.gz", hash = "sha256:ff9d0de28c8fa877ed9b29a42fe407cfe6736d70a1c48177aa84fcc3dc8518cd"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
click = ">=7.0"
|
||||
importlib-metadata = {version = ">=4.6", markers = "python_version < \"3.10\""}
|
||||
Jinja2 = ">=2.11.1"
|
||||
Markdown = ">=3.3"
|
||||
Markdown = ">=3.6"
|
||||
MarkupSafe = ">=1.1"
|
||||
mkdocs = ">=1.4"
|
||||
mkdocs-autorefs = ">=0.3.1"
|
||||
mkdocs-autorefs = ">=1.2"
|
||||
mkdocstrings-python = {version = ">=0.5.2", optional = true, markers = "extra == \"python\""}
|
||||
platformdirs = ">=2.2.0"
|
||||
platformdirs = ">=2.2"
|
||||
pymdown-extensions = ">=6.3"
|
||||
typing-extensions = {version = ">=4.1", markers = "python_version < \"3.10\""}
|
||||
|
||||
@@ -2785,24 +2785,6 @@ files = [
|
||||
[package.dependencies]
|
||||
types-pytz = ">=2022.1.1"
|
||||
|
||||
[[package]]
|
||||
name = "pandas-stubs"
|
||||
version = "2.0.3.230814"
|
||||
description = "Type annotations for pandas"
|
||||
optional = true
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "pandas_stubs-2.0.3.230814-py3-none-any.whl", hash = "sha256:4b3dfc027d49779176b7daa031a3405f7b839bcb6e312f4b9f29fea5feec5b4f"},
|
||||
{file = "pandas_stubs-2.0.3.230814.tar.gz", hash = "sha256:1d5cc09e36e3d9f9a1ed9dceae4e03eeb26d1b898dd769996925f784365c8769"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
numpy = [
|
||||
{version = "<=1.24.3", markers = "python_full_version <= \"3.8.0\""},
|
||||
{version = ">=1.25.0", markers = "python_version >= \"3.9\""},
|
||||
]
|
||||
types-pytz = ">=2022.1.1"
|
||||
|
||||
[[package]]
|
||||
name = "pandocfilters"
|
||||
version = "1.5.1"
|
||||
@@ -3838,29 +3820,29 @@ files = [
|
||||
|
||||
[[package]]
|
||||
name = "ruff"
|
||||
version = "0.6.2"
|
||||
version = "0.6.3"
|
||||
description = "An extremely fast Python linter and code formatter, written in Rust."
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "ruff-0.6.2-py3-none-linux_armv6l.whl", hash = "sha256:5c8cbc6252deb3ea840ad6a20b0f8583caab0c5ef4f9cca21adc5a92b8f79f3c"},
|
||||
{file = "ruff-0.6.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:17002fe241e76544448a8e1e6118abecbe8cd10cf68fde635dad480dba594570"},
|
||||
{file = "ruff-0.6.2-py3-none-macosx_11_0_arm64.whl", hash = "sha256:3dbeac76ed13456f8158b8f4fe087bf87882e645c8e8b606dd17b0b66c2c1158"},
|
||||
{file = "ruff-0.6.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:094600ee88cda325988d3f54e3588c46de5c18dae09d683ace278b11f9d4d534"},
|
||||
{file = "ruff-0.6.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:316d418fe258c036ba05fbf7dfc1f7d3d4096db63431546163b472285668132b"},
|
||||
{file = "ruff-0.6.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:d72b8b3abf8a2d51b7b9944a41307d2f442558ccb3859bbd87e6ae9be1694a5d"},
|
||||
{file = "ruff-0.6.2-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:2aed7e243be68487aa8982e91c6e260982d00da3f38955873aecd5a9204b1d66"},
|
||||
{file = "ruff-0.6.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d371f7fc9cec83497fe7cf5eaf5b76e22a8efce463de5f775a1826197feb9df8"},
|
||||
{file = "ruff-0.6.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:a8f310d63af08f583363dfb844ba8f9417b558199c58a5999215082036d795a1"},
|
||||
{file = "ruff-0.6.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:7db6880c53c56addb8638fe444818183385ec85eeada1d48fc5abe045301b2f1"},
|
||||
{file = "ruff-0.6.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:1175d39faadd9a50718f478d23bfc1d4da5743f1ab56af81a2b6caf0a2394f23"},
|
||||
{file = "ruff-0.6.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:5b939f9c86d51635fe486585389f54582f0d65b8238e08c327c1534844b3bb9a"},
|
||||
{file = "ruff-0.6.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:d0d62ca91219f906caf9b187dea50d17353f15ec9bb15aae4a606cd697b49b4c"},
|
||||
{file = "ruff-0.6.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:7438a7288f9d67ed3c8ce4d059e67f7ed65e9fe3aa2ab6f5b4b3610e57e3cb56"},
|
||||
{file = "ruff-0.6.2-py3-none-win32.whl", hash = "sha256:279d5f7d86696df5f9549b56b9b6a7f6c72961b619022b5b7999b15db392a4da"},
|
||||
{file = "ruff-0.6.2-py3-none-win_amd64.whl", hash = "sha256:d9f3469c7dd43cd22eb1c3fc16926fb8258d50cb1b216658a07be95dd117b0f2"},
|
||||
{file = "ruff-0.6.2-py3-none-win_arm64.whl", hash = "sha256:f28fcd2cd0e02bdf739297516d5643a945cc7caf09bd9bcb4d932540a5ea4fa9"},
|
||||
{file = "ruff-0.6.2.tar.gz", hash = "sha256:239ee6beb9e91feb8e0ec384204a763f36cb53fb895a1a364618c6abb076b3be"},
|
||||
{file = "ruff-0.6.3-py3-none-linux_armv6l.whl", hash = "sha256:97f58fda4e309382ad30ede7f30e2791d70dd29ea17f41970119f55bdb7a45c3"},
|
||||
{file = "ruff-0.6.3-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:3b061e49b5cf3a297b4d1c27ac5587954ccb4ff601160d3d6b2f70b1622194dc"},
|
||||
{file = "ruff-0.6.3-py3-none-macosx_11_0_arm64.whl", hash = "sha256:34e2824a13bb8c668c71c1760a6ac7d795ccbd8d38ff4a0d8471fdb15de910b1"},
|
||||
{file = "ruff-0.6.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bddfbb8d63c460f4b4128b6a506e7052bad4d6f3ff607ebbb41b0aa19c2770d1"},
|
||||
{file = "ruff-0.6.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ced3eeb44df75353e08ab3b6a9e113b5f3f996bea48d4f7c027bc528ba87b672"},
|
||||
{file = "ruff-0.6.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:47021dff5445d549be954eb275156dfd7c37222acc1e8014311badcb9b4ec8c1"},
|
||||
{file = "ruff-0.6.3-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:7d7bd20dc07cebd68cc8bc7b3f5ada6d637f42d947c85264f94b0d1cd9d87384"},
|
||||
{file = "ruff-0.6.3-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:500f166d03fc6d0e61c8e40a3ff853fa8a43d938f5d14c183c612df1b0d6c58a"},
|
||||
{file = "ruff-0.6.3-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:42844ff678f9b976366b262fa2d1d1a3fe76f6e145bd92c84e27d172e3c34500"},
|
||||
{file = "ruff-0.6.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:70452a10eb2d66549de8e75f89ae82462159855e983ddff91bc0bce6511d0470"},
|
||||
{file = "ruff-0.6.3-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:65a533235ed55f767d1fc62193a21cbf9e3329cf26d427b800fdeacfb77d296f"},
|
||||
{file = "ruff-0.6.3-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:d2e2c23cef30dc3cbe9cc5d04f2899e7f5e478c40d2e0a633513ad081f7361b5"},
|
||||
{file = "ruff-0.6.3-py3-none-musllinux_1_2_i686.whl", hash = "sha256:d8a136aa7d228975a6aee3dd8bea9b28e2b43e9444aa678fb62aeb1956ff2351"},
|
||||
{file = "ruff-0.6.3-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:f92fe93bc72e262b7b3f2bba9879897e2d58a989b4714ba6a5a7273e842ad2f8"},
|
||||
{file = "ruff-0.6.3-py3-none-win32.whl", hash = "sha256:7a62d3b5b0d7f9143d94893f8ba43aa5a5c51a0ffc4a401aa97a81ed76930521"},
|
||||
{file = "ruff-0.6.3-py3-none-win_amd64.whl", hash = "sha256:746af39356fee2b89aada06c7376e1aa274a23493d7016059c3a72e3b296befb"},
|
||||
{file = "ruff-0.6.3-py3-none-win_arm64.whl", hash = "sha256:14a9528a8b70ccc7a847637c29e56fd1f9183a9db743bbc5b8e0c4ad60592a82"},
|
||||
{file = "ruff-0.6.3.tar.gz", hash = "sha256:183b99e9edd1ef63be34a3b51fee0a9f4ab95add123dbf89a71f7b1f0c991983"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -4232,6 +4214,17 @@ files = [
|
||||
{file = "types_python_dateutil-2.9.0.20240316-py3-none-any.whl", hash = "sha256:6b8cb66d960771ce5ff974e9dd45e38facb81718cc1e208b10b1baccbfdbee3b"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "types-pytz"
|
||||
version = "2024.1.0.20240417"
|
||||
description = "Typing stubs for pytz"
|
||||
optional = true
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "types-pytz-2024.1.0.20240417.tar.gz", hash = "sha256:6810c8a1f68f21fdf0f4f374a432487c77645a0ac0b31de4bf4690cf21ad3981"},
|
||||
{file = "types_pytz-2024.1.0.20240417-py3-none-any.whl", hash = "sha256:8335d443310e2db7b74e007414e74c4f53b67452c0cb0d228ca359ccfba59659"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "types-pyyaml"
|
||||
version = "6.0.12.20240808"
|
||||
@@ -4323,6 +4316,7 @@ optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "urllib3-2.2.2-py3-none-any.whl", hash = "sha256:a448b2f64d686155468037e1ace9f2d2199776e17f0a46610480d311f73e3472"},
|
||||
{file = "urllib3-2.2.2.tar.gz", hash = "sha256:dd505485549a7a552833da5e6063639d0d177c04f23bc3864e41e5dc5f612168"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
@@ -4513,4 +4507,4 @@ metrics = ["pandas", "pandas-stubs"]
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.8"
|
||||
content-hash = "84cd2523482606530c1b5dbe931d053dfd356e0c6e80c741ddc10ea7d808affd"
|
||||
content-hash = "ab1a7151a2f59ad9a820550fca7361d9817ff8260e8b6d527b198b09d98612e4"
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "supervision"
|
||||
version = "0.23.0"
|
||||
version = "0.24.0rc1"
|
||||
description = "A set of easy-to-use utils that will come in handy in any Computer Vision project"
|
||||
authors = ["Piotr Skalski <piotr.skalski92@gmail.com>"]
|
||||
maintainers = ["Piotr Skalski <piotr.skalski92@gmail.com>"]
|
||||
@@ -85,7 +85,7 @@ docutils = [
|
||||
|
||||
[tool.poetry.group.docs.dependencies]
|
||||
mkdocs-material = { extras = ["imaging"], version = "^9.5.5" }
|
||||
mkdocstrings = { extras = ["python"], version = "^0.25.2" }
|
||||
mkdocstrings = { extras = ["python"], version = ">=0.25.2,<0.27.0" }
|
||||
mike = "^2.0.0"
|
||||
# For Documentation Development use Python 3.10 or above
|
||||
# Use Latest mkdocs-jupyter min 0.24.6 for Jupyter Notebook Theme support
|
||||
|
||||
@@ -86,19 +86,10 @@ class MeanAveragePrecision(Metric):
|
||||
) -> MeanAveragePrecisionResult:
|
||||
"""
|
||||
Calculate Mean Average Precision based on predicted and ground-truth
|
||||
detections at different threshold.
|
||||
detections at different thresholds.
|
||||
|
||||
Args:
|
||||
predictions (List[np.ndarray]): Each element of the list describes
|
||||
a single image and has `shape = (M, 6)` where `M` is
|
||||
the number of detected objects. Each row is expected to be
|
||||
in `(x_min, y_min, x_max, y_max, class, conf)` format.
|
||||
targets (List[np.ndarray]): Each element of the list describes a single
|
||||
image and has `shape = (N, 5)` where `N` is the
|
||||
number of ground-truth objects. Each row is expected to be in
|
||||
`(x_min, y_min, x_max, y_max, class)` format.
|
||||
Returns:
|
||||
(MeanAveragePrecision): New instance of MeanAveragePrecision.
|
||||
(MeanAveragePrecisionResult): New instance of MeanAveragePrecision.
|
||||
|
||||
Example:
|
||||
```python
|
||||
@@ -219,7 +210,7 @@ class MeanAveragePrecision(Metric):
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def compute_average_precision(recall: np.ndarray, precision: np.ndarray) -> float:
|
||||
def _compute_average_precision(recall: np.ndarray, precision: np.ndarray) -> float:
|
||||
"""
|
||||
Compute the average precision using 101-point interpolation (COCO), given
|
||||
the recall and precision curves.
|
||||
@@ -231,16 +222,15 @@ class MeanAveragePrecision(Metric):
|
||||
Returns:
|
||||
(float): Average precision.
|
||||
"""
|
||||
extended_recall = np.concatenate(([0.0], recall, [1.0]))
|
||||
extended_precision = np.concatenate(([1.0], precision, [0.0]))
|
||||
max_accumulated_precision = np.flip(
|
||||
np.maximum.accumulate(np.flip(extended_precision))
|
||||
)
|
||||
interpolated_recall_levels = np.linspace(0, 1, 101)
|
||||
interpolated_precision = np.interp(
|
||||
interpolated_recall_levels, extended_recall, max_accumulated_precision
|
||||
)
|
||||
average_precision = np.trapz(interpolated_precision, interpolated_recall_levels)
|
||||
if len(recall) == 0 and len(precision) == 0:
|
||||
return 0.0
|
||||
|
||||
recall_levels = np.linspace(0, 1, 101)
|
||||
precision_levels = np.zeros_like(recall_levels)
|
||||
for r, p in zip(recall[::-1], precision[::-1]):
|
||||
precision_levels[recall_levels <= r] = p
|
||||
|
||||
average_precision = (1 / 100 * precision_levels).sum()
|
||||
return average_precision
|
||||
|
||||
@staticmethod
|
||||
@@ -316,14 +306,14 @@ class MeanAveragePrecision(Metric):
|
||||
|
||||
false_positives = (1 - matches[is_class]).cumsum(0)
|
||||
true_positives = matches[is_class].cumsum(0)
|
||||
true_negatives = total_true - true_positives
|
||||
false_negatives = total_true - true_positives
|
||||
|
||||
recall = true_positives / (true_positives + true_negatives + eps)
|
||||
recall = true_positives / (true_positives + false_negatives + eps)
|
||||
precision = true_positives / (true_positives + false_positives)
|
||||
|
||||
for iou_level_idx in range(matches.shape[1]):
|
||||
average_precisions[class_idx, iou_level_idx] = (
|
||||
MeanAveragePrecision.compute_average_precision(
|
||||
MeanAveragePrecision._compute_average_precision(
|
||||
recall[:, iou_level_idx], precision[:, iou_level_idx]
|
||||
)
|
||||
)
|
||||
|
||||
+20
-48
@@ -1,7 +1,6 @@
|
||||
from contextlib import ExitStack as DoesNotRaise
|
||||
from typing import List, Optional
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
|
||||
from supervision import DetectionDataset
|
||||
@@ -13,29 +12,29 @@ from test.test_utils import mock_detections
|
||||
[
|
||||
(
|
||||
[],
|
||||
DetectionDataset(classes=[], images={}, annotations={}),
|
||||
DetectionDataset(classes=[], images=[], annotations={}),
|
||||
DoesNotRaise(),
|
||||
), # empty dataset list
|
||||
(
|
||||
[DetectionDataset(classes=[], images={}, annotations={})],
|
||||
DetectionDataset(classes=[], images={}, annotations={}),
|
||||
[DetectionDataset(classes=[], images=[], annotations={})],
|
||||
DetectionDataset(classes=[], images=[], annotations={}),
|
||||
DoesNotRaise(),
|
||||
), # single empty dataset
|
||||
(
|
||||
[
|
||||
DetectionDataset(classes=["dog", "person"], images={}, annotations={}),
|
||||
DetectionDataset(classes=["dog", "person"], images={}, annotations={}),
|
||||
DetectionDataset(classes=["dog", "person"], images=[], annotations={}),
|
||||
DetectionDataset(classes=["dog", "person"], images=[], annotations={}),
|
||||
],
|
||||
DetectionDataset(classes=["dog", "person"], images={}, annotations={}),
|
||||
DetectionDataset(classes=["dog", "person"], images=[], annotations={}),
|
||||
DoesNotRaise(),
|
||||
), # two datasets; no images and annotations, the same classes
|
||||
(
|
||||
[
|
||||
DetectionDataset(classes=["dog", "person"], images={}, annotations={}),
|
||||
DetectionDataset(classes=["cat"], images={}, annotations={}),
|
||||
DetectionDataset(classes=["dog", "person"], images=[], annotations={}),
|
||||
DetectionDataset(classes=["cat"], images=[], annotations={}),
|
||||
],
|
||||
DetectionDataset(
|
||||
classes=["cat", "dog", "person"], images={}, annotations={}
|
||||
classes=["cat", "dog", "person"], images=[], annotations={}
|
||||
),
|
||||
DoesNotRaise(),
|
||||
), # two datasets; no images and annotations, different classes
|
||||
@@ -43,10 +42,7 @@ from test.test_utils import mock_detections
|
||||
[
|
||||
DetectionDataset(
|
||||
classes=["dog", "person"],
|
||||
images={
|
||||
"image-1.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
"image-2.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
},
|
||||
images=["image-1.png", "image-2.png"],
|
||||
annotations={
|
||||
"image-1.png": mock_detections(
|
||||
xyxy=[[0, 0, 10, 10]], class_id=[0]
|
||||
@@ -56,14 +52,11 @@ from test.test_utils import mock_detections
|
||||
),
|
||||
},
|
||||
),
|
||||
DetectionDataset(classes=[], images={}, annotations={}),
|
||||
DetectionDataset(classes=[], images=[], annotations={}),
|
||||
],
|
||||
DetectionDataset(
|
||||
classes=["dog", "person"],
|
||||
images={
|
||||
"image-1.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
"image-2.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
},
|
||||
images=["image-1.png", "image-2.png"],
|
||||
annotations={
|
||||
"image-1.png": mock_detections(xyxy=[[0, 0, 10, 10]], class_id=[0]),
|
||||
"image-2.png": mock_detections(xyxy=[[0, 0, 10, 10]], class_id=[1]),
|
||||
@@ -75,10 +68,7 @@ from test.test_utils import mock_detections
|
||||
[
|
||||
DetectionDataset(
|
||||
classes=["dog", "person"],
|
||||
images={
|
||||
"image-1.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
"image-2.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
},
|
||||
images=["image-1.png", "image-2.png"],
|
||||
annotations={
|
||||
"image-1.png": mock_detections(
|
||||
xyxy=[[0, 0, 10, 10]], class_id=[0]
|
||||
@@ -88,14 +78,11 @@ from test.test_utils import mock_detections
|
||||
),
|
||||
},
|
||||
),
|
||||
DetectionDataset(classes=["cat"], images={}, annotations={}),
|
||||
DetectionDataset(classes=["cat"], images=[], annotations={}),
|
||||
],
|
||||
DetectionDataset(
|
||||
classes=["cat", "dog", "person"],
|
||||
images={
|
||||
"image-1.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
"image-2.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
},
|
||||
images=["image-1.png", "image-2.png"],
|
||||
annotations={
|
||||
"image-1.png": mock_detections(xyxy=[[0, 0, 10, 10]], class_id=[1]),
|
||||
"image-2.png": mock_detections(xyxy=[[0, 0, 10, 10]], class_id=[2]),
|
||||
@@ -107,10 +94,7 @@ from test.test_utils import mock_detections
|
||||
[
|
||||
DetectionDataset(
|
||||
classes=["dog", "person"],
|
||||
images={
|
||||
"image-1.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
"image-2.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
},
|
||||
images=["image-1.png", "image-2.png"],
|
||||
annotations={
|
||||
"image-1.png": mock_detections(
|
||||
xyxy=[[0, 0, 10, 10]], class_id=[0]
|
||||
@@ -122,9 +106,7 @@ from test.test_utils import mock_detections
|
||||
),
|
||||
DetectionDataset(
|
||||
classes=["cat"],
|
||||
images={
|
||||
"image-3.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
},
|
||||
images=["image-3.png"],
|
||||
annotations={
|
||||
"image-3.png": mock_detections(
|
||||
xyxy=[[0, 0, 10, 10]], class_id=[0]
|
||||
@@ -134,11 +116,7 @@ from test.test_utils import mock_detections
|
||||
],
|
||||
DetectionDataset(
|
||||
classes=["cat", "dog", "person"],
|
||||
images={
|
||||
"image-1.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
"image-2.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
"image-3.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
},
|
||||
images=["image-1.png", "image-2.png", "image-3.png"],
|
||||
annotations={
|
||||
"image-1.png": mock_detections(xyxy=[[0, 0, 10, 10]], class_id=[1]),
|
||||
"image-2.png": mock_detections(xyxy=[[0, 0, 10, 10]], class_id=[2]),
|
||||
@@ -151,10 +129,7 @@ from test.test_utils import mock_detections
|
||||
[
|
||||
DetectionDataset(
|
||||
classes=["dog", "person"],
|
||||
images={
|
||||
"image-1.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
"image-2.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
},
|
||||
images=["image-1.png", "image-2.png"],
|
||||
annotations={
|
||||
"image-1.png": mock_detections(
|
||||
xyxy=[[0, 0, 10, 10]], class_id=[0]
|
||||
@@ -166,10 +141,7 @@ from test.test_utils import mock_detections
|
||||
),
|
||||
DetectionDataset(
|
||||
classes=["dog", "person"],
|
||||
images={
|
||||
"image-2.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
"image-3.png": np.zeros((100, 100, 3), dtype=np.uint8),
|
||||
},
|
||||
images=["image-2.png", "image-3.png"],
|
||||
annotations={
|
||||
"image-2.png": mock_detections(
|
||||
xyxy=[[0, 0, 10, 10]], class_id=[0]
|
||||
|
||||
@@ -278,7 +278,7 @@ def test_map_detections_class_id(
|
||||
np.array([[[]]]).astype(bool),
|
||||
None,
|
||||
pytest.raises(AssertionError),
|
||||
), # raises AssertionError because mask dimentionality is not 2D
|
||||
), # raises AssertionError because mask dimensionality is not 2D
|
||||
(
|
||||
np.array([[]]).astype(bool),
|
||||
None,
|
||||
|
||||
@@ -26,7 +26,6 @@ DETECTIONS = mock_detections(
|
||||
)
|
||||
|
||||
POLYGON = np.array([[100, 100], [200, 100], [200, 200], [100, 200]])
|
||||
FRAME_RESOLUTION = (300, 300)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -36,7 +35,6 @@ FRAME_RESOLUTION = (300, 300)
|
||||
DETECTIONS,
|
||||
sv.PolygonZone(
|
||||
POLYGON,
|
||||
FRAME_RESOLUTION,
|
||||
triggering_anchors=(
|
||||
sv.Position.TOP_LEFT,
|
||||
sv.Position.TOP_RIGHT,
|
||||
@@ -53,7 +51,6 @@ FRAME_RESOLUTION = (300, 300)
|
||||
DETECTIONS,
|
||||
sv.PolygonZone(
|
||||
POLYGON,
|
||||
FRAME_RESOLUTION,
|
||||
),
|
||||
np.array(
|
||||
[False, False, True, True, True, True, False, False, False], dtype=bool
|
||||
@@ -64,7 +61,6 @@ FRAME_RESOLUTION = (300, 300)
|
||||
DETECTIONS,
|
||||
sv.PolygonZone(
|
||||
POLYGON,
|
||||
FRAME_RESOLUTION,
|
||||
triggering_anchors=[sv.Position.BOTTOM_CENTER],
|
||||
),
|
||||
np.array(
|
||||
@@ -76,7 +72,6 @@ FRAME_RESOLUTION = (300, 300)
|
||||
sv.Detections.empty(),
|
||||
sv.PolygonZone(
|
||||
POLYGON,
|
||||
FRAME_RESOLUTION,
|
||||
),
|
||||
np.array([], dtype=bool),
|
||||
DoesNotRaise(),
|
||||
@@ -107,4 +102,4 @@ def test_polygon_zone_trigger(
|
||||
)
|
||||
def test_polygon_zone_initialization(polygon, triggering_anchors, exception):
|
||||
with exception:
|
||||
sv.PolygonZone(polygon, FRAME_RESOLUTION, triggering_anchors=triggering_anchors)
|
||||
sv.PolygonZone(polygon, triggering_anchors=triggering_anchors)
|
||||
|
||||
@@ -975,7 +975,7 @@ def test_get_data_item(
|
||||
),
|
||||
False,
|
||||
DoesNotRaise(),
|
||||
), # foreground object in 2 seperate elements
|
||||
), # foreground object in 2 separate elements
|
||||
(
|
||||
np.array([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]).astype(
|
||||
bool
|
||||
@@ -1032,7 +1032,7 @@ def test_contains_holes(
|
||||
4,
|
||||
True,
|
||||
DoesNotRaise(),
|
||||
), # foreground object in 2 seperate elements
|
||||
), # foreground object in 2 separate elements
|
||||
(
|
||||
np.array([[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]).astype(
|
||||
bool
|
||||
|
||||
Reference in New Issue
Block a user