Skip to content

Commit c34a914

Browse files
authored
Add API usage calls to utils (#5077)
* Add API usage calls to utils * Update to the new api
1 parent 1b14829 commit c34a914

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

torchvision/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def make_grid(
4242
Returns:
4343
grid (Tensor): the tensor containing grid of images.
4444
"""
45+
_log_api_usage_once("utils", "make_grid")
4546
if not (torch.is_tensor(tensor) or (isinstance(tensor, list) and all(torch.is_tensor(t) for t in tensor))):
4647
raise TypeError(f"tensor or list of tensors expected, got {type(tensor)}")
4748

@@ -130,6 +131,7 @@ def save_image(
130131
**kwargs: Other arguments are documented in ``make_grid``.
131132
"""
132133

134+
_log_api_usage_once("utils", "save_image")
133135
grid = make_grid(tensor, **kwargs)
134136
# Add 0.5 after unnormalizing to [0, 255] to round to nearest integer
135137
ndarr = grid.mul(255).add_(0.5).clamp_(0, 255).permute(1, 2, 0).to("cpu", torch.uint8).numpy()
@@ -174,6 +176,7 @@ def draw_bounding_boxes(
174176
img (Tensor[C, H, W]): Image Tensor of dtype uint8 with bounding boxes plotted.
175177
"""
176178

179+
_log_api_usage_once("utils", "draw_bounding_boxes")
177180
if not isinstance(image, torch.Tensor):
178181
raise TypeError(f"Tensor expected, got {type(image)}")
179182
elif image.dtype != torch.uint8:
@@ -252,6 +255,7 @@ def draw_segmentation_masks(
252255
img (Tensor[C, H, W]): Image Tensor, with segmentation masks drawn on top.
253256
"""
254257

258+
_log_api_usage_once("utils", "draw_segmentation_masks")
255259
if not isinstance(image, torch.Tensor):
256260
raise TypeError(f"The image must be a tensor, got {type(image)}")
257261
elif image.dtype != torch.uint8:
@@ -329,6 +333,7 @@ def draw_keypoints(
329333
img (Tensor[C, H, W]): Image Tensor of dtype uint8 with keypoints drawn.
330334
"""
331335

336+
_log_api_usage_once("utils", "draw_keypoints")
332337
if not isinstance(image, torch.Tensor):
333338
raise TypeError(f"The image must be a tensor, got {type(image)}")
334339
elif image.dtype != torch.uint8:

0 commit comments

Comments
 (0)