otx.core.model.segmentation#
Class definition for detection model entity used in OTX.
Classes
|
Base class for the semantic segmentation models used in OTX. |
|
Semantic segmentation model compatible for OpenVINO IR inference. |
- class otx.core.model.segmentation.OTXSegmentationModel(label_info: LabelInfoTypes, model_name: str, input_size: tuple[int, int] = (512, 512), optimizer: OptimizerCallable = <function _default_optimizer_callable>, scheduler: LRSchedulerCallable | LRSchedulerListCallable = <function _default_scheduler_callable>, metric: MetricCallable = <function _segm_callable>, torch_compile: bool = False, train_type: Literal[OTXTrainType.SUPERVISED, OTXTrainType.SEMI_SUPERVISED] = OTXTrainType.SUPERVISED, unsupervised_weight: float = 0.7, semisl_start_epoch: int = 2, drop_unreliable_pixels_percent: int = 20, tile_config: TileConfig = TileConfig(enable_tiler=False, enable_adaptive_tiling=True, tile_size=(400, 400), overlap=0.2, iou_threshold=0.45, max_num_instances=1500, object_tile_ratio=0.03, sampling_ratio=1.0, with_full_img=False))[source]#
Bases:
OTXModel
[SegBatchDataEntity
,SegBatchPredEntity
]Base class for the semantic segmentation models used in OTX.
Base semantic segmentation model.
- Parameters:
label_info (LabelInfoTypes) – The label information for the segmentation model.
model_name (str) – The version/name/size of the model.
input_size (tuple[int, int]) – Model input size in the order of height and width.
optimizer (OptimizerCallable, optional) – The optimizer to use for training. Defaults to DefaultOptimizerCallable.
scheduler (LRSchedulerCallable | LRSchedulerListCallable, optional) – The scheduler to use for learning rate adjustment. Defaults to DefaultSchedulerCallable.
metric (MetricCallable, optional) – The metric to use for evaluation. Defaults to SegmCallable.
torch_compile (bool, optional) – Whether to compile the model using TorchScript. Defaults to False.
train_type (Literal[OTXTrainType.SUPERVISED, OTXTrainType.SEMI_SUPERVISED], optional) – The training type of the model. Defaults to OTXTrainType.SUPERVISED.
unsupervised_weight (float, optional) – The weight of the unsupervised loss. Only for semi-supervised learning. Defaults to 0.7.
semisl_start_epoch (int, optional) – The epoch at which the semi-supervised learning starts. Only for semi-supervised learning. Defaults to 2.
drop_unreliable_pixels_percent (int, optional) – The percentage of unreliable pixels to drop. Only for semi-supervised learning. Defaults to 20.
- export(output_dir: Path, base_name: str, export_format: OTXExportFormatType, precision: OTXPrecisionType = OTXPrecisionType.FP32, to_exportable_code: bool = False) Path [source]#
Export this model to the specified output directory.
- Parameters:
output_dir (Path) – directory for saving the exported model
base_name – (str): base name for the exported model file. Extension is defined by the target export format
export_format (OTXExportFormatType) – format of the output model
precision (OTXExportPrecisionType) – precision of the output model
to_exportable_code (bool) – flag to export model in exportable code with demo package
- Returns:
path to the exported model.
- Return type:
Path
- forward_explain(inputs: SegBatchDataEntity) SegBatchPredEntity [source]#
Model forward explain function.
- forward_for_tracing(image: Tensor) Tensor | dict[str, Tensor] [source]#
Model forward function used for the model tracing during model exportation.
- class otx.core.model.segmentation.OVSegmentationModel(model_name: str, model_type: str = 'Segmentation', async_inference: bool = True, max_num_requests: int | None = None, use_throughput_mode: bool = True, model_api_configuration: dict[str, Any] | None = None, metric: MetricCallable = <function _segm_callable>, **kwargs)[source]#
Bases:
OVModel
[SegBatchDataEntity
,SegBatchPredEntity
]Semantic segmentation model compatible for OpenVINO IR inference.
It can consume OpenVINO IR model path or model name from Intel OMZ repository and create the OTX segmentation model compatible for OTX testing pipeline.