otx.algo.classification.multilabel_models#

multilabel classification models package.

Classes

EfficientNetMultilabelCls(label_info, ...)

EfficientNet Model for multi-label classification task.

MobileNetV3MultilabelCls(label_info, ...)

MobileNetV3 Model for multi-class classification task.

TVModelMultilabelCls(label_info, ...)

Torchvision model for multilabel classification.

TimmModelMultilabelCls(label_info, ...)

TimmModel for multi-label classification task.

VisionTransformerMultilabelCls(label_info, ...)

DeitTiny Model for multi-class classification task.

class otx.algo.classification.multilabel_models.EfficientNetMultilabelCls(label_info: LabelInfoTypes, data_input_params: DataInputParams, model_name: str = 'efficientnet_b0', optimizer: OptimizerCallable = <function _default_optimizer_callable>, scheduler: LRSchedulerCallable | LRSchedulerListCallable = <function _default_scheduler_callable>, metric: MetricCallable = <function _multi_label_cls_metric_callable>, torch_compile: bool = False)[source]#

Bases: OTXMultilabelClsModel

EfficientNet Model for multi-label classification task.

Initialize the base model with the given parameters.

Parameters:
  • label_info (LabelInfoTypes) – Information about the labels used in the model.

  • data_input_params (DataInputParams) – Parameters of the input data such as input size, mean, and std.

  • model_name (str, optional) – Name of the model. Defaults to “OTXModel”.

  • optimizer (OptimizerCallable, optional) – Callable for the optimizer. Defaults to DefaultOptimizerCallable.

  • scheduler (LRSchedulerCallable | LRSchedulerListCallable) – Callable for the learning rate scheduler. Defaults to DefaultSchedulerCallable.

  • metric (MetricCallable, optional) – Callable for the metric. Defaults to NullMetricCallable.

  • torch_compile (bool, optional) – Flag to indicate if torch.compile should be used. Defaults to False.

  • tile_config (TileConfig, optional) – Configuration for tiling. Defaults to TileConfig(enable_tiler=False).

Returns:

None

forward_for_tracing(image: Tensor) Tensor | dict[str, Tensor][source]#

Model forward function used for the model tracing during model exportation.

load_from_otx_v1_ckpt(state_dict: dict, add_prefix: str = 'model.') dict[source]#

Load the previous OTX ckpt according to OTX2.0.

class otx.algo.classification.multilabel_models.MobileNetV3MultilabelCls(label_info: LabelInfoTypes, data_input_params: DataInputParams, model_name: str = 'mobilenetv3_large', optimizer: OptimizerCallable = <function _default_optimizer_callable>, scheduler: LRSchedulerCallable | LRSchedulerListCallable = <function _default_scheduler_callable>, metric: MetricCallable = <function _multi_label_cls_metric_callable>, torch_compile: bool = False)[source]#

Bases: OTXMultilabelClsModel

MobileNetV3 Model for multi-class classification task.

Parameters:
  • label_info (LabelInfoTypes) – The label information.

  • data_input_params (DataInputParams) – The data input parameters such as input size and normalization.

  • model_name (str, optional) – The model name. Defaults to “mobilenetv3_large”.

  • optimizer (OptimizerCallable, optional) – The optimizer callable. Defaults to DefaultOptimizerCallable.

  • scheduler (LRSchedulerCallable | LRSchedulerListCallable, optional) – The learning rate scheduler callable. Defaults to DefaultSchedulerCallable.

  • metric (MetricCallable, optional) – The metric callable. Defaults to MultiClassClsMetricCallable.

  • torch_compile (bool, optional) – Whether to compile the model using TorchScript. Defaults to False.

Initialize the base model with the given parameters.

Parameters:
  • label_info (LabelInfoTypes) – Information about the labels used in the model.

  • data_input_params (DataInputParams) – Parameters of the input data such as input size, mean, and std.

  • model_name (str, optional) – Name of the model. Defaults to “OTXModel”.

  • optimizer (OptimizerCallable, optional) – Callable for the optimizer. Defaults to DefaultOptimizerCallable.

  • scheduler (LRSchedulerCallable | LRSchedulerListCallable) – Callable for the learning rate scheduler. Defaults to DefaultSchedulerCallable.

  • metric (MetricCallable, optional) – Callable for the metric. Defaults to NullMetricCallable.

  • torch_compile (bool, optional) – Flag to indicate if torch.compile should be used. Defaults to False.

  • tile_config (TileConfig, optional) – Configuration for tiling. Defaults to TileConfig(enable_tiler=False).

Returns:

None

forward_for_tracing(image: Tensor) Tensor | dict[str, Tensor][source]#

Model forward function used for the model tracing during model exportation.

load_from_otx_v1_ckpt(state_dict: dict, add_prefix: str = 'model.') dict[source]#

Load the previous OTX ckpt according to OTX2.0.

class otx.algo.classification.multilabel_models.TVModelMultilabelCls(label_info: LabelInfoTypes, data_input_params: DataInputParams, model_name: str = 'efficientnet_v2_s', optimizer: OptimizerCallable = <function _default_optimizer_callable>, scheduler: LRSchedulerCallable | LRSchedulerListCallable = <function _default_scheduler_callable>, metric: MetricCallable = <function _multi_label_cls_metric_callable>, torch_compile: bool = False)[source]#

Bases: OTXMultilabelClsModel

Torchvision model for multilabel classification.

Parameters:
  • label_info (LabelInfoTypes) – Information about the labels.

  • backbone (TVModelType) – Backbone model for feature extraction.

  • pretrained (bool, optional) – Whether to use pretrained weights. Defaults to True.

  • optimizer (OptimizerCallable, optional) – Optimizer for model training. Defaults to DefaultOptimizerCallable.

  • scheduler (LRSchedulerCallable | LRSchedulerListCallable, optional) – Learning rate scheduler. Defaults to DefaultSchedulerCallable.

  • metric (MetricCallable, optional) – Metric for model evaluation. Defaults to MultiLabelClsMetricCallable.

  • torch_compile (bool, optional) – Whether to compile the model using TorchScript. Defaults to False.

  • input_size (tuple[int, int], optional) – Input size of the images. Defaults to (224, 224).

Initialize the base model with the given parameters.

Parameters:
  • label_info (LabelInfoTypes) – Information about the labels used in the model.

  • data_input_params (DataInputParams) – Parameters of the input data such as input size, mean, and std.

  • model_name (str, optional) – Name of the model. Defaults to “OTXModel”.

  • optimizer (OptimizerCallable, optional) – Callable for the optimizer. Defaults to DefaultOptimizerCallable.

  • scheduler (LRSchedulerCallable | LRSchedulerListCallable) – Callable for the learning rate scheduler. Defaults to DefaultSchedulerCallable.

  • metric (MetricCallable, optional) – Callable for the metric. Defaults to NullMetricCallable.

  • torch_compile (bool, optional) – Flag to indicate if torch.compile should be used. Defaults to False.

  • tile_config (TileConfig, optional) – Configuration for tiling. Defaults to TileConfig(enable_tiler=False).

Returns:

None

forward_for_tracing(image: torch.Tensor) torch.Tensor | dict[str, torch.Tensor][source]#

Model forward function used for the model tracing during model exportation.

class otx.algo.classification.multilabel_models.TimmModelMultilabelCls(label_info: LabelInfoTypes, data_input_params: DataInputParams, model_name: str, optimizer: OptimizerCallable = <function _default_optimizer_callable>, scheduler: LRSchedulerCallable | LRSchedulerListCallable = <function _default_scheduler_callable>, metric: MetricCallable = <function _multi_label_cls_metric_callable>, torch_compile: bool = False)[source]#

Bases: OTXMultilabelClsModel

TimmModel for multi-label classification task.

Parameters:
  • label_info (LabelInfoTypes) – The label information for the classification task.

  • model_name (str) – The name of the model. You can find available models at timm.list_models() or timm.list_pretrained().

  • input_size (tuple[int, int], optional) – Model input size in the order of height and width. Defaults to (224, 224).

  • pretrained (bool, optional) – Whether to load pretrained weights. Defaults to True.

  • optimizer (OptimizerCallable, optional) – The optimizer callable for training the model.

  • scheduler (LRSchedulerCallable | LRSchedulerListCallable, optional) – The learning rate scheduler callable.

  • metric (MetricCallable, optional) – The metric callable for evaluating the model. Defaults to MultiLabelClsMetricCallable.

  • torch_compile (bool, optional) – Whether to compile the model using TorchScript. Defaults to False.

Initialize the base model with the given parameters.

Parameters:
  • label_info (LabelInfoTypes) – Information about the labels used in the model.

  • data_input_params (DataInputParams) – Parameters of the input data such as input size, mean, and std.

  • model_name (str, optional) – Name of the model. Defaults to “OTXModel”.

  • optimizer (OptimizerCallable, optional) – Callable for the optimizer. Defaults to DefaultOptimizerCallable.

  • scheduler (LRSchedulerCallable | LRSchedulerListCallable) – Callable for the learning rate scheduler. Defaults to DefaultSchedulerCallable.

  • metric (MetricCallable, optional) – Callable for the metric. Defaults to NullMetricCallable.

  • torch_compile (bool, optional) – Flag to indicate if torch.compile should be used. Defaults to False.

  • tile_config (TileConfig, optional) – Configuration for tiling. Defaults to TileConfig(enable_tiler=False).

Returns:

None

forward_for_tracing(image: torch.Tensor) torch.Tensor | dict[str, torch.Tensor][source]#

Model forward function used for the model tracing during model exportation.

load_from_otx_v1_ckpt(state_dict: dict, add_prefix: str = 'model.') dict[source]#

Load the previous OTX ckpt according to OTX2.0.

class otx.algo.classification.multilabel_models.VisionTransformerMultilabelCls(label_info: LabelInfoTypes, data_input_params: DataInputParams, model_name: str = 'vit-tiny', lora: bool = False, optimizer: OptimizerCallable = <function _default_optimizer_callable>, scheduler: LRSchedulerCallable | LRSchedulerListCallable = <function _default_scheduler_callable>, metric: MetricCallable = <function _multi_label_cls_metric_callable>, torch_compile: bool = False)[source]#

Bases: ForwardExplainMixInForViT, OTXMultilabelClsModel

DeitTiny Model for multi-class classification task.

load_from_otx_v1_ckpt(state_dict: dict, add_prefix: str = 'model.') dict[source]#

Load the previous OTX ckpt according to OTX2.0.