otx.api.usecases.exportable_code.demo.demo_package#
Initialization of demo package.
Functions
|
Create annotation converter according to kind of task. |
|
Create visualizer according to kind of task. |
Classes
|
Synchronous executor for model inference. |
|
Async inferencer. |
|
Sync executor for task-chain inference. |
|
Class for storing the model wrapper based on Model API and needed parameters of model. |
- class otx.api.usecases.exportable_code.demo.demo_package.AsyncExecutor(model: ModelContainer, visualizer: Visualizer)[source]#
Bases:
object
Async inferencer.
- Parameters:
model – model for inference
visualizer – visualizer of inference results
- class otx.api.usecases.exportable_code.demo.demo_package.ChainExecutor(models: List[ModelContainer], visualizer: Visualizer)[source]#
Bases:
object
Sync executor for task-chain inference.
- Parameters:
models – list of models for inference
visualizer – visualizer of inference results
- static crop(item: ndarray, parent_annotation: Annotation, item_annotation: Annotation) Tuple[ndarray, Annotation] [source]#
Crop operation between chain stages.
- run(input_stream: int | str, loop: bool = False) None [source]#
Run demo using input stream (image, video stream, camera).
- single_run(input_image: ndarray) AnnotationSceneEntity [source]#
Inference for single image.
- class otx.api.usecases.exportable_code.demo.demo_package.ModelContainer(model_dir: Path, device='CPU')[source]#
Bases:
object
Class for storing the model wrapper based on Model API and needed parameters of model.
- Parameters:
model_dir (Path) – path to model directory
- infer(frame)[source]#
Infer with original image.
- Parameters:
frame (np.ndarray) – image
- Returns:
prediction frame_meta (Dict): dict with original shape
- Return type:
annotation_scene (AnnotationScene)
- infer_tile(frame)[source]#
Infer by patching full image to tiles.
- Parameters:
frame (np.ndarray) – image
- Returns:
prediction frame_meta (Dict): dict with original shape
- Return type:
annotation_scene (AnnotationScene)
- setup_tiler(model_dir, device) DetectionTiler | InstanceSegmentationTiler | None [source]#
Setup tiler for model.
- property labels: LabelSchemaEntity#
Labels property.
- class otx.api.usecases.exportable_code.demo.demo_package.SyncExecutor(model: ModelContainer, visualizer: Visualizer)[source]#
Bases:
object
Synchronous executor for model inference.
- Parameters:
model (ModelContainer) – model for inference
visualizer (Visualizer) – visualizer of inference results. Defaults to None.