sportslabkit.image_model.torchreid#
Overview#
Base class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality. |
|
Base class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality. |
|
Base class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality. |
|
Base class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality. |
|
Base class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality. |
|
Base class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality. |
|
Base class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality. |
|
Base class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality. |
|
Base class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality. |
|
Base class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality. |
|
Base class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality. |
|
Base class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality. |
|
Base class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality. |
|
Base class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality. |
|
Base class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality. |
|
Base class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality. |
Print available models as a list. |
|
|
- |
- |
|
- |
Classes#
- class sportslabkit.image_model.torchreid.BaseTorchReIDModel(name: str = 'osnet_x1_0', path: str = '', device: str = 'cpu', image_size: tuple[int, int] = (256, 128), pixel_mean: list[float] = field(default_factory=lambda : ...), pixel_std: list[float] = field(default_factory=lambda : ...), pixel_norm: bool = True, verbose: bool = False)[source]#
Bases:
sportslabkit.image_model.base.BaseImageModelBase class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality.
Subclasses should override the ‘load’ and ‘forward’ methods. The ‘load’ method should handle loading the model from the specified repository and checkpoint, and ‘forward’ should define the forward pass of the model. Then add ConfigTemplates for your model to define the available configuration options.
The input to the model should be flexible. It accepts numpy.ndarray, torch.Tensor, pathlib Path, string file, PIL Image, or a list of any of these. All inputs will be converted to a list of numpy arrays representing the images.
The output of the model is expected to be a list of embeddings, one for each image. If the model’s output does not meet this expectation, _check_and_fix_outputs method should convert the output into a compatible format.
Example
- class CustomImageModel(BaseImageModel):
- def load(self):
# Load your model here pass
- def forward(self, x):
# Define the forward pass here pass
- input_is_batched#
Whether the input is batched or not. This is set by the _check_and_fix_inputs method.
- Type:
Overview
Methods# load()-
forward(x)Forward must be overridden by subclasses. The overriding method should define the forward pass of the model. The model will receive a 4-dimensional numpy array representing the images. As for the output, the model is expected to return something that can be converted into a 2-dimensional numpy array.
Members
- forward(x)[source]#
Forward must be overridden by subclasses. The overriding method should define the forward pass of the model. The model will receive a 4-dimensional numpy array representing the images. As for the output, the model is expected to return something that can be converted into a 2-dimensional numpy array.
- Parameters:
x (np.ndarray) – input image
- class sportslabkit.image_model.torchreid.ShuffleNet(name: str = 'shufflenet', path: str = '', device: str = 'cpu', image_size: tuple[int, int] = (256, 128), pixel_mean: list[float] = field(default_factory=lambda : ...), pixel_std: list[float] = field(default_factory=lambda : ...), pixel_norm: bool = True, verbose: bool = False)[source]#
Bases:
BaseTorchReIDModelBase class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality.
Subclasses should override the ‘load’ and ‘forward’ methods. The ‘load’ method should handle loading the model from the specified repository and checkpoint, and ‘forward’ should define the forward pass of the model. Then add ConfigTemplates for your model to define the available configuration options.
The input to the model should be flexible. It accepts numpy.ndarray, torch.Tensor, pathlib Path, string file, PIL Image, or a list of any of these. All inputs will be converted to a list of numpy arrays representing the images.
The output of the model is expected to be a list of embeddings, one for each image. If the model’s output does not meet this expectation, _check_and_fix_outputs method should convert the output into a compatible format.
Example
- class CustomImageModel(BaseImageModel):
- def load(self):
# Load your model here pass
- def forward(self, x):
# Define the forward pass here pass
- class sportslabkit.image_model.torchreid.MobileNetV2_x1_0(name: str = 'mobilenetv2_x1_0', path: str = '', device: str = 'cpu', image_size: tuple[int, int] = (256, 128), pixel_mean: list[float] = field(default_factory=lambda : ...), pixel_std: list[float] = field(default_factory=lambda : ...), pixel_norm: bool = True, verbose: bool = False)[source]#
Bases:
BaseTorchReIDModelBase class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality.
Subclasses should override the ‘load’ and ‘forward’ methods. The ‘load’ method should handle loading the model from the specified repository and checkpoint, and ‘forward’ should define the forward pass of the model. Then add ConfigTemplates for your model to define the available configuration options.
The input to the model should be flexible. It accepts numpy.ndarray, torch.Tensor, pathlib Path, string file, PIL Image, or a list of any of these. All inputs will be converted to a list of numpy arrays representing the images.
The output of the model is expected to be a list of embeddings, one for each image. If the model’s output does not meet this expectation, _check_and_fix_outputs method should convert the output into a compatible format.
Example
- class CustomImageModel(BaseImageModel):
- def load(self):
# Load your model here pass
- def forward(self, x):
# Define the forward pass here pass
- class sportslabkit.image_model.torchreid.MobileNetV2_x1_4(name: str = 'mobilenetv2_x1_4', path: str = '', device: str = 'cpu', image_size: tuple[int, int] = (256, 128), pixel_mean: list[float] = field(default_factory=lambda : ...), pixel_std: list[float] = field(default_factory=lambda : ...), pixel_norm: bool = True, verbose: bool = False)[source]#
Bases:
BaseTorchReIDModelBase class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality.
Subclasses should override the ‘load’ and ‘forward’ methods. The ‘load’ method should handle loading the model from the specified repository and checkpoint, and ‘forward’ should define the forward pass of the model. Then add ConfigTemplates for your model to define the available configuration options.
The input to the model should be flexible. It accepts numpy.ndarray, torch.Tensor, pathlib Path, string file, PIL Image, or a list of any of these. All inputs will be converted to a list of numpy arrays representing the images.
The output of the model is expected to be a list of embeddings, one for each image. If the model’s output does not meet this expectation, _check_and_fix_outputs method should convert the output into a compatible format.
Example
- class CustomImageModel(BaseImageModel):
- def load(self):
# Load your model here pass
- def forward(self, x):
# Define the forward pass here pass
- class sportslabkit.image_model.torchreid.MLFN(name: str = 'mfln', path: str = '', device: str = 'cpu', image_size: tuple[int, int] = (256, 128), pixel_mean: list[float] = field(default_factory=lambda : ...), pixel_std: list[float] = field(default_factory=lambda : ...), pixel_norm: bool = True, verbose: bool = False)[source]#
Bases:
BaseTorchReIDModelBase class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality.
Subclasses should override the ‘load’ and ‘forward’ methods. The ‘load’ method should handle loading the model from the specified repository and checkpoint, and ‘forward’ should define the forward pass of the model. Then add ConfigTemplates for your model to define the available configuration options.
The input to the model should be flexible. It accepts numpy.ndarray, torch.Tensor, pathlib Path, string file, PIL Image, or a list of any of these. All inputs will be converted to a list of numpy arrays representing the images.
The output of the model is expected to be a list of embeddings, one for each image. If the model’s output does not meet this expectation, _check_and_fix_outputs method should convert the output into a compatible format.
Example
- class CustomImageModel(BaseImageModel):
- def load(self):
# Load your model here pass
- def forward(self, x):
# Define the forward pass here pass
- class sportslabkit.image_model.torchreid.OSNet_x1_0(name: str = 'osnet_x1_0', path: str = '', device: str = 'cpu', image_size: tuple[int, int] = (256, 128), pixel_mean: list[float] = field(default_factory=lambda : ...), pixel_std: list[float] = field(default_factory=lambda : ...), pixel_norm: bool = True, verbose: bool = False)[source]#
Bases:
BaseTorchReIDModelBase class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality.
Subclasses should override the ‘load’ and ‘forward’ methods. The ‘load’ method should handle loading the model from the specified repository and checkpoint, and ‘forward’ should define the forward pass of the model. Then add ConfigTemplates for your model to define the available configuration options.
The input to the model should be flexible. It accepts numpy.ndarray, torch.Tensor, pathlib Path, string file, PIL Image, or a list of any of these. All inputs will be converted to a list of numpy arrays representing the images.
The output of the model is expected to be a list of embeddings, one for each image. If the model’s output does not meet this expectation, _check_and_fix_outputs method should convert the output into a compatible format.
Example
- class CustomImageModel(BaseImageModel):
- def load(self):
# Load your model here pass
- def forward(self, x):
# Define the forward pass here pass
- class sportslabkit.image_model.torchreid.OSNet_x0_75(name: str = 'osnet_x0_75', path: str = '', device: str = 'cpu', image_size: tuple[int, int] = (256, 128), pixel_mean: list[float] = field(default_factory=lambda : ...), pixel_std: list[float] = field(default_factory=lambda : ...), pixel_norm: bool = True, verbose: bool = False)[source]#
Bases:
BaseTorchReIDModelBase class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality.
Subclasses should override the ‘load’ and ‘forward’ methods. The ‘load’ method should handle loading the model from the specified repository and checkpoint, and ‘forward’ should define the forward pass of the model. Then add ConfigTemplates for your model to define the available configuration options.
The input to the model should be flexible. It accepts numpy.ndarray, torch.Tensor, pathlib Path, string file, PIL Image, or a list of any of these. All inputs will be converted to a list of numpy arrays representing the images.
The output of the model is expected to be a list of embeddings, one for each image. If the model’s output does not meet this expectation, _check_and_fix_outputs method should convert the output into a compatible format.
Example
- class CustomImageModel(BaseImageModel):
- def load(self):
# Load your model here pass
- def forward(self, x):
# Define the forward pass here pass
- class sportslabkit.image_model.torchreid.OSNet_x0_5(name: str = 'osnet_x0_5', path: str = '', device: str = 'cpu', image_size: tuple[int, int] = (256, 128), pixel_mean: list[float] = field(default_factory=lambda : ...), pixel_std: list[float] = field(default_factory=lambda : ...), pixel_norm: bool = True, verbose: bool = False)[source]#
Bases:
BaseTorchReIDModelBase class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality.
Subclasses should override the ‘load’ and ‘forward’ methods. The ‘load’ method should handle loading the model from the specified repository and checkpoint, and ‘forward’ should define the forward pass of the model. Then add ConfigTemplates for your model to define the available configuration options.
The input to the model should be flexible. It accepts numpy.ndarray, torch.Tensor, pathlib Path, string file, PIL Image, or a list of any of these. All inputs will be converted to a list of numpy arrays representing the images.
The output of the model is expected to be a list of embeddings, one for each image. If the model’s output does not meet this expectation, _check_and_fix_outputs method should convert the output into a compatible format.
Example
- class CustomImageModel(BaseImageModel):
- def load(self):
# Load your model here pass
- def forward(self, x):
# Define the forward pass here pass
- class sportslabkit.image_model.torchreid.OSNet_x0_25(name: str = 'osnet_x0_25', path: str = '', device: str = 'cpu', image_size: tuple[int, int] = (256, 128), pixel_mean: list[float] = field(default_factory=lambda : ...), pixel_std: list[float] = field(default_factory=lambda : ...), pixel_norm: bool = True, verbose: bool = False)[source]#
Bases:
BaseTorchReIDModelBase class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality.
Subclasses should override the ‘load’ and ‘forward’ methods. The ‘load’ method should handle loading the model from the specified repository and checkpoint, and ‘forward’ should define the forward pass of the model. Then add ConfigTemplates for your model to define the available configuration options.
The input to the model should be flexible. It accepts numpy.ndarray, torch.Tensor, pathlib Path, string file, PIL Image, or a list of any of these. All inputs will be converted to a list of numpy arrays representing the images.
The output of the model is expected to be a list of embeddings, one for each image. If the model’s output does not meet this expectation, _check_and_fix_outputs method should convert the output into a compatible format.
Example
- class CustomImageModel(BaseImageModel):
- def load(self):
# Load your model here pass
- def forward(self, x):
# Define the forward pass here pass
- class sportslabkit.image_model.torchreid.OSNet_ibn_x1_0(name: str = 'osnet_ibn_x1_0', path: str = '', device: str = 'cpu', image_size: tuple[int, int] = (256, 128), pixel_mean: list[float] = field(default_factory=lambda : ...), pixel_std: list[float] = field(default_factory=lambda : ...), pixel_norm: bool = True, verbose: bool = False)[source]#
Bases:
BaseTorchReIDModelBase class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality.
Subclasses should override the ‘load’ and ‘forward’ methods. The ‘load’ method should handle loading the model from the specified repository and checkpoint, and ‘forward’ should define the forward pass of the model. Then add ConfigTemplates for your model to define the available configuration options.
The input to the model should be flexible. It accepts numpy.ndarray, torch.Tensor, pathlib Path, string file, PIL Image, or a list of any of these. All inputs will be converted to a list of numpy arrays representing the images.
The output of the model is expected to be a list of embeddings, one for each image. If the model’s output does not meet this expectation, _check_and_fix_outputs method should convert the output into a compatible format.
Example
- class CustomImageModel(BaseImageModel):
- def load(self):
# Load your model here pass
- def forward(self, x):
# Define the forward pass here pass
- class sportslabkit.image_model.torchreid.OSNet_ain_x1_0(name: str = 'osnet_ain_x1_0', path: str = '', device: str = 'cpu', image_size: tuple[int, int] = (256, 128), pixel_mean: list[float] = field(default_factory=lambda : ...), pixel_std: list[float] = field(default_factory=lambda : ...), pixel_norm: bool = True, verbose: bool = False)[source]#
Bases:
BaseTorchReIDModelBase class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality.
Subclasses should override the ‘load’ and ‘forward’ methods. The ‘load’ method should handle loading the model from the specified repository and checkpoint, and ‘forward’ should define the forward pass of the model. Then add ConfigTemplates for your model to define the available configuration options.
The input to the model should be flexible. It accepts numpy.ndarray, torch.Tensor, pathlib Path, string file, PIL Image, or a list of any of these. All inputs will be converted to a list of numpy arrays representing the images.
The output of the model is expected to be a list of embeddings, one for each image. If the model’s output does not meet this expectation, _check_and_fix_outputs method should convert the output into a compatible format.
Example
- class CustomImageModel(BaseImageModel):
- def load(self):
# Load your model here pass
- def forward(self, x):
# Define the forward pass here pass
- class sportslabkit.image_model.torchreid.OSNet_ain_x0_75(name: str = 'osnet_ain_x0_75', path: str = '', device: str = 'cpu', image_size: tuple[int, int] = (256, 128), pixel_mean: list[float] = field(default_factory=lambda : ...), pixel_std: list[float] = field(default_factory=lambda : ...), pixel_norm: bool = True, verbose: bool = False)[source]#
Bases:
BaseTorchReIDModelBase class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality.
Subclasses should override the ‘load’ and ‘forward’ methods. The ‘load’ method should handle loading the model from the specified repository and checkpoint, and ‘forward’ should define the forward pass of the model. Then add ConfigTemplates for your model to define the available configuration options.
The input to the model should be flexible. It accepts numpy.ndarray, torch.Tensor, pathlib Path, string file, PIL Image, or a list of any of these. All inputs will be converted to a list of numpy arrays representing the images.
The output of the model is expected to be a list of embeddings, one for each image. If the model’s output does not meet this expectation, _check_and_fix_outputs method should convert the output into a compatible format.
Example
- class CustomImageModel(BaseImageModel):
- def load(self):
# Load your model here pass
- def forward(self, x):
# Define the forward pass here pass
- class sportslabkit.image_model.torchreid.OSNet_ain_x0_5(name: str = 'osnet_ain_x0_5', path: str = '', device: str = 'cpu', image_size: tuple[int, int] = (256, 128), pixel_mean: list[float] = field(default_factory=lambda : ...), pixel_std: list[float] = field(default_factory=lambda : ...), pixel_norm: bool = True, verbose: bool = False)[source]#
Bases:
BaseTorchReIDModelBase class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality.
Subclasses should override the ‘load’ and ‘forward’ methods. The ‘load’ method should handle loading the model from the specified repository and checkpoint, and ‘forward’ should define the forward pass of the model. Then add ConfigTemplates for your model to define the available configuration options.
The input to the model should be flexible. It accepts numpy.ndarray, torch.Tensor, pathlib Path, string file, PIL Image, or a list of any of these. All inputs will be converted to a list of numpy arrays representing the images.
The output of the model is expected to be a list of embeddings, one for each image. If the model’s output does not meet this expectation, _check_and_fix_outputs method should convert the output into a compatible format.
Example
- class CustomImageModel(BaseImageModel):
- def load(self):
# Load your model here pass
- def forward(self, x):
# Define the forward pass here pass
- class sportslabkit.image_model.torchreid.OSNet_ain_x0_25(name: str = 'osnet_ain_x0_25', path: str = '', device: str = 'cpu', image_size: tuple[int, int] = (256, 128), pixel_mean: list[float] = field(default_factory=lambda : ...), pixel_std: list[float] = field(default_factory=lambda : ...), pixel_norm: bool = True, verbose: bool = False)[source]#
Bases:
BaseTorchReIDModelBase class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality.
Subclasses should override the ‘load’ and ‘forward’ methods. The ‘load’ method should handle loading the model from the specified repository and checkpoint, and ‘forward’ should define the forward pass of the model. Then add ConfigTemplates for your model to define the available configuration options.
The input to the model should be flexible. It accepts numpy.ndarray, torch.Tensor, pathlib Path, string file, PIL Image, or a list of any of these. All inputs will be converted to a list of numpy arrays representing the images.
The output of the model is expected to be a list of embeddings, one for each image. If the model’s output does not meet this expectation, _check_and_fix_outputs method should convert the output into a compatible format.
Example
- class CustomImageModel(BaseImageModel):
- def load(self):
# Load your model here pass
- def forward(self, x):
# Define the forward pass here pass
- class sportslabkit.image_model.torchreid.ResNet50(name: str = 'resnet50', path: str = model_dict['resnet50_MSMT17'], device: str = 'cpu', image_size: tuple[int, int] = (256, 128), pixel_mean: list[float] = field(default_factory=lambda : ...), pixel_std: list[float] = field(default_factory=lambda : ...), pixel_norm: bool = True, verbose: bool = False)[source]#
Bases:
BaseTorchReIDModelBase class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality.
Subclasses should override the ‘load’ and ‘forward’ methods. The ‘load’ method should handle loading the model from the specified repository and checkpoint, and ‘forward’ should define the forward pass of the model. Then add ConfigTemplates for your model to define the available configuration options.
The input to the model should be flexible. It accepts numpy.ndarray, torch.Tensor, pathlib Path, string file, PIL Image, or a list of any of these. All inputs will be converted to a list of numpy arrays representing the images.
The output of the model is expected to be a list of embeddings, one for each image. If the model’s output does not meet this expectation, _check_and_fix_outputs method should convert the output into a compatible format.
Example
- class CustomImageModel(BaseImageModel):
- def load(self):
# Load your model here pass
- def forward(self, x):
# Define the forward pass here pass
- class sportslabkit.image_model.torchreid.ResNet50_fc512(name: str = 'resnet50_fc512', path: str = model_dict['resnet50_fc512_MSMT17'], device: str = 'cpu', image_size: tuple[int, int] = (256, 128), pixel_mean: list[float] = field(default_factory=lambda : ...), pixel_std: list[float] = field(default_factory=lambda : ...), pixel_norm: bool = True, verbose: bool = False)[source]#
Bases:
BaseTorchReIDModelBase class for image embedding models. This class implements basic functionality for handling input and output data, and requires subclasses to implement model loading and forward pass functionality.
Subclasses should override the ‘load’ and ‘forward’ methods. The ‘load’ method should handle loading the model from the specified repository and checkpoint, and ‘forward’ should define the forward pass of the model. Then add ConfigTemplates for your model to define the available configuration options.
The input to the model should be flexible. It accepts numpy.ndarray, torch.Tensor, pathlib Path, string file, PIL Image, or a list of any of these. All inputs will be converted to a list of numpy arrays representing the images.
The output of the model is expected to be a list of embeddings, one for each image. If the model’s output does not meet this expectation, _check_and_fix_outputs method should convert the output into a compatible format.
Example
- class CustomImageModel(BaseImageModel):
- def load(self):
# Load your model here pass
- def forward(self, x):
# Define the forward pass here pass