|
2 | 2 | import pathlib
|
3 | 3 | import warnings
|
4 | 4 | from types import FunctionType
|
5 |
| -from typing import Any, Union, Optional, List, Tuple, BinaryIO |
| 5 | +from typing import Any, BinaryIO, List, Optional, Tuple, Union |
6 | 6 |
|
7 | 7 | import numpy as np
|
8 | 8 | import torch
|
9 |
| -from PIL import Image, ImageDraw, ImageFont, ImageColor |
| 9 | +from PIL import Image, ImageColor, ImageDraw, ImageFont |
10 | 10 |
|
11 | 11 | __all__ = ["make_grid", "save_image", "draw_bounding_boxes", "draw_segmentation_masks", "draw_keypoints"]
|
12 | 12 |
|
@@ -388,6 +388,23 @@ def _generate_color_palette(num_masks: int):
|
388 | 388 |
|
389 | 389 |
|
390 | 390 | def _log_api_usage_once(obj: Any) -> None:
|
| 391 | + |
| 392 | + """ |
| 393 | + Logs API usage(module and name) within an organization. |
| 394 | + In a large ecosystem, it's often useful to track the PyTorch and |
| 395 | + TorchVision APIs usage. This API provides the similar functionality to the |
| 396 | + logging module in the Python stdlib. It can be used for debugging purpose |
| 397 | + to log which methods are used and by default it is inactive, unless the user |
| 398 | + manually subscribes a logger via the `SetAPIUsageLogger method <https://github.com/pytorch/pytorch/blob/eb3b9fe719b21fae13c7a7cf3253f970290a573e/c10/util/Logging.cpp#L114>`_. |
| 399 | + Please note it is triggered only once for the same API call within a process. |
| 400 | + It does not collect any data from open-source users since it is no-op by default. |
| 401 | + For more information, please refer to |
| 402 | + * PyTorch note: https://pytorch.org/docs/stable/notes/large_scale_deployments.html#api-usage-logging; |
| 403 | + * Logging policy: https://github.com/pytorch/vision/issues/5052; |
| 404 | +
|
| 405 | + Args: |
| 406 | + obj (class instance or method): an object to extract info from. |
| 407 | + """ |
391 | 408 | if not obj.__module__.startswith("torchvision"):
|
392 | 409 | return
|
393 | 410 | name = obj.__class__.__name__
|
|
0 commit comments