PyTorch utilities.
Class |
|
Output processor for single label classifiers. |
Class |
|
Output processor for object detectors. |
Class |
|
Output processor for instance segementers. |
Class |
|
Output processor for keypoint detection models. |
Class |
|
Transform that resizes the PIL image or torch Tensor, if necessary, so that its maximum dimensions are at most the specified size. |
Class |
|
Transform that resizes the PIL image or torch Tensor, if necessary, so that its minimum dimensions are at least the specified size. |
Class |
|
Interface for processing the outputs of Torch models. |
Class |
|
Transform that center crops the PIL image or torch Tensor, if necessary, so that its dimensions are multiples of the specified patch size. |
Class |
|
Callback that saves the input/output tensor of the specified layer of a Torch model during each forward() call. |
Class |
|
Output processor for semantic segementers. |
Class |
|
Transform that converts a tensor or ndarray to a PIL image, while also allowing PIL images to passthrough. |
Class |
|
Mixin for Torch models that can generate embeddings. |
Class |
|
A torch:torch.utils.data.Dataset for image classification. |
Class |
|
A torch:torch.utils.data.Dataset of images. |
Class |
|
Wrapper for evaluating a Torch model on images. |
Class |
|
Configuration for running a TorchImageModel . |
Class |
|
A torch:torch.utils.data.Dataset of image patch tensors extracted from a list of images. |
Class |
|
Undocumented |
Function | ensure |
Verifies that the package requirements from the requirements.txt file on disk associated with a downloaded PyTorch Hub model are installed. |
Function | find |
Locates the requirements.txt file on disk associated with a downloaded PyTorch Hub model. |
Function | from |
Creates a torch:torch.utils.data.Dataset for the given image classification dataset directory tree. |
Function | install |
Installs the package requirements from the requirements.txt file on disk associated with a downloaded PyTorch Hub model. |
Function | load |
Loads an image model from PyTorch Hub as a TorchImageModel . |
Function | load |
Loads a raw model from PyTorch Hub as a torch:torch.nn.Module . |
Function | load |
Loads the package requirements from the requirements.txt file on disk associated with a downloaded PyTorch Hub model. |
Function | recommend |
Recommend a number of workers for running a torch:torch.utils.data.DataLoader . |
Variable | logger |
Undocumented |
Function | _is |
Undocumented |
Function | _load |
Undocumented |
Function | _polyline |
Undocumented |
Function | _polylines |
Undocumented |
Function | _strip |
Undocumented |
Function | _to |
Undocumented |
Function | _to |
Undocumented |
Verifies that the package requirements from the requirements.txt file on disk associated with a downloaded PyTorch Hub model are installed.
Example usage:
import fiftyone.utils.torch as fout fout.ensure_torch_hub_requirements("facebookresearch/dinov2")
Parameters | |
repo | see torch:torch.hub.load |
source:"github" | see torch:torch.hub.load |
errorNone | the error level to use, defined as:
By default, fiftyone.config.requirement_error_level is used |
logFalse | whether to generate a log message if a requirement is satisfied |
Locates the requirements.txt file on disk associated with a downloaded PyTorch Hub model.
Example usage:
import fiftyone.utils.torch as fout req_path = fout.find_torch_hub_requirements("facebookresearch/dinov2") print(req_path) # '~/.cache/torch/hub/facebookresearch_dinov2_main/requirements.txt'
Parameters | |
repo | see torch:torch.hub.load |
source:"github" | see torch:torch.hub.load |
Returns | |
the path to the requirements file on disk |
Creates a torch:torch.utils.data.Dataset
for the given image
classification dataset directory tree.
The directory should have the following format:
<dataset_dir>/ <classA>/ <image1>.<ext> <image2>.<ext> ... <classB>/ <image1>.<ext> <image2>.<ext> ...
Parameters | |
dataset | the dataset directory |
Returns | |
a torchvision:torchvision.datasets.ImageFolder |
Installs the package requirements from the requirements.txt file on disk associated with a downloaded PyTorch Hub model.
Example usage:
import fiftyone.utils.torch as fout fout.install_torch_hub_requirements("facebookresearch/dinov2")
Parameters | |
repo | see torch:torch.hub.load |
source:"github" | see torch:torch.hub.load |
errorNone | the error level to use, defined as:
By default, fiftyone.config.requirement_error_level is used |
Loads an image model from PyTorch Hub as a
TorchImageModel
.
Example usage:
import fiftyone.utils.torch as fout model = fout.load_torch_hub_image_model( "facebookresearch/dinov2", "dinov2_vits14", image_patch_size=14, embeddings_layer="head", ) assert model.has_embeddings is True
Parameters | |
repo | see torch:torch.hub.load |
model | see torch:torch.hub.load |
hub | Undocumented |
**kwargs | additional parameters for TorchImageModelConfig |
Returns | |
a TorchImageModel |
Loads a raw model from PyTorch Hub as a
torch:torch.nn.Module
.
Example usage:
import fiftyone.utils.torch as fout model = fout.load_torch_hub_raw_model( "facebookresearch/dinov2", "dinov2_vits14", ) print(type(model)) # <class 'dinov2.models.vision_transformer.DinoVisionTransformer'>
Parameters | |
*args | positional arguments for torch:torch.hub.load |
**kwargs | keyword arguments for torch:torch.hub.load |
Returns | |
a torch:torch.nn.Module |
Loads the package requirements from the requirements.txt file on disk associated with a downloaded PyTorch Hub model.
Example usage:
import fiftyone.utils.torch as fout requirements = fout.load_torch_hub_requirements("facebookresearch/dinov2") print(requirements) # ['torch==2.0.0', 'torchvision==0.15.0', ...]
Parameters | |
repo | see torch:torch.hub.load |
source:"github" | see torch:torch.hub.load |
Returns | |
a list of requirement strings |