We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
shape check of impad function
In this [line](https://github.com/open-mmlab/mmcv/blob/8829ff0dfd9b9c9484cbce17f5cecd1128b61723/mmcv/image/transforms/geometry.py#L182):
Instead of `for i in range(len(shape) - 1):
         assert shape[i] >= img.shape[i]`
Should it be
`for i in range(len(shape)):
        assert shape[i] >= img.shape[i]`
to ensure all input shape dimensions equal or less than pad shape?

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mmcv/image/transforms/geometry.py`
Content:
```
1 # Copyright (c) Open-MMLab. All rights reserved.
2 from __future__ import division
3 
4 import cv2
5 import numpy as np
6 
7 
8 def imflip(img, direction='horizontal'):
9     """Flip an image horizontally or vertically.
10 
11     Args:
12         img (ndarray): Image to be flipped.
13         direction (str): The flip direction, either "horizontal" or "vertical".
14 
15     Returns:
16         ndarray: The flipped image.
17     """
18     assert direction in ['horizontal', 'vertical']
19     if direction == 'horizontal':
20         return np.flip(img, axis=1)
21     else:
22         return np.flip(img, axis=0)
23 
24 
25 def imrotate(img,
26              angle,
27              center=None,
28              scale=1.0,
29              border_value=0,
30              auto_bound=False):
31     """Rotate an image.
32 
33     Args:
34         img (ndarray): Image to be rotated.
35         angle (float): Rotation angle in degrees, positive values mean
36             clockwise rotation.
37         center (tuple): Center of the rotation in the source image, by default
38             it is the center of the image.
39         scale (float): Isotropic scale factor.
40         border_value (int): Border value.
41         auto_bound (bool): Whether to adjust the image size to cover the whole
42             rotated image.
43 
44     Returns:
45         ndarray: The rotated image.
46     """
47     if center is not None and auto_bound:
48         raise ValueError('`auto_bound` conflicts with `center`')
49     h, w = img.shape[:2]
50     if center is None:
51         center = ((w - 1) * 0.5, (h - 1) * 0.5)
52     assert isinstance(center, tuple)
53 
54     matrix = cv2.getRotationMatrix2D(center, -angle, scale)
55     if auto_bound:
56         cos = np.abs(matrix[0, 0])
57         sin = np.abs(matrix[0, 1])
58         new_w = h * sin + w * cos
59         new_h = h * cos + w * sin
60         matrix[0, 2] += (new_w - w) * 0.5
61         matrix[1, 2] += (new_h - h) * 0.5
62         w = int(np.round(new_w))
63         h = int(np.round(new_h))
64     rotated = cv2.warpAffine(img, matrix, (w, h), borderValue=border_value)
65     return rotated
66 
67 
68 def bbox_clip(bboxes, img_shape):
69     """Clip bboxes to fit the image shape.
70 
71     Args:
72         bboxes (ndarray): Shape (..., 4*k)
73         img_shape (tuple): (height, width) of the image.
74 
75     Returns:
76         ndarray: Clipped bboxes.
77     """
78     assert bboxes.shape[-1] % 4 == 0
79     clipped_bboxes = np.empty_like(bboxes, dtype=bboxes.dtype)
80     clipped_bboxes[..., 0::2] = np.maximum(
81         np.minimum(bboxes[..., 0::2], img_shape[1] - 1), 0)
82     clipped_bboxes[..., 1::2] = np.maximum(
83         np.minimum(bboxes[..., 1::2], img_shape[0] - 1), 0)
84     return clipped_bboxes
85 
86 
87 def bbox_scaling(bboxes, scale, clip_shape=None):
88     """Scaling bboxes w.r.t the box center.
89 
90     Args:
91         bboxes (ndarray): Shape(..., 4).
92         scale (float): Scaling factor.
93         clip_shape (tuple, optional): If specified, bboxes that exceed the
94             boundary will be clipped according to the given shape (h, w).
95 
96     Returns:
97         ndarray: Scaled bboxes.
98     """
99     if float(scale) == 1.0:
100         scaled_bboxes = bboxes.copy()
101     else:
102         w = bboxes[..., 2] - bboxes[..., 0] + 1
103         h = bboxes[..., 3] - bboxes[..., 1] + 1
104         dw = (w * (scale - 1)) * 0.5
105         dh = (h * (scale - 1)) * 0.5
106         scaled_bboxes = bboxes + np.stack((-dw, -dh, dw, dh), axis=-1)
107     if clip_shape is not None:
108         return bbox_clip(scaled_bboxes, clip_shape)
109     else:
110         return scaled_bboxes
111 
112 
113 def imcrop(img, bboxes, scale=1.0, pad_fill=None):
114     """Crop image patches.
115 
116     3 steps: scale the bboxes -> clip bboxes -> crop and pad.
117 
118     Args:
119         img (ndarray): Image to be cropped.
120         bboxes (ndarray): Shape (k, 4) or (4, ), location of cropped bboxes.
121         scale (float, optional): Scale ratio of bboxes, the default value
122             1.0 means no padding.
123         pad_fill (number or list): Value to be filled for padding, None for
124             no padding.
125 
126     Returns:
127         list or ndarray: The cropped image patches.
128     """
129     chn = 1 if img.ndim == 2 else img.shape[2]
130     if pad_fill is not None:
131         if isinstance(pad_fill, (int, float)):
132             pad_fill = [pad_fill for _ in range(chn)]
133         assert len(pad_fill) == chn
134 
135     _bboxes = bboxes[None, ...] if bboxes.ndim == 1 else bboxes
136     scaled_bboxes = bbox_scaling(_bboxes, scale).astype(np.int32)
137     clipped_bbox = bbox_clip(scaled_bboxes, img.shape)
138 
139     patches = []
140     for i in range(clipped_bbox.shape[0]):
141         x1, y1, x2, y2 = tuple(clipped_bbox[i, :])
142         if pad_fill is None:
143             patch = img[y1:y2 + 1, x1:x2 + 1, ...]
144         else:
145             _x1, _y1, _x2, _y2 = tuple(scaled_bboxes[i, :])
146             if chn == 1:
147                 patch_shape = (_y2 - _y1 + 1, _x2 - _x1 + 1)
148             else:
149                 patch_shape = (_y2 - _y1 + 1, _x2 - _x1 + 1, chn)
150             patch = np.array(
151                 pad_fill, dtype=img.dtype) * np.ones(
152                     patch_shape, dtype=img.dtype)
153             x_start = 0 if _x1 >= 0 else -_x1
154             y_start = 0 if _y1 >= 0 else -_y1
155             w = x2 - x1 + 1
156             h = y2 - y1 + 1
157             patch[y_start:y_start + h, x_start:x_start + w,
158                   ...] = img[y1:y1 + h, x1:x1 + w, ...]
159         patches.append(patch)
160 
161     if bboxes.ndim == 1:
162         return patches[0]
163     else:
164         return patches
165 
166 
167 def impad(img, shape, pad_val=0):
168     """Pad an image to a certain shape.
169 
170     Args:
171         img (ndarray): Image to be padded.
172         shape (tuple): Expected padding shape.
173         pad_val (number or sequence): Values to be filled in padding areas.
174 
175     Returns:
176         ndarray: The padded image.
177     """
178     if not isinstance(pad_val, (int, float)):
179         assert len(pad_val) == img.shape[-1]
180     if len(shape) < len(img.shape):
181         shape = shape + (img.shape[-1], )
182     assert len(shape) == len(img.shape)
183     for i in range(len(shape) - 1):
184         assert shape[i] >= img.shape[i]
185     pad = np.empty(shape, dtype=img.dtype)
186     pad[...] = pad_val
187     pad[:img.shape[0], :img.shape[1], ...] = img
188     return pad
189 
190 
191 def impad_to_multiple(img, divisor, pad_val=0):
192     """Pad an image to ensure each edge to be multiple to some number.
193 
194     Args:
195         img (ndarray): Image to be padded.
196         divisor (int): Padded image edges will be multiple to divisor.
197         pad_val (number or sequence): Same as :func:`impad`.
198 
199     Returns:
200         ndarray: The padded image.
201     """
202     pad_h = int(np.ceil(img.shape[0] / divisor)) * divisor
203     pad_w = int(np.ceil(img.shape[1] / divisor)) * divisor
204     return impad(img, (pad_h, pad_w), pad_val)
205
```

Path: `mmcv/version.py`
Content:
```
1 # Copyright (c) Open-MMLab. All rights reserved.
2 __version__ = '0.2.15'
3
```
--- 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()

```

diff --git a/mmcv/image/transforms/geometry.py b/mmcv/image/transforms/geometry.py
--- a/mmcv/image/transforms/geometry.py
+++ b/mmcv/image/transforms/geometry.py
@@ -180,7 +180,7 @@
     if len(shape) < len(img.shape):
         shape = shape + (img.shape[-1], )
     assert len(shape) == len(img.shape)
-    for i in range(len(shape) - 1):
+    for i in range(len(shape)):
         assert shape[i] >= img.shape[i]
     pad = np.empty(shape, dtype=img.dtype)
     pad[...] = pad_val
diff --git a/mmcv/version.py b/mmcv/version.py
--- a/mmcv/version.py
+++ b/mmcv/version.py
@@ -1,2 +1,2 @@
 # Copyright (c) Open-MMLab. All rights reserved.
-__version__ = '0.2.15'
+__version__ = '0.2.16'

{"golden_diff": "diff --git a/mmcv/image/transforms/geometry.py b/mmcv/image/transforms/geometry.py\n--- a/mmcv/image/transforms/geometry.py\n+++ b/mmcv/image/transforms/geometry.py\n@@ -180,7 +180,7 @@\n     if len(shape) < len(img.shape):\n         shape = shape + (img.shape[-1], )\n     assert len(shape) == len(img.shape)\n-    for i in range(len(shape) - 1):\n+    for i in range(len(shape)):\n         assert shape[i] >= img.shape[i]\n     pad = np.empty(shape, dtype=img.dtype)\n     pad[...] = pad_val\ndiff --git a/mmcv/version.py b/mmcv/version.py\n--- a/mmcv/version.py\n+++ b/mmcv/version.py\n@@ -1,2 +1,2 @@\n # Copyright (c) Open-MMLab. All rights reserved.\n-__version__ = '0.2.15'\n+__version__ = '0.2.16'\n", "issue": "shape check of impad function\nIn this [line](https://github.com/open-mmlab/mmcv/blob/8829ff0dfd9b9c9484cbce17f5cecd1128b61723/mmcv/image/transforms/geometry.py#L182):\r\nInstead of `for i in range(len(shape) - 1):\r\n         assert shape[i] >= img.shape[i]`\r\nShould it be\r\n`for i in range(len(shape)):\r\n        assert shape[i] >= img.shape[i]`\r\nto ensure all input shape dimensions equal or less than pad shape?\n", "before_files": [{"content": "# Copyright (c) Open-MMLab. All rights reserved.\nfrom __future__ import division\n\nimport cv2\nimport numpy as np\n\n\ndef imflip(img, direction='horizontal'):\n    \"\"\"Flip an image horizontally or vertically.\n\n    Args:\n        img (ndarray): Image to be flipped.\n        direction (str): The flip direction, either \"horizontal\" or \"vertical\".\n\n    Returns:\n        ndarray: The flipped image.\n    \"\"\"\n    assert direction in ['horizontal', 'vertical']\n    if direction == 'horizontal':\n        return np.flip(img, axis=1)\n    else:\n        return np.flip(img, axis=0)\n\n\ndef imrotate(img,\n             angle,\n             center=None,\n             scale=1.0,\n             border_value=0,\n             auto_bound=False):\n    \"\"\"Rotate an image.\n\n    Args:\n        img (ndarray): Image to be rotated.\n        angle (float): Rotation angle in degrees, positive values mean\n            clockwise rotation.\n        center (tuple): Center of the rotation in the source image, by default\n            it is the center of the image.\n        scale (float): Isotropic scale factor.\n        border_value (int): Border value.\n        auto_bound (bool): Whether to adjust the image size to cover the whole\n            rotated image.\n\n    Returns:\n        ndarray: The rotated image.\n    \"\"\"\n    if center is not None and auto_bound:\n        raise ValueError('`auto_bound` conflicts with `center`')\n    h, w = img.shape[:2]\n    if center is None:\n        center = ((w - 1) * 0.5, (h - 1) * 0.5)\n    assert isinstance(center, tuple)\n\n    matrix = cv2.getRotationMatrix2D(center, -angle, scale)\n    if auto_bound:\n        cos = np.abs(matrix[0, 0])\n        sin = np.abs(matrix[0, 1])\n        new_w = h * sin + w * cos\n        new_h = h * cos + w * sin\n        matrix[0, 2] += (new_w - w) * 0.5\n        matrix[1, 2] += (new_h - h) * 0.5\n        w = int(np.round(new_w))\n        h = int(np.round(new_h))\n    rotated = cv2.warpAffine(img, matrix, (w, h), borderValue=border_value)\n    return rotated\n\n\ndef bbox_clip(bboxes, img_shape):\n    \"\"\"Clip bboxes to fit the image shape.\n\n    Args:\n        bboxes (ndarray): Shape (..., 4*k)\n        img_shape (tuple): (height, width) of the image.\n\n    Returns:\n        ndarray: Clipped bboxes.\n    \"\"\"\n    assert bboxes.shape[-1] % 4 == 0\n    clipped_bboxes = np.empty_like(bboxes, dtype=bboxes.dtype)\n    clipped_bboxes[..., 0::2] = np.maximum(\n        np.minimum(bboxes[..., 0::2], img_shape[1] - 1), 0)\n    clipped_bboxes[..., 1::2] = np.maximum(\n        np.minimum(bboxes[..., 1::2], img_shape[0] - 1), 0)\n    return clipped_bboxes\n\n\ndef bbox_scaling(bboxes, scale, clip_shape=None):\n    \"\"\"Scaling bboxes w.r.t the box center.\n\n    Args:\n        bboxes (ndarray): Shape(..., 4).\n        scale (float): Scaling factor.\n        clip_shape (tuple, optional): If specified, bboxes that exceed the\n            boundary will be clipped according to the given shape (h, w).\n\n    Returns:\n        ndarray: Scaled bboxes.\n    \"\"\"\n    if float(scale) == 1.0:\n        scaled_bboxes = bboxes.copy()\n    else:\n        w = bboxes[..., 2] - bboxes[..., 0] + 1\n        h = bboxes[..., 3] - bboxes[..., 1] + 1\n        dw = (w * (scale - 1)) * 0.5\n        dh = (h * (scale - 1)) * 0.5\n        scaled_bboxes = bboxes + np.stack((-dw, -dh, dw, dh), axis=-1)\n    if clip_shape is not None:\n        return bbox_clip(scaled_bboxes, clip_shape)\n    else:\n        return scaled_bboxes\n\n\ndef imcrop(img, bboxes, scale=1.0, pad_fill=None):\n    \"\"\"Crop image patches.\n\n    3 steps: scale the bboxes -> clip bboxes -> crop and pad.\n\n    Args:\n        img (ndarray): Image to be cropped.\n        bboxes (ndarray): Shape (k, 4) or (4, ), location of cropped bboxes.\n        scale (float, optional): Scale ratio of bboxes, the default value\n            1.0 means no padding.\n        pad_fill (number or list): Value to be filled for padding, None for\n            no padding.\n\n    Returns:\n        list or ndarray: The cropped image patches.\n    \"\"\"\n    chn = 1 if img.ndim == 2 else img.shape[2]\n    if pad_fill is not None:\n        if isinstance(pad_fill, (int, float)):\n            pad_fill = [pad_fill for _ in range(chn)]\n        assert len(pad_fill) == chn\n\n    _bboxes = bboxes[None, ...] if bboxes.ndim == 1 else bboxes\n    scaled_bboxes = bbox_scaling(_bboxes, scale).astype(np.int32)\n    clipped_bbox = bbox_clip(scaled_bboxes, img.shape)\n\n    patches = []\n    for i in range(clipped_bbox.shape[0]):\n        x1, y1, x2, y2 = tuple(clipped_bbox[i, :])\n        if pad_fill is None:\n            patch = img[y1:y2 + 1, x1:x2 + 1, ...]\n        else:\n            _x1, _y1, _x2, _y2 = tuple(scaled_bboxes[i, :])\n            if chn == 1:\n                patch_shape = (_y2 - _y1 + 1, _x2 - _x1 + 1)\n            else:\n                patch_shape = (_y2 - _y1 + 1, _x2 - _x1 + 1, chn)\n            patch = np.array(\n                pad_fill, dtype=img.dtype) * np.ones(\n                    patch_shape, dtype=img.dtype)\n            x_start = 0 if _x1 >= 0 else -_x1\n            y_start = 0 if _y1 >= 0 else -_y1\n            w = x2 - x1 + 1\n            h = y2 - y1 + 1\n            patch[y_start:y_start + h, x_start:x_start + w,\n                  ...] = img[y1:y1 + h, x1:x1 + w, ...]\n        patches.append(patch)\n\n    if bboxes.ndim == 1:\n        return patches[0]\n    else:\n        return patches\n\n\ndef impad(img, shape, pad_val=0):\n    \"\"\"Pad an image to a certain shape.\n\n    Args:\n        img (ndarray): Image to be padded.\n        shape (tuple): Expected padding shape.\n        pad_val (number or sequence): Values to be filled in padding areas.\n\n    Returns:\n        ndarray: The padded image.\n    \"\"\"\n    if not isinstance(pad_val, (int, float)):\n        assert len(pad_val) == img.shape[-1]\n    if len(shape) < len(img.shape):\n        shape = shape + (img.shape[-1], )\n    assert len(shape) == len(img.shape)\n    for i in range(len(shape) - 1):\n        assert shape[i] >= img.shape[i]\n    pad = np.empty(shape, dtype=img.dtype)\n    pad[...] = pad_val\n    pad[:img.shape[0], :img.shape[1], ...] = img\n    return pad\n\n\ndef impad_to_multiple(img, divisor, pad_val=0):\n    \"\"\"Pad an image to ensure each edge to be multiple to some number.\n\n    Args:\n        img (ndarray): Image to be padded.\n        divisor (int): Padded image edges will be multiple to divisor.\n        pad_val (number or sequence): Same as :func:`impad`.\n\n    Returns:\n        ndarray: The padded image.\n    \"\"\"\n    pad_h = int(np.ceil(img.shape[0] / divisor)) * divisor\n    pad_w = int(np.ceil(img.shape[1] / divisor)) * divisor\n    return impad(img, (pad_h, pad_w), pad_val)\n", "path": "mmcv/image/transforms/geometry.py"}, {"content": "# Copyright (c) Open-MMLab. All rights reserved.\n__version__ = '0.2.15'\n", "path": "mmcv/version.py"}], "after_files": [{"content": "# Copyright (c) Open-MMLab. All rights reserved.\nfrom __future__ import division\n\nimport cv2\nimport numpy as np\n\n\ndef imflip(img, direction='horizontal'):\n    \"\"\"Flip an image horizontally or vertically.\n\n    Args:\n        img (ndarray): Image to be flipped.\n        direction (str): The flip direction, either \"horizontal\" or \"vertical\".\n\n    Returns:\n        ndarray: The flipped image.\n    \"\"\"\n    assert direction in ['horizontal', 'vertical']\n    if direction == 'horizontal':\n        return np.flip(img, axis=1)\n    else:\n        return np.flip(img, axis=0)\n\n\ndef imrotate(img,\n             angle,\n             center=None,\n             scale=1.0,\n             border_value=0,\n             auto_bound=False):\n    \"\"\"Rotate an image.\n\n    Args:\n        img (ndarray): Image to be rotated.\n        angle (float): Rotation angle in degrees, positive values mean\n            clockwise rotation.\n        center (tuple): Center of the rotation in the source image, by default\n            it is the center of the image.\n        scale (float): Isotropic scale factor.\n        border_value (int): Border value.\n        auto_bound (bool): Whether to adjust the image size to cover the whole\n            rotated image.\n\n    Returns:\n        ndarray: The rotated image.\n    \"\"\"\n    if center is not None and auto_bound:\n        raise ValueError('`auto_bound` conflicts with `center`')\n    h, w = img.shape[:2]\n    if center is None:\n        center = ((w - 1) * 0.5, (h - 1) * 0.5)\n    assert isinstance(center, tuple)\n\n    matrix = cv2.getRotationMatrix2D(center, -angle, scale)\n    if auto_bound:\n        cos = np.abs(matrix[0, 0])\n        sin = np.abs(matrix[0, 1])\n        new_w = h * sin + w * cos\n        new_h = h * cos + w * sin\n        matrix[0, 2] += (new_w - w) * 0.5\n        matrix[1, 2] += (new_h - h) * 0.5\n        w = int(np.round(new_w))\n        h = int(np.round(new_h))\n    rotated = cv2.warpAffine(img, matrix, (w, h), borderValue=border_value)\n    return rotated\n\n\ndef bbox_clip(bboxes, img_shape):\n    \"\"\"Clip bboxes to fit the image shape.\n\n    Args:\n        bboxes (ndarray): Shape (..., 4*k)\n        img_shape (tuple): (height, width) of the image.\n\n    Returns:\n        ndarray: Clipped bboxes.\n    \"\"\"\n    assert bboxes.shape[-1] % 4 == 0\n    clipped_bboxes = np.empty_like(bboxes, dtype=bboxes.dtype)\n    clipped_bboxes[..., 0::2] = np.maximum(\n        np.minimum(bboxes[..., 0::2], img_shape[1] - 1), 0)\n    clipped_bboxes[..., 1::2] = np.maximum(\n        np.minimum(bboxes[..., 1::2], img_shape[0] - 1), 0)\n    return clipped_bboxes\n\n\ndef bbox_scaling(bboxes, scale, clip_shape=None):\n    \"\"\"Scaling bboxes w.r.t the box center.\n\n    Args:\n        bboxes (ndarray): Shape(..., 4).\n        scale (float): Scaling factor.\n        clip_shape (tuple, optional): If specified, bboxes that exceed the\n            boundary will be clipped according to the given shape (h, w).\n\n    Returns:\n        ndarray: Scaled bboxes.\n    \"\"\"\n    if float(scale) == 1.0:\n        scaled_bboxes = bboxes.copy()\n    else:\n        w = bboxes[..., 2] - bboxes[..., 0] + 1\n        h = bboxes[..., 3] - bboxes[..., 1] + 1\n        dw = (w * (scale - 1)) * 0.5\n        dh = (h * (scale - 1)) * 0.5\n        scaled_bboxes = bboxes + np.stack((-dw, -dh, dw, dh), axis=-1)\n    if clip_shape is not None:\n        return bbox_clip(scaled_bboxes, clip_shape)\n    else:\n        return scaled_bboxes\n\n\ndef imcrop(img, bboxes, scale=1.0, pad_fill=None):\n    \"\"\"Crop image patches.\n\n    3 steps: scale the bboxes -> clip bboxes -> crop and pad.\n\n    Args:\n        img (ndarray): Image to be cropped.\n        bboxes (ndarray): Shape (k, 4) or (4, ), location of cropped bboxes.\n        scale (float, optional): Scale ratio of bboxes, the default value\n            1.0 means no padding.\n        pad_fill (number or list): Value to be filled for padding, None for\n            no padding.\n\n    Returns:\n        list or ndarray: The cropped image patches.\n    \"\"\"\n    chn = 1 if img.ndim == 2 else img.shape[2]\n    if pad_fill is not None:\n        if isinstance(pad_fill, (int, float)):\n            pad_fill = [pad_fill for _ in range(chn)]\n        assert len(pad_fill) == chn\n\n    _bboxes = bboxes[None, ...] if bboxes.ndim == 1 else bboxes\n    scaled_bboxes = bbox_scaling(_bboxes, scale).astype(np.int32)\n    clipped_bbox = bbox_clip(scaled_bboxes, img.shape)\n\n    patches = []\n    for i in range(clipped_bbox.shape[0]):\n        x1, y1, x2, y2 = tuple(clipped_bbox[i, :])\n        if pad_fill is None:\n            patch = img[y1:y2 + 1, x1:x2 + 1, ...]\n        else:\n            _x1, _y1, _x2, _y2 = tuple(scaled_bboxes[i, :])\n            if chn == 1:\n                patch_shape = (_y2 - _y1 + 1, _x2 - _x1 + 1)\n            else:\n                patch_shape = (_y2 - _y1 + 1, _x2 - _x1 + 1, chn)\n            patch = np.array(\n                pad_fill, dtype=img.dtype) * np.ones(\n                    patch_shape, dtype=img.dtype)\n            x_start = 0 if _x1 >= 0 else -_x1\n            y_start = 0 if _y1 >= 0 else -_y1\n            w = x2 - x1 + 1\n            h = y2 - y1 + 1\n            patch[y_start:y_start + h, x_start:x_start + w,\n                  ...] = img[y1:y1 + h, x1:x1 + w, ...]\n        patches.append(patch)\n\n    if bboxes.ndim == 1:\n        return patches[0]\n    else:\n        return patches\n\n\ndef impad(img, shape, pad_val=0):\n    \"\"\"Pad an image to a certain shape.\n\n    Args:\n        img (ndarray): Image to be padded.\n        shape (tuple): Expected padding shape.\n        pad_val (number or sequence): Values to be filled in padding areas.\n\n    Returns:\n        ndarray: The padded image.\n    \"\"\"\n    if not isinstance(pad_val, (int, float)):\n        assert len(pad_val) == img.shape[-1]\n    if len(shape) < len(img.shape):\n        shape = shape + (img.shape[-1], )\n    assert len(shape) == len(img.shape)\n    for i in range(len(shape)):\n        assert shape[i] >= img.shape[i]\n    pad = np.empty(shape, dtype=img.dtype)\n    pad[...] = pad_val\n    pad[:img.shape[0], :img.shape[1], ...] = img\n    return pad\n\n\ndef impad_to_multiple(img, divisor, pad_val=0):\n    \"\"\"Pad an image to ensure each edge to be multiple to some number.\n\n    Args:\n        img (ndarray): Image to be padded.\n        divisor (int): Padded image edges will be multiple to divisor.\n        pad_val (number or sequence): Same as :func:`impad`.\n\n    Returns:\n        ndarray: The padded image.\n    \"\"\"\n    pad_h = int(np.ceil(img.shape[0] / divisor)) * divisor\n    pad_w = int(np.ceil(img.shape[1] / divisor)) * divisor\n    return impad(img, (pad_h, pad_w), pad_val)\n", "path": "mmcv/image/transforms/geometry.py"}, {"content": "# Copyright (c) Open-MMLab. All rights reserved.\n__version__ = '0.2.16'\n", "path": "mmcv/version.py"}]}