(
image: Float[Tensor, "channel height width"],
shape: Optional[tuple[int, int]] = None,
width: Optional[int] = None,
height: Optional[int] = None,
)
| 215 | |
| 216 | |
| 217 | def resize( |
| 218 | image: Float[Tensor, "channel height width"], |
| 219 | shape: Optional[tuple[int, int]] = None, |
| 220 | width: Optional[int] = None, |
| 221 | height: Optional[int] = None, |
| 222 | ) -> Float[Tensor, "channel new_height new_width"]: |
| 223 | assert (shape is not None) + (width is not None) + (height is not None) == 1 |
| 224 | _, h, w = image.shape |
| 225 | |
| 226 | if width is not None: |
| 227 | shape = (int(h * width / w), width) |
| 228 | elif height is not None: |
| 229 | shape = (height, int(w * height / h)) |
| 230 | |
| 231 | return F.interpolate( |
| 232 | image[None], |
| 233 | shape, |
| 234 | mode="bilinear", |
| 235 | align_corners=False, |
| 236 | antialias="bilinear", |
| 237 | )[0] |
| 238 | |
| 239 | |
| 240 | def draw_label( |
nothing calls this directly
no outgoing calls
no test coverage detected