prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Use Kornia resize in ResizePreprocessor in ObjectDetector
                Use Kornia resize in ResizePreprocessor
  
  _Originally posted by @edgarriba in https://github.com/kornia/kornia/pull/2363#discussion_r1257304346_
              
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `kornia/contrib/object_detection.py`
  Content:
  ```
  1 from __future__ import annotations
  2 
  3 from typing import Any
  4 
  5 import torch
  6 import torch.nn.functional as F
  7 
  8 from kornia.core import Module, Tensor, concatenate
  9 
  10 
  11 class ResizePreProcessor(Module):
  12     """This module resizes a list of image tensors to the given size, and also returns the original image sizes for
  13     further post-processing."""
  14 
  15     def __init__(self, size: int | tuple[int, int], interpolation_mode: str = "bilinear") -> None:
  16         """
  17         Args:
  18             size: images will be resized to this value. If a 2-integer tuple is given, it is interpreted as
  19                 (height, width). If an integer is given, images will be resized to a square.
  20             interpolation_mode: interpolation mode for image resizing. Supported values: ``nearest``, ``bilinear``,
  21                 ``bicubic``, ``area``, and ``nearest-exact``.
  22         """
  23         super().__init__()
  24         self.size = size
  25         self.interpolation_mode = interpolation_mode
  26 
  27     def forward(self, imgs: list[Tensor]) -> tuple[Tensor, dict[str, Any]]:
  28         # TODO: support other input formats e.g. file path, numpy
  29         # NOTE: antialias=False is used in F.interpolate()
  30         original_sizes = [(img.shape[1], img.shape[2]) for img in imgs]
  31         resized_imgs = [F.interpolate(img.unsqueeze(0), self.size, mode=self.interpolation_mode) for img in imgs]
  32         return concatenate(resized_imgs), {"original_size": original_sizes}
  33 
  34 
  35 class ObjectDetector:
  36     """This class wraps an object detection model and performs pre-processing and post-processing."""
  37 
  38     def __init__(self, model: Module, pre_processor: Module, post_processor: Module) -> None:
  39         """Construct an Object Detector object.
  40 
  41         Args:
  42             model: an object detection model.
  43             pre_processor: a pre-processing module
  44             post_processor: a post-processing module.
  45         """
  46         super().__init__()
  47         self.model = model.eval()
  48         self.pre_processor = pre_processor.eval()
  49         self.post_processor = post_processor.eval()
  50 
  51     @torch.inference_mode()
  52     def predict(self, imgs: list[Tensor]) -> list[Tensor]:
  53         """Detect objects in a given list of images.
  54 
  55         Args:
  56             imgs: list of RGB images. Each image is a Tensor with shape :math:`(3, H, W)`.
  57 
  58         Returns:
  59             list of detections found in each image. For item in a batch, shape is :math:`(D, 6)`, where :math:`D` is the
  60             number of detections in the given image, :math:`6` represents class id, score, and `xywh` bounding box.
  61         """
  62         imgs, meta = self.pre_processor(imgs)
  63         out = self.model(imgs)
  64         detections = self.post_processor(out, meta)
  65         return detections
  66 
  67     def compile(
  68         self,
  69         *,
  70         fullgraph: bool = False,
  71         dynamic: bool = False,
  72         backend: str = 'inductor',
  73         mode: str | None = None,
  74         options: dict[str, str | int | bool] | None = None,
  75         disable: bool = False,
  76     ) -> None:
  77         """Compile the internal object detection model with :py:func:`torch.compile()`."""
  78         self.model = torch.compile(  # type: ignore
  79             self.model,
  80             fullgraph=fullgraph,
  81             dynamic=dynamic,
  82             backend=backend,
  83             mode=mode,
  84             options=options,
  85             disable=disable,
  86         )
  87
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/kornia/contrib/object_detection.py b/kornia/contrib/object_detection.py
  --- a/kornia/contrib/object_detection.py
  +++ b/kornia/contrib/object_detection.py
  @@ -3,32 +3,32 @@
   from typing import Any
   
   import torch
  -import torch.nn.functional as F
   
   from kornia.core import Module, Tensor, concatenate
  +from kornia.geometry.transform import Resize
   
   
   class ResizePreProcessor(Module):
       """This module resizes a list of image tensors to the given size, and also returns the original image sizes for
       further post-processing."""
   
  -    def __init__(self, size: int | tuple[int, int], interpolation_mode: str = "bilinear") -> None:
  +    def __init__(self, size: tuple[int, int], interpolation_mode: str = "bilinear") -> None:
           """
           Args:
               size: images will be resized to this value. If a 2-integer tuple is given, it is interpreted as
  -                (height, width). If an integer is given, images will be resized to a square.
  +                (height, width).
               interpolation_mode: interpolation mode for image resizing. Supported values: ``nearest``, ``bilinear``,
                   ``bicubic``, ``area``, and ``nearest-exact``.
           """
           super().__init__()
           self.size = size
  -        self.interpolation_mode = interpolation_mode
  +        self.resizer = Resize(self.size, interpolation=interpolation_mode)
   
       def forward(self, imgs: list[Tensor]) -> tuple[Tensor, dict[str, Any]]:
           # TODO: support other input formats e.g. file path, numpy
           # NOTE: antialias=False is used in F.interpolate()
           original_sizes = [(img.shape[1], img.shape[2]) for img in imgs]
  -        resized_imgs = [F.interpolate(img.unsqueeze(0), self.size, mode=self.interpolation_mode) for img in imgs]
  +        resized_imgs = [self.resizer(img.unsqueeze(0)) for img in imgs]
           return concatenate(resized_imgs), {"original_size": original_sizes}
  
verification_info: {"golden_diff": "diff --git a/kornia/contrib/object_detection.py b/kornia/contrib/object_detection.py\n--- a/kornia/contrib/object_detection.py\n+++ b/kornia/contrib/object_detection.py\n@@ -3,32 +3,32 @@\n from typing import Any\n \n import torch\n-import torch.nn.functional as F\n \n from kornia.core import Module, Tensor, concatenate\n+from kornia.geometry.transform import Resize\n \n \n class ResizePreProcessor(Module):\n     \"\"\"This module resizes a list of image tensors to the given size, and also returns the original image sizes for\n     further post-processing.\"\"\"\n \n-    def __init__(self, size: int | tuple[int, int], interpolation_mode: str = \"bilinear\") -> None:\n+    def __init__(self, size: tuple[int, int], interpolation_mode: str = \"bilinear\") -> None:\n         \"\"\"\n         Args:\n             size: images will be resized to this value. If a 2-integer tuple is given, it is interpreted as\n-                (height, width). If an integer is given, images will be resized to a square.\n+                (height, width).\n             interpolation_mode: interpolation mode for image resizing. Supported values: ``nearest``, ``bilinear``,\n                 ``bicubic``, ``area``, and ``nearest-exact``.\n         \"\"\"\n         super().__init__()\n         self.size = size\n-        self.interpolation_mode = interpolation_mode\n+        self.resizer = Resize(self.size, interpolation=interpolation_mode)\n \n     def forward(self, imgs: list[Tensor]) -> tuple[Tensor, dict[str, Any]]:\n         # TODO: support other input formats e.g. file path, numpy\n         # NOTE: antialias=False is used in F.interpolate()\n         original_sizes = [(img.shape[1], img.shape[2]) for img in imgs]\n-        resized_imgs = [F.interpolate(img.unsqueeze(0), self.size, mode=self.interpolation_mode) for img in imgs]\n+        resized_imgs = [self.resizer(img.unsqueeze(0)) for img in imgs]\n         return concatenate(resized_imgs), {\"original_size\": original_sizes}\n", "issue": "Use Kornia resize in ResizePreprocessor in ObjectDetector\n              Use Kornia resize in ResizePreprocessor\r\n\r\n_Originally posted by @edgarriba in https://github.com/kornia/kornia/pull/2363#discussion_r1257304346_\r\n            \n", "before_files": [{"content": "from __future__ import annotations\n\nfrom typing import Any\n\nimport torch\nimport torch.nn.functional as F\n\nfrom kornia.core import Module, Tensor, concatenate\n\n\nclass ResizePreProcessor(Module):\n    \"\"\"This module resizes a list of image tensors to the given size, and also returns the original image sizes for\n    further post-processing.\"\"\"\n\n    def __init__(self, size: int | tuple[int, int], interpolation_mode: str = \"bilinear\") -> None:\n        \"\"\"\n        Args:\n            size: images will be resized to this value. If a 2-integer tuple is given, it is interpreted as\n                (height, width). If an integer is given, images will be resized to a square.\n            interpolation_mode: interpolation mode for image resizing. Supported values: ``nearest``, ``bilinear``,\n                ``bicubic``, ``area``, and ``nearest-exact``.\n        \"\"\"\n        super().__init__()\n        self.size = size\n        self.interpolation_mode = interpolation_mode\n\n    def forward(self, imgs: list[Tensor]) -> tuple[Tensor, dict[str, Any]]:\n        # TODO: support other input formats e.g. file path, numpy\n        # NOTE: antialias=False is used in F.interpolate()\n        original_sizes = [(img.shape[1], img.shape[2]) for img in imgs]\n        resized_imgs = [F.interpolate(img.unsqueeze(0), self.size, mode=self.interpolation_mode) for img in imgs]\n        return concatenate(resized_imgs), {\"original_size\": original_sizes}\n\n\nclass ObjectDetector:\n    \"\"\"This class wraps an object detection model and performs pre-processing and post-processing.\"\"\"\n\n    def __init__(self, model: Module, pre_processor: Module, post_processor: Module) -> None:\n        \"\"\"Construct an Object Detector object.\n\n        Args:\n            model: an object detection model.\n            pre_processor: a pre-processing module\n            post_processor: a post-processing module.\n        \"\"\"\n        super().__init__()\n        self.model = model.eval()\n        self.pre_processor = pre_processor.eval()\n        self.post_processor = post_processor.eval()\n\n    @torch.inference_mode()\n    def predict(self, imgs: list[Tensor]) -> list[Tensor]:\n        \"\"\"Detect objects in a given list of images.\n\n        Args:\n            imgs: list of RGB images. Each image is a Tensor with shape :math:`(3, H, W)`.\n\n        Returns:\n            list of detections found in each image. For item in a batch, shape is :math:`(D, 6)`, where :math:`D` is the\n            number of detections in the given image, :math:`6` represents class id, score, and `xywh` bounding box.\n        \"\"\"\n        imgs, meta = self.pre_processor(imgs)\n        out = self.model(imgs)\n        detections = self.post_processor(out, meta)\n        return detections\n\n    def compile(\n        self,\n        *,\n        fullgraph: bool = False,\n        dynamic: bool = False,\n        backend: str = 'inductor',\n        mode: str | None = None,\n        options: dict[str, str | int | bool] | None = None,\n        disable: bool = False,\n    ) -> None:\n        \"\"\"Compile the internal object detection model with :py:func:`torch.compile()`.\"\"\"\n        self.model = torch.compile(  # type: ignore\n            self.model,\n            fullgraph=fullgraph,\n            dynamic=dynamic,\n            backend=backend,\n            mode=mode,\n            options=options,\n            disable=disable,\n        )\n", "path": "kornia/contrib/object_detection.py"}], "after_files": [{"content": "from __future__ import annotations\n\nfrom typing import Any\n\nimport torch\n\nfrom kornia.core import Module, Tensor, concatenate\nfrom kornia.geometry.transform import Resize\n\n\nclass ResizePreProcessor(Module):\n    \"\"\"This module resizes a list of image tensors to the given size, and also returns the original image sizes for\n    further post-processing.\"\"\"\n\n    def __init__(self, size: tuple[int, int], interpolation_mode: str = \"bilinear\") -> None:\n        \"\"\"\n        Args:\n            size: images will be resized to this value. If a 2-integer tuple is given, it is interpreted as\n                (height, width).\n            interpolation_mode: interpolation mode for image resizing. Supported values: ``nearest``, ``bilinear``,\n                ``bicubic``, ``area``, and ``nearest-exact``.\n        \"\"\"\n        super().__init__()\n        self.size = size\n        self.resizer = Resize(self.size, interpolation=interpolation_mode)\n\n    def forward(self, imgs: list[Tensor]) -> tuple[Tensor, dict[str, Any]]:\n        # TODO: support other input formats e.g. file path, numpy\n        # NOTE: antialias=False is used in F.interpolate()\n        original_sizes = [(img.shape[1], img.shape[2]) for img in imgs]\n        resized_imgs = [self.resizer(img.unsqueeze(0)) for img in imgs]\n        return concatenate(resized_imgs), {\"original_size\": original_sizes}\n\n\nclass ObjectDetector:\n    \"\"\"This class wraps an object detection model and performs pre-processing and post-processing.\"\"\"\n\n    def __init__(self, model: Module, pre_processor: Module, post_processor: Module) -> None:\n        \"\"\"Construct an Object Detector object.\n\n        Args:\n            model: an object detection model.\n            pre_processor: a pre-processing module\n            post_processor: a post-processing module.\n        \"\"\"\n        super().__init__()\n        self.model = model.eval()\n        self.pre_processor = pre_processor.eval()\n        self.post_processor = post_processor.eval()\n\n    @torch.inference_mode()\n    def predict(self, imgs: list[Tensor]) -> list[Tensor]:\n        \"\"\"Detect objects in a given list of images.\n\n        Args:\n            imgs: list of RGB images. Each image is a Tensor with shape :math:`(3, H, W)`.\n\n        Returns:\n            list of detections found in each image. For item in a batch, shape is :math:`(D, 6)`, where :math:`D` is the\n            number of detections in the given image, :math:`6` represents class id, score, and `xywh` bounding box.\n        \"\"\"\n        imgs, meta = self.pre_processor(imgs)\n        out = self.model(imgs)\n        detections = self.post_processor(out, meta)\n        return detections\n\n    def compile(\n        self,\n        *,\n        fullgraph: bool = False,\n        dynamic: bool = False,\n        backend: str = 'inductor',\n        mode: str | None = None,\n        options: dict[str, str | int | bool] | None = None,\n        disable: bool = False,\n    ) -> None:\n        \"\"\"Compile the internal object detection model with :py:func:`torch.compile()`.\"\"\"\n        self.model = torch.compile(  # type: ignore\n            self.model,\n            fullgraph=fullgraph,\n            dynamic=dynamic,\n            backend=backend,\n            mode=mode,\n            options=options,\n            disable=disable,\n        )\n", "path": "kornia/contrib/object_detection.py"}]}