Skip to content

Commit

Permalink
Detection IoU (#1284)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicki Skafte Detlefsen <skaftenicki@gmail.com>
Co-authored-by: Jirka Borovec <6035284+Borda@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Jirka <jirka.borovec@seznam.cz>
  • Loading branch information
6 people authored Apr 18, 2023
1 parent 7699f85 commit 25d347b
Show file tree
Hide file tree
Showing 25 changed files with 1,992 additions and 147 deletions.
130 changes: 68 additions & 62 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,70 +22,76 @@
//"--shm-size=4gb",
],
// Set *default* container specific settings.json values on container create.
"settings": {
"editor.formatOnSave": true,
"editor.rulers": [
120
],
"python.pythonPath": "/usr/local/bin/python",
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.languageServer": "Pylance",
"python.autoComplete.addBrackets": true,
"python.analysis.autoImportCompletions": true,
"python.analysis.completeFunctionParens": true,
"python.analysis.autoSearchPaths": true,
"python.analysis.useImportHeuristic": true,
"python.sortImports": true,
"python.sortImports.args": [
"--settings-path=${workspaceFolder}/pyproject.toml",
],
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"--config=${workspaceFolder}/pyproject.toml"
],
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint",
"python.linting.enabled": true,
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.flake8Args": [
"--config=${workspaceFolder}/setup.cfg",
"--verbose"
],
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"restructuredtext.confPath": "${workspaceFolder}/docs/source",
"restructuredtext.builtDocumentationPath": "${workspaceFolder}/docs/build",
"restructuredtext.languageServer.disabled": false,
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true,
}
"customizations": {
"vscode": {
"settings": {
"editor.formatOnSave": true,
"editor.rulers": [
120
],
"files.exclude": {
"**/__pycache__": true
},
"python.pythonPath": "/usr/local/bin/python",
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.languageServer": "Pylance",
"python.autoComplete.addBrackets": true,
"python.analysis.autoImportCompletions": true,
"python.analysis.completeFunctionParens": true,
"python.analysis.autoSearchPaths": true,
"python.analysis.useImportHeuristic": true,
"python.sortImports": true,
"isort.args": [
"--settings-path=${workspaceFolder}/pyproject.toml"
],
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.provider": "black",
"python.formatting.blackArgs": [
"--config=${workspaceFolder}/pyproject.toml"
],
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint",
"python.linting.enabled": true,
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.flake8Args": [
"--config=${workspaceFolder}/setup.cfg",
"--verbose"
],
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"esbonio.sphinx.confDir": "${workspaceFolder}/docs/source",
"esbonio.sphinx.buildDir": "${workspaceFolder}/docs/build",
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
}
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"visualstudioexptteam.vscodeintellicode",
"kevinrose.vsc-python-indent",
"littlefoxteam.vscode-python-test-adapter",
"hbenl.vscode-test-explorer",
"medo64.render-crlf",
"shardulm94.trailing-spaces",
"njqdev.vscode-python-typehint",
"lextudio.restructuredtext",
"trond-snekvik.simple-rst"
]
}
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"visualstudioexptteam.vscodeintellicode",
"kevinrose.vsc-python-indent",
"littlefoxteam.vscode-python-test-adapter",
"hbenl.vscode-test-explorer",
"medo64.render-crlf",
"shardulm94.trailing-spaces",
"njqdev.vscode-python-typehint",
"lextudio.restructuredtext",
"trond-snekvik.simple-rst",
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `PrecisionAtFixedRecall` metric to classification package ([#1683](https://github.com/Lightning-AI/torchmetrics/pull/1683))


- Added multiple metrics to detection package ([#1284](https://github.com/Lightning-AI/metrics/pull/1284))
* `IntersectionOverUnion`
* `GeneralizedIntersectionOverUnion`
* `CompleteIntersectionOverUnion`
* `DistanceIntersectionOverUnion`


### Changed

- Changed `update_count` and `update_called` from private to public methods ([#1370](https://github.com/Lightning-AI/metrics/pull/1370))
Expand Down
21 changes: 21 additions & 0 deletions docs/source/detection/complete_intersection_over_union.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. customcarditem::
:header: Complete Intersection Over Union (cIoU)
:image: https://pl-flash-data.s3.amazonaws.com/assets/thumbnails/object_detection.svg
:tags: Detection

#######################################
Complete Intersection Over Union (cIoU)
#######################################

Module Interface
________________

.. autoclass:: torchmetrics.detection.ciou.CompleteIntersectionOverUnion
:noindex:
:exclude-members: update, compute

Functional Interface
____________________

.. autofunction:: torchmetrics.functional.detection.ciou.complete_intersection_over_union
:noindex:
21 changes: 21 additions & 0 deletions docs/source/detection/distance_intersection_over_union.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. customcarditem::
:header: Distance Intersection Over Union (dIoU)
:image: https://pl-flash-data.s3.amazonaws.com/assets/thumbnails/object_detection.svg
:tags: Detection

#######################################
Distance Intersection Over Union (dIoU)
#######################################

Module Interface
________________

.. autoclass:: torchmetrics.detection.diou.DistanceIntersectionOverUnion
:noindex:
:exclude-members: update, compute

Functional Interface
____________________

.. autofunction:: torchmetrics.functional.detection.diou.distance_intersection_over_union
:noindex:
21 changes: 21 additions & 0 deletions docs/source/detection/generalized_intersection_over_union.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. customcarditem::
:header: Generalized Intersection Over Union (gIoU)
:image: https://pl-flash-data.s3.amazonaws.com/assets/thumbnails/object_detection.svg
:tags: Detection

##########################################
Generalized Intersection Over Union (gIoU)
##########################################

Module Interface
________________

.. autoclass:: torchmetrics.detection.giou.GeneralizedIntersectionOverUnion
:noindex:
:exclude-members: update, compute

Functional Interface
____________________

.. autofunction:: torchmetrics.functional.detection.giou.generalized_intersection_over_union
:noindex:
21 changes: 21 additions & 0 deletions docs/source/detection/intersection_over_union.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.. customcarditem::
:header: Intersection Over Union (IoU)
:image: https://pl-flash-data.s3.amazonaws.com/assets/thumbnails/object_detection.svg
:tags: Detection

#############################
Intersection Over Union (IoU)
#############################

Module Interface
________________

.. autoclass:: torchmetrics.detection.iou.IntersectionOverUnion
:noindex:
:exclude-members: update, compute

Functional Interface
____________________

.. autofunction:: torchmetrics.functional.detection.iou.intersection_over_union
:noindex:
18 changes: 15 additions & 3 deletions src/torchmetrics/detection/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from torchmetrics.detection.panoptic_qualities import ModifiedPanopticQuality, PanopticQuality
from torchmetrics.utilities.imports import _TORCHVISION_GREATER_EQUAL_0_8
from torchmetrics.utilities.imports import (
_TORCHVISION_AVAILABLE,
_TORCHVISION_GREATER_EQUAL_0_8,
_TORCHVISION_GREATER_EQUAL_0_13,
)

__all__ = ["ModifiedPanopticQuality", "PanopticQuality"]

if _TORCHVISION_GREATER_EQUAL_0_8:
from torchmetrics.detection.mean_ap import MeanAveragePrecision # noqa: F401
from torchmetrics.detection.giou import GeneralizedIntersectionOverUnion
from torchmetrics.detection.iou import IntersectionOverUnion
from torchmetrics.detection.mean_ap import MeanAveragePrecision

__all__.append("MeanAveragePrecision")
__all__ += ["MeanAveragePrecision", "GeneralizedIntersectionOverUnion", "IntersectionOverUnion"]

if _TORCHVISION_GREATER_EQUAL_0_13:
from torchmetrics.detection.ciou import CompleteIntersectionOverUnion
from torchmetrics.detection.diou import DistanceIntersectionOverUnion

__all__ += ["CompleteIntersectionOverUnion", "DistanceIntersectionOverUnion"]
Loading

0 comments on commit 25d347b

Please sign in to comment.