object_detection.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. # LICENSE HEADER MANAGED BY add-license-header
  2. #
  3. # Copyright 2018 Kornia Team
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. from __future__ import annotations
  18. import warnings
  19. from typing import Any
  20. from kornia.models.detection.base import (
  21. BoundingBox as BoundingBoxBase,
  22. )
  23. from kornia.models.detection.base import (
  24. BoundingBoxDataFormat,
  25. )
  26. from kornia.models.detection.base import (
  27. ObjectDetector as ObjectDetectorBase,
  28. )
  29. from kornia.models.detection.base import (
  30. ObjectDetectorResult as ObjectDetectorResultBase,
  31. )
  32. from kornia.models.detection.base import (
  33. results_from_detections as results_from_detections_base,
  34. )
  35. from kornia.models.utils import ResizePreProcessor as ResizePreProcessorBase
  36. __all__ = [
  37. "BoundingBox",
  38. "BoundingBoxDataFormat",
  39. "ObjectDetector",
  40. "ObjectDetectorResult",
  41. "ResizePreProcessor",
  42. "results_from_detections",
  43. ]
  44. class BoundingBox(BoundingBoxBase):
  45. def __init__(self, *args: Any, **kwargs: Any) -> None:
  46. super().__init__(*args, **kwargs)
  47. warnings.warn(
  48. "BoundingBox is deprecated and will be removed in v0.8.0. Use kornia.models.detection.BoundingBox instead.",
  49. DeprecationWarning,
  50. stacklevel=1,
  51. )
  52. def results_from_detections(*args: Any, **kwargs: Any) -> list[ObjectDetectorResultBase]:
  53. """Return detector results."""
  54. warnings.warn(
  55. "results_from_detections is deprecated and will be removed in v0.8.0. "
  56. "Use kornia.models.detection.results_from_detections instead.",
  57. DeprecationWarning,
  58. stacklevel=1,
  59. )
  60. return results_from_detections_base(*args, **kwargs)
  61. class ResizePreProcessor(ResizePreProcessorBase):
  62. def __init__(self, *args: Any, **kwargs: Any) -> None:
  63. super().__init__(*args, **kwargs)
  64. warnings.warn(
  65. "ResizePreProcessor is deprecated and will be removed in v0.8.0. "
  66. "Use kornia.models.utils.ResizePreProcessor instead.",
  67. DeprecationWarning,
  68. stacklevel=1,
  69. )
  70. class ObjectDetector(ObjectDetectorBase):
  71. def __init__(self, *args: Any, **kwargs: Any) -> None:
  72. super().__init__(*args, **kwargs)
  73. warnings.warn(
  74. "ObjectDetector is deprecated and will be removed in v0.8.0. "
  75. "Use kornia.models.detection.ObjectDetector instead.",
  76. DeprecationWarning,
  77. stacklevel=1,
  78. )
  79. class ObjectDetectorResult(ObjectDetectorResultBase):
  80. def __init__(self, *args: Any, **kwargs: Any) -> None:
  81. super().__init__(*args, **kwargs)
  82. warnings.warn(
  83. "ObjectDetectorResult is deprecated and will be removed in v0.8.0. "
  84. "Use kornia.models.detection.ObjectDetectorResult instead.",
  85. DeprecationWarning,
  86. stacklevel=1,
  87. )