Module datatap.template.multi_instance_template
Expand source code
from __future__ import annotations
from typing_extensions import TypedDict
from ..utils import basic_repr
class MultiInstanceTemplateJson(TypedDict, total=False):
"""
The serialized JSON representation of a multi instance template.
"""
boundingBox: bool
segmentation: bool
count: bool
class MultiInstanceTemplate():
"""
Describes how an individual multi-instance is structured.
"""
bounding_box: bool
"""
If `bounding_box` is `True`, then all corresponding `MultiInstance`s will
have a `BoundingBox` representing the bounds of their shape.
"""
segmentation: bool
"""
If `segmentation` is `True`, then all corresponding `MultiInstance`s will
have a `Segmentation` tightly representing their shape.
"""
count: bool
"""
If `count` is `True`, then all corresponding `MultiInstance`s will have a
count of how many true instances are present in the multi-instance.
"""
def __init__(
self,
*,
bounding_box: bool = False,
segmentation: bool = False,
count: bool = False
):
self.bounding_box = bounding_box
self.segmentation = segmentation
self.count = count
def to_json(self) -> MultiInstanceTemplateJson:
json = MultiInstanceTemplateJson()
if self.bounding_box: json["boundingBox"] = True
if self.segmentation: json["segmentation"] = True
if self.count: json["count"] = True
return json
@staticmethod
def from_json(json: MultiInstanceTemplateJson) -> MultiInstanceTemplate:
bounding_box = json.get("boundingBox", False)
segmentation = json.get("segmentation", False)
count = json.get("count", False)
return MultiInstanceTemplate(
bounding_box = bounding_box,
segmentation = segmentation,
count = count
)
def __repr__(self) -> str:
return basic_repr(
"MultiInstanceTemplate",
bounding_box = self.bounding_box,
segmentation = self.segmentation
)
Classes
class MultiInstanceTemplate (*, bounding_box: bool = False, segmentation: bool = False, count: bool = False)
-
Describes how an individual multi-instance is structured.
Expand source code
class MultiInstanceTemplate(): """ Describes how an individual multi-instance is structured. """ bounding_box: bool """ If `bounding_box` is `True`, then all corresponding `MultiInstance`s will have a `BoundingBox` representing the bounds of their shape. """ segmentation: bool """ If `segmentation` is `True`, then all corresponding `MultiInstance`s will have a `Segmentation` tightly representing their shape. """ count: bool """ If `count` is `True`, then all corresponding `MultiInstance`s will have a count of how many true instances are present in the multi-instance. """ def __init__( self, *, bounding_box: bool = False, segmentation: bool = False, count: bool = False ): self.bounding_box = bounding_box self.segmentation = segmentation self.count = count def to_json(self) -> MultiInstanceTemplateJson: json = MultiInstanceTemplateJson() if self.bounding_box: json["boundingBox"] = True if self.segmentation: json["segmentation"] = True if self.count: json["count"] = True return json @staticmethod def from_json(json: MultiInstanceTemplateJson) -> MultiInstanceTemplate: bounding_box = json.get("boundingBox", False) segmentation = json.get("segmentation", False) count = json.get("count", False) return MultiInstanceTemplate( bounding_box = bounding_box, segmentation = segmentation, count = count ) def __repr__(self) -> str: return basic_repr( "MultiInstanceTemplate", bounding_box = self.bounding_box, segmentation = self.segmentation )
Class variables
var bounding_box : bool
-
If
bounding_box
isTrue
, then all correspondingMultiInstance
s will have aBoundingBox
representing the bounds of their shape. var count : bool
-
If
count
isTrue
, then all correspondingMultiInstance
s will have a count of how many true instances are present in the multi-instance. var segmentation : bool
-
If
segmentation
isTrue
, then all correspondingMultiInstance
s will have aSegmentation
tightly representing their shape.
Static methods
def from_json(json: MultiInstanceTemplateJson) ‑> MultiInstanceTemplate
-
Expand source code
@staticmethod def from_json(json: MultiInstanceTemplateJson) -> MultiInstanceTemplate: bounding_box = json.get("boundingBox", False) segmentation = json.get("segmentation", False) count = json.get("count", False) return MultiInstanceTemplate( bounding_box = bounding_box, segmentation = segmentation, count = count )
Methods
def to_json(self) ‑> MultiInstanceTemplateJson
-
Expand source code
def to_json(self) -> MultiInstanceTemplateJson: json = MultiInstanceTemplateJson() if self.bounding_box: json["boundingBox"] = True if self.segmentation: json["segmentation"] = True if self.count: json["count"] = True return json
class MultiInstanceTemplateJson (*args, **kwargs)
-
The serialized JSON representation of a multi instance template.
Expand source code
class MultiInstanceTemplateJson(TypedDict, total=False): """ The serialized JSON representation of a multi instance template. """ boundingBox: bool segmentation: bool count: bool
Ancestors
- builtins.dict
Class variables
var boundingBox : bool
var count : bool
var segmentation : bool