diff --git a/ote_sdk/ote_sdk/entities/annotation.py b/ote_sdk/ote_sdk/entities/annotation.py
index 5e929d8dc97..8aff0b1dce7 100644
--- a/ote_sdk/ote_sdk/entities/annotation.py
+++ b/ote_sdk/ote_sdk/entities/annotation.py
@@ -8,8 +8,6 @@
from enum import Enum
from typing import Dict, List, Optional, Set
-from bson import ObjectId
-
from ote_sdk.entities.id import ID
from ote_sdk.entities.label import LabelEntity
from ote_sdk.entities.scored_label import ScoredLabel
@@ -23,10 +21,7 @@ class Annotation(metaclass=abc.ABCMeta):
"""
# pylint: disable=redefined-builtin;
- def __init__(
- self, shape: ShapeEntity, labels: List[ScoredLabel], id: Optional[ID] = None
- ):
- self.__id_ = ID(ObjectId()) if id is None else id
+ def __init__(self, shape: ShapeEntity, labels: List[ScoredLabel]):
self.__shape = shape
self.__labels = labels
@@ -34,31 +29,9 @@ def __repr__(self):
return (
f"{self.__class__.__name__}("
f"shape={self.shape}, "
- f"labels={self.get_labels(True)}, "
- f"id={self.id_})"
+ f"labels={self.get_labels(True)}"
)
- @property
- def id_(self):
- """
- Returns the id for the annotation
- """
- return self.__id_
-
- @id_.setter
- def id_(self, value):
- self.__id_ = value
-
- @property
- def id(self):
- """DEPRECATED"""
- return self.__id_
-
- @id.setter
- def id(self, value):
- """DEPRECATED"""
- self.__id_ = value
-
@property
def shape(self):
"""
@@ -113,8 +86,7 @@ def set_labels(self, labels: List[ScoredLabel]):
def __eq__(self, other):
if isinstance(other, Annotation):
return (
- self.id_ == other.id_
- and self.get_labels(True) == other.get_labels(True)
+ self.get_labels(True) == other.get_labels(True)
and self.shape == other.shape
)
return False
diff --git a/ote_sdk/ote_sdk/entities/datasets.py b/ote_sdk/ote_sdk/entities/datasets.py
index 59953cb25ed..6abfb65ce2e 100644
--- a/ote_sdk/ote_sdk/entities/datasets.py
+++ b/ote_sdk/ote_sdk/entities/datasets.py
@@ -12,11 +12,8 @@
from enum import Enum
from typing import Iterator, List, Optional, Sequence, Union, overload
-from bson.objectid import ObjectId
-
from ote_sdk.entities.annotation import AnnotationSceneEntity, AnnotationSceneKind
from ote_sdk.entities.dataset_item import DatasetItemEntity
-from ote_sdk.entities.id import ID
from ote_sdk.entities.label import LabelEntity
from ote_sdk.entities.subset import Subset
@@ -277,7 +274,6 @@ def with_empty_annotations(
# reset ROI
roi = copy.copy(dataset_item.roi)
- roi.id_ = ID(ObjectId())
roi.set_labels([])
new_dataset_item = DatasetItemEntity(
diff --git a/ote_sdk/ote_sdk/entities/shapes/ellipse.py b/ote_sdk/ote_sdk/entities/shapes/ellipse.py
index 863f5136c9b..b8b7e99507b 100644
--- a/ote_sdk/ote_sdk/entities/shapes/ellipse.py
+++ b/ote_sdk/ote_sdk/entities/shapes/ellipse.py
@@ -14,7 +14,6 @@
from scipy import optimize, special
from shapely.geometry import Polygon as shapely_polygon
-from ote_sdk.entities.scored_label import ScoredLabel
from ote_sdk.entities.shapes.rectangle import Rectangle
from ote_sdk.entities.shapes.shape import Shape, ShapeType
from ote_sdk.utils.time_utils import now
@@ -33,7 +32,6 @@ class Ellipse(Shape):
:param y1: top y coordinate of encapsulating rectangle
:param x2: right x coordinate of encapsulating rectangle
:param y2: bottom y coordinate of encapsulating rectangle
- :param labels: list of the ScoredLabel's for the Ellipse
:param modification_date: last modified date
"""
@@ -44,14 +42,11 @@ def __init__(
y1: float,
x2: float,
y2: float,
- labels: Optional[List[ScoredLabel]] = None,
modification_date: Optional[datetime.datetime] = None,
):
- labels = [] if labels is None else labels
modification_date = now() if modification_date is None else modification_date
super().__init__(
- type=ShapeType.ELLIPSE,
- labels=labels,
+ shape_type=ShapeType.ELLIPSE,
modification_date=modification_date,
)
@@ -92,7 +87,7 @@ def width(self):
:example:
- >>> e1 = Ellipse(x1=0.5, x2=1.0, y1=0.0, y2=0.5, labels = [])
+ >>> e1 = Ellipse(x1=0.5, x2=1.0, y1=0.0, y2=0.5)
>>> e1.width
0.5
@@ -107,7 +102,7 @@ def height(self):
:example:
- >>> e1 = Ellipse(x1=0.5, x2=1.0, y1=0.0, y2=0.5, labels = [])
+ >>> e1 = Ellipse(x1=0.5, x2=1.0, y1=0.0, y2=0.5)
>>> e1.height
0.5
@@ -136,7 +131,7 @@ def minor_axis(self) -> float:
:example:
- >>> e1 = Ellipse(x1=0.5, x2=1.0, y1=0.0, y2=0.4, labels = [])
+ >>> e1 = Ellipse(x1=0.5, x2=1.0, y1=0.0, y2=0.4)
>>> e1.minor_axis
0.2
@@ -153,7 +148,7 @@ def major_axis(self) -> float:
:example:
- >>> e1 = Ellipse(x1=0.5, x2=1.0, y1=0.0, y2=0.4, labels = [])
+ >>> e1 = Ellipse(x1=0.5, x2=1.0, y1=0.0, y2=0.4)
>>> e1.major_axis
0.25
@@ -179,7 +174,7 @@ def normalize_wrt_roi_shape(self, roi_shape: Rectangle) -> "Ellipse":
>>> roi = Rectangle(x1=0.0, x2=0.5, y1=0.0, y2=0.5)
>>> normalized = c1.normalize_wrt_roi_shape(roi_shape)
>>> normalized
- Ellipse(, x1=0.25, y1=0.25, x2=0.3, y2=0.3, scored_labels=[])
+ Ellipse(, x1=0.25, y1=0.25, x2=0.3, y2=0.3)
:param roi_shape: Region of Interest
:return: New polygon in the image coordinate system
@@ -214,7 +209,7 @@ def denormalize_wrt_roi_shape(self, roi_shape: Rectangle) -> "Ellipse":
>>> roi = Rectangle(x1=0.5, x2=1.0, y1=0.0, y2=1.0) # the half-right
>>> normalized = c1.denormalize_wrt_roi_shape(roi_shape) # should return top half
>>> normalized
- Ellipse(, x1=0.0, y1=0.0, x2=1.0, y2=0.5, scored_labels=[])
+ Ellipse(, x1=0.0, y1=0.0, x2=1.0, y2=0.5)
:param roi_shape: Region of Interest
:return: New polygon in the ROI coordinate system
diff --git a/ote_sdk/ote_sdk/entities/shapes/polygon.py b/ote_sdk/ote_sdk/entities/shapes/polygon.py
index a6fe12c5213..2abc660a7dd 100644
--- a/ote_sdk/ote_sdk/entities/shapes/polygon.py
+++ b/ote_sdk/ote_sdk/entities/shapes/polygon.py
@@ -14,7 +14,6 @@
from shapely.geometry import Polygon as shapely_polygon
-from ote_sdk.entities.scored_label import ScoredLabel
from ote_sdk.entities.shapes.rectangle import Rectangle
from ote_sdk.entities.shapes.shape import Shape, ShapeType
from ote_sdk.utils.time_utils import now
@@ -80,7 +79,6 @@ class Polygon(Shape):
NB Freehand drawings are also stored as polygons.
:param points: list of Point's forming the polygon
- :param labels: list of the ScoredLabel's for the Polygon
:param modification_date: last modified date
"""
@@ -88,14 +86,11 @@ class Polygon(Shape):
def __init__(
self,
points: List[Point],
- labels: Optional[List[ScoredLabel]] = None,
modification_date: Optional[datetime.datetime] = None,
):
- labels = [] if labels is None else labels
modification_date = now() if modification_date is None else modification_date
super().__init__(
- type=ShapeType.POLYGON,
- labels=labels,
+ shape_type=ShapeType.POLYGON,
modification_date=modification_date,
)
@@ -151,7 +146,7 @@ def normalize_wrt_roi_shape(self, roi_shape: Rectangle) -> "Polygon":
>>> roi = Rectangle(x1=0.0, x2=0.5, y1=0.0, y2=0.5)
>>> normalized = p1.normalize_wrt_roi_shape(roi_shape)
>>> normalized
- Polygon(, len(points)=3, scored_labels=[])
+ Polygon(, len(points)=3)
:param roi_shape: Region of Interest
:return: New polygon in the image coordinate system
@@ -181,7 +176,7 @@ def denormalize_wrt_roi_shape(self, roi_shape: Rectangle) -> "Polygon":
>>> roi = Rectangle(x1=0.5, x2=1.0, y1=0.0, y2=1.0) # the half-right
>>> normalized = p1.denormalize_wrt_roi_shape(roi_shape)
>>> normalized
- Polygon(, len(points)=3, scored_labels=[])
+ Polygon(, len(points)=3)
:param roi_shape: Region of Interest
:return: New polygon in the ROI coordinate system
diff --git a/ote_sdk/ote_sdk/entities/shapes/rectangle.py b/ote_sdk/ote_sdk/entities/shapes/rectangle.py
index fe73135d729..6ea82453dec 100644
--- a/ote_sdk/ote_sdk/entities/shapes/rectangle.py
+++ b/ote_sdk/ote_sdk/entities/shapes/rectangle.py
@@ -9,12 +9,11 @@
import datetime
import math
import warnings
-from typing import List, Optional
+from typing import Optional
import numpy as np
from shapely.geometry import Polygon as shapely_polygon
-from ote_sdk.entities.scored_label import ScoredLabel
from ote_sdk.entities.shapes.shape import Shape, ShapeEntity, ShapeType
from ote_sdk.utils.time_utils import now
@@ -36,7 +35,6 @@ class Rectangle(Shape):
:param y1: see above
:param x2: see above
:param y2: see above
- :param labels: list of the ScoredLabel's for the rectangle
:param modification_date: last modified date
"""
@@ -47,14 +45,11 @@ def __init__(
y1: float,
x2: float,
y2: float,
- labels: Optional[List[ScoredLabel]] = None,
modification_date: Optional[datetime.datetime] = None,
):
- labels = [] if labels is None else labels
modification_date = now() if modification_date is None else modification_date
super().__init__(
- type=ShapeType.RECTANGLE,
- labels=labels,
+ shape_type=ShapeType.RECTANGLE,
modification_date=modification_date,
)
@@ -106,7 +101,7 @@ def clip_to_visible_region(self) -> "Rectangle":
x2 = min(max(0.0, self.x2), 1.0)
y2 = min(max(0.0, self.y2), 1.0)
- return Rectangle(x1, y1, x2, y2, [], self.modification_date)
+ return Rectangle(x1, y1, x2, y2, self.modification_date)
def normalize_wrt_roi_shape(self, roi_shape: "Rectangle") -> "Rectangle":
"""
@@ -122,7 +117,7 @@ def normalize_wrt_roi_shape(self, roi_shape: "Rectangle") -> "Rectangle":
>>> roi = Rectangle(x1=0.0, x2=0.5, y1=0.0, y2=0.5)
>>> normalized = b1.normalize_wrt_roi_shape(roi_shape)
>>> normalized
- Box(, x=0.25, y=0.0, width=0.25, height=0.25, scored_labels=[])
+ Box(, x=0.25, y=0.0, width=0.25, height=0.25)
:param roi_shape: Region of Interest
:return: New polygon in the image coordinate system
@@ -152,14 +147,14 @@ def denormalize_wrt_roi_shape(self, roi_shape: "Rectangle") -> "Rectangle":
Box denormalized to a rectangle as ROI
>>> from ote_sdk.entities.annotation import Annotation
- >>> b1 = Rectangle(x1=0.5, x2=1.0, y1=0.0, y2=0.5, labels = [])
+ >>> b1 = Rectangle(x1=0.5, x2=1.0, y1=0.0, y2=0.5)
# the top-right
- >>> roi = Annotation(Rectangle(x1=0.5, x2=1.0, y1=0.0, y2=1.0), labels = [])
+ >>> roi = Annotation(Rectangle(x1=0.5, x2=1.0, y1=0.0, y2=1.0))
# the half-right
>>> normalized = b1.denormalize_wrt_roi_shape(roi_shape)
# should return top half
>>> normalized
- Box(, x=0.0, y=0.0, width=1.0, height=0.5, scored_labels=[])
+ Box(, x=0.0, y=0.0, width=1.0, height=0.5)
:param roi_shape: Region of Interest
:return: New polygon in the ROI coordinate system
@@ -193,26 +188,18 @@ def _as_shapely_polygon(self) -> shapely_polygon:
return shapely_polygon(points)
@classmethod
- def generate_full_box(
- cls, labels: Optional[List[ScoredLabel]] = None
- ) -> "Rectangle":
+ def generate_full_box(cls) -> "Rectangle":
"""
- Returns a rectangle that fully encapsulates the normalized coordinate space,
- with `labels`
+ Returns a rectangle that fully encapsulates the normalized coordinate space
:example:
>>> Rectangle.generate_full_box()
- Box(, x=0.0, y=0.0, width=1.0, height=1.0, scored_labels=[])
-
- :param labels: labels to assigned to the output rectangle
+ Box(, x=0.0, y=0.0, width=1.0, height=1.0)
:return: a rectangle that fully encapsulates the normalized coordinate space,
- with `labels`
"""
- if labels is None:
- labels = []
- return cls(x1=0.0, y1=0.0, x2=1.0, y2=1.0, labels=labels)
+ return cls(x1=0.0, y1=0.0, x2=1.0, y2=1.0)
@staticmethod
def is_full_box(rectangle: ShapeEntity) -> bool:
@@ -222,11 +209,11 @@ def is_full_box(rectangle: ShapeEntity) -> bool:
:example:
- >>> b1 = Rectangle(x1=0.5, x2=1.0, y1=0.0, y2=1.0, labels = [])
+ >>> b1 = Rectangle(x1=0.5, x2=1.0, y1=0.0, y2=1.0)
>>> Rectangle.is_full_box(b1)
False
- >>> b2 = Rectangle(x1=0.0, x2=1.0, y1=0.0, y2=1.0, labels = [])
+ >>> b2 = Rectangle(x1=0.0, x2=1.0, y1=0.0, y2=1.0)
>>> Rectangle.is_full_box(b2)
True
@@ -271,7 +258,7 @@ def width(self):
:example:
- >>> b1 = Rectangle(x1=0.5, x2=1.0, y1=0.0, y2=0.5, labels = [])
+ >>> b1 = Rectangle(x1=0.5, x2=1.0, y1=0.0, y2=0.5)
>>> b1.width
0.5
@@ -286,7 +273,7 @@ def height(self):
:example:
- >>> b1 = Rectangle(x1=0.5, x2=1.0, y1=0.0, y2=0.5, labels = [])
+ >>> b1 = Rectangle(x1=0.5, x2=1.0, y1=0.0, y2=0.5)
>>> b1.height
0.5
@@ -301,7 +288,7 @@ def diagonal(self):
:example:
- >>> b1 = Rectangle(x1=0.0, x2=0.3, y1=0.0, y2=0.4, labels = [])
+ >>> b1 = Rectangle(x1=0.0, x2=0.3, y1=0.0, y2=0.4)
>>> b1.diagonal
0.5
diff --git a/ote_sdk/ote_sdk/entities/shapes/shape.py b/ote_sdk/ote_sdk/entities/shapes/shape.py
index 48f4dde1ad6..600d8b606f2 100644
--- a/ote_sdk/ote_sdk/entities/shapes/shape.py
+++ b/ote_sdk/ote_sdk/entities/shapes/shape.py
@@ -5,15 +5,14 @@
#
import abc
+import datetime
import warnings
from enum import IntEnum, auto
-from typing import TYPE_CHECKING, List
+from typing import TYPE_CHECKING
from shapely.errors import PredicateError, TopologicalError
from shapely.geometry import Polygon as shapely_polygon
-from ote_sdk.entities.scored_label import ScoredLabel
-
if TYPE_CHECKING:
from ote_sdk.entities.shapes.rectangle import Rectangle
@@ -37,9 +36,8 @@ class ShapeEntity(metaclass=abc.ABCMeta):
"""
# pylint: disable=redefined-builtin
- def __init__(self, type: ShapeType, labels: List[ScoredLabel]):
- self._type = type
- self._labels = labels
+ def __init__(self, shape_type: ShapeType):
+ self._type = shape_type
@property
def type(self):
@@ -76,34 +74,6 @@ def contains_center(self, other: "ShapeEntity") -> bool:
"""
raise NotImplementedError
- @abc.abstractmethod
- def get_labels(self, include_empty: bool = False):
- """
- Get scored labels that are assigned to this shape
-
- :param include_empty: set to True to include empty label (if exists) in the output.
- :return: List of labels in shape
- """
- raise NotImplementedError
-
- @abc.abstractmethod
- def append_label(self, label: ScoredLabel):
- """
- Appends the scored label to the shape.
-
- :param label: the scored label to be appended to the shape
- """
- raise NotImplementedError
-
- @abc.abstractmethod
- def set_labels(self, labels: List[ScoredLabel]):
- """
- Sets the labels of the shape to be the input of the function.
-
- :param labels: the scored labels to be set as shape labels
- """
- raise NotImplementedError
-
@abc.abstractmethod
def normalize_wrt_roi_shape(self, roi_shape: "Rectangle") -> "Shape":
"""
@@ -146,8 +116,8 @@ class Shape(ShapeEntity):
"""
# pylint: disable=redefined-builtin, too-many-arguments; Requires refactor
- def __init__(self, type: ShapeType, labels: List[ScoredLabel], modification_date):
- super().__init__(type=type, labels=labels)
+ def __init__(self, shape_type: ShapeType, modification_date: datetime.datetime):
+ super().__init__(shape_type=shape_type)
self.modification_date = modification_date
def __repr__(self):
@@ -180,17 +150,6 @@ def contains_center(self, other: "ShapeEntity") -> bool:
polygon_shape = other._as_shapely_polygon()
return polygon_roi.contains(polygon_shape.centroid)
- def get_labels(self, include_empty: bool = False) -> List[ScoredLabel]:
- return [
- label for label in self._labels if include_empty or (not label.is_empty)
- ]
-
- def append_label(self, label: ScoredLabel):
- self._labels.append(label)
-
- def set_labels(self, labels: List[ScoredLabel]):
- self._labels = labels
-
def _validate_coordinates(self, x: float, y: float) -> bool:
"""
Checks whether the values for a given x,y coordinate pair lie within the range of (0,1) that is expected for
diff --git a/ote_sdk/ote_sdk/tests/entities/shapes/test_ellipse.py b/ote_sdk/ote_sdk/tests/entities/shapes/test_ellipse.py
index 323ca0b8516..65524153a44 100644
--- a/ote_sdk/ote_sdk/tests/entities/shapes/test_ellipse.py
+++ b/ote_sdk/ote_sdk/tests/entities/shapes/test_ellipse.py
@@ -78,7 +78,6 @@ def test_ellipse(self):
assert ellipse.y_center == 0.25
assert ellipse.minor_axis == 0.25
assert ellipse.major_axis == 0.25
- assert ellipse._labels == []
assert ellipse.modification_date == modification_date
incorrect_ellipse_params = {
diff --git a/ote_sdk/ote_sdk/tests/entities/shapes/test_rectangle.py b/ote_sdk/ote_sdk/tests/entities/shapes/test_rectangle.py
index cbe18e4a0b4..c02366f3a7e 100644
--- a/ote_sdk/ote_sdk/tests/entities/shapes/test_rectangle.py
+++ b/ote_sdk/ote_sdk/tests/entities/shapes/test_rectangle.py
@@ -67,7 +67,6 @@ def vertical_rectangle_params(self) -> dict:
"y1": 0.1,
"x2": 0.3,
"y2": 0.4,
- "labels": self.rectangle_labels(),
"modification_date": datetime(
year=2020, month=1, day=1, hour=9, minute=30, second=15, microsecond=2
),
@@ -130,11 +129,9 @@ class object initiation with optional parameters
"""
# Checking default values of optional parameters
default_params_rectangle = self.horizontal_rectangle()
- assert default_params_rectangle._labels == []
assert isinstance(default_params_rectangle.modification_date, datetime)
# check for specified values of optional parameters
specified_params_rectangle = self.vertical_rectangle()
- assert specified_params_rectangle._labels == self.rectangle_labels()
assert specified_params_rectangle.modification_date == datetime(
year=2020, month=1, day=1, hour=9, minute=30, second=15, microsecond=2
)
@@ -237,11 +234,6 @@ def test_rectangle_eq(self):
# Check for different types branch
assert rectangle != str
# Check for unequal labels parameters. Expected that different labels are not affecting equality
- unequal_label = LabelEntity(
- name="Unequal label", domain=Domain.SEGMENTATION, id=ID("unequal_label_1")
- )
- unequal_scored_label = ScoredLabel(label=unequal_label)
- equal_rectangle._labels.append(unequal_scored_label)
assert rectangle == equal_rectangle
# Check for instances with unequal parameters combinations
# Generating all possible scenarios of parameter values submission
@@ -321,7 +313,6 @@ def test_rectangle_clip_to_visible_region(self):
"y1": 0.2,
"x2": 0.6,
"y2": 0.4,
- "labels": self.rectangle_labels(),
},
"params_expected": {"x1": 0.3, "y1": 0.2, "x2": 0.6, "y2": 0.4},
},
@@ -331,7 +322,6 @@ def test_rectangle_clip_to_visible_region(self):
"y1": -0.3,
"x2": 1.6,
"y2": 1.4,
- "labels": self.rectangle_labels(),
},
"params_expected": {"x1": 0.0, "y1": 0.0, "x2": 1.0, "y2": 1.0},
},
@@ -341,7 +331,6 @@ def test_rectangle_clip_to_visible_region(self):
"y1": 0.0,
"x2": 1.0,
"y2": 1.0,
- "labels": self.rectangle_labels(),
},
"params_expected": {"x1": 0.0, "y1": 0.0, "x2": 1.0, "y2": 1.0},
},
@@ -464,29 +453,17 @@ def test_rectangle_generate_full_box(self):
Description:
Check Rectangle generate_full_box method
- Input data:
- Labels specified for full_box instance of Rectangle class
-
Expected results:
Test passes if generate_full_box method returns instance of Rectangle class with coordinates
(x1=0.0, y1=0.0, x2=1.0, y2=1.0)
Steps
1. Check generate_full_box method for Rectangle instance with no labels specified
- 2. Check generate_full_box method for Rectangle instance with labels specified
"""
- detection_label = ScoredLabel(
- LabelEntity(name="detection", domain=Domain.DETECTION)
- )
- for label_actual, label_expected in [
- (None, []),
- ([detection_label], [detection_label]),
- ]:
- full_box = Rectangle.generate_full_box(label_actual)
- assert full_box.type == ShapeType.RECTANGLE
- assert full_box.x1 == full_box.y1 == 0.0
- assert full_box.x2 == full_box.y2 == 1.0
- assert full_box._labels == label_expected
+ full_box = Rectangle.generate_full_box()
+ assert full_box.type == ShapeType.RECTANGLE
+ assert full_box.x1 == full_box.y1 == 0.0
+ assert full_box.x2 == full_box.y2 == 1.0
@pytest.mark.priority_medium
@pytest.mark.unit
diff --git a/ote_sdk/ote_sdk/tests/entities/shapes/test_shape.py b/ote_sdk/ote_sdk/tests/entities/shapes/test_shape.py
index f1ee3de2c2c..3dcb8a76c9d 100644
--- a/ote_sdk/ote_sdk/tests/entities/shapes/test_shape.py
+++ b/ote_sdk/ote_sdk/tests/entities/shapes/test_shape.py
@@ -18,9 +18,6 @@
import pytest
-from ote_sdk.entities.color import Color
-from ote_sdk.entities.label import LabelEntity
-from ote_sdk.entities.scored_label import Domain, ScoredLabel
from ote_sdk.entities.shapes.ellipse import Ellipse
from ote_sdk.entities.shapes.polygon import Point, Polygon
from ote_sdk.entities.shapes.rectangle import Rectangle
@@ -84,24 +81,6 @@ def test_shape_entity_not_implemented_methods(self):
ShapeEntity.intersects(shape, shape)
with pytest.raises(NotImplementedError):
ShapeEntity.contains_center(shape, shape)
- with pytest.raises(NotImplementedError):
- ShapeEntity.get_labels(shape)
- with pytest.raises(NotImplementedError):
- ShapeEntity.append_label(
- shape,
- ScoredLabel(
- LabelEntity(name="classification", domain=Domain.CLASSIFICATION)
- ),
- )
- with pytest.raises(NotImplementedError):
- ShapeEntity.set_labels(
- shape,
- [
- ScoredLabel(
- LabelEntity(name="detection", domain=Domain.DETECTION)
- )
- ],
- )
with pytest.raises(NotImplementedError):
ShapeEntity.normalize_wrt_roi_shape(shape, rectangle_entity)
with pytest.raises(NotImplementedError):
@@ -133,59 +112,11 @@ def fully_covering_polygon() -> Polygon:
]
)
- @staticmethod
- def generate_labels_list(include_empty: bool = True) -> list:
- classification_label = ScoredLabel(
- LabelEntity(
- name="classification",
- domain=Domain.CLASSIFICATION,
- color=Color(red=187, green=28, blue=28),
- creation_date=datetime(year=2021, month=10, day=25),
- )
- )
- detection_label = ScoredLabel(
- LabelEntity(
- name="detection",
- domain=Domain.DETECTION,
- color=Color(red=180, green=30, blue=24),
- creation_date=datetime(year=2021, month=9, day=24),
- )
- )
- empty_label = ScoredLabel(
- LabelEntity(
- name="empty_rectangle_label",
- domain=Domain.CLASSIFICATION,
- color=Color(red=178, green=25, blue=30),
- creation_date=datetime(year=2021, month=7, day=26),
- is_empty=True,
- )
- )
- labels_list = [classification_label, detection_label]
- if include_empty:
- labels_list.append(empty_label)
- return labels_list
-
- @staticmethod
- def appendable_label(empty=False) -> ScoredLabel:
- return ScoredLabel(
- LabelEntity(
- name="appended_label",
- domain=Domain.CLASSIFICATION,
- color=Color(red=181, green=28, blue=31),
- creation_date=datetime(year=2021, month=11, day=22),
- is_empty=empty,
- )
- )
-
def rectangle(self) -> Rectangle:
- return Rectangle(
- x1=0.2, y1=0.2, x2=0.6, y2=0.7, labels=self.generate_labels_list()
- )
+ return Rectangle(x1=0.2, y1=0.2, x2=0.6, y2=0.7)
def ellipse(self) -> Ellipse:
- return Ellipse(
- x1=0.4, y1=0.1, x2=0.9, y2=0.8, labels=self.generate_labels_list()
- )
+ return Ellipse(x1=0.4, y1=0.1, x2=0.9, y2=0.8)
def polygon(self) -> Polygon:
return Polygon(
@@ -197,7 +128,6 @@ def polygon(self) -> Polygon:
Point(0.8, 0.4),
Point(0.3, 0.4),
],
- labels=self.generate_labels_list(),
)
@staticmethod
@@ -403,166 +333,6 @@ def test_shape_contains_center(self):
for shape_outside in shapes_outside:
assert not rectangle_part.contains_center(shape_outside)
- @pytest.mark.priority_medium
- @pytest.mark.unit
- @pytest.mark.reqids(Requirements.REQ_1)
- def test_shape_get_labels(self):
- """
- Description:
- Check Shape get_labels method for Rectangle, Ellipse and Polygon objects
-
- Expected results:
- Test passes if get_labels method returns expected values
-
- Steps
- 1. Check get_labels method for Shapes with no labels specified
- 2. Check get_labels method for Shapes with specified labels and include_empty parameter set to False
- 3. Check get_labels method for Shapes with specified labels and include_empty parameter set to True
- """
- # Checks for no labels specified
- for no_labels_shape in [
- self.fully_covering_rectangle(),
- self.fully_covering_ellipse(),
- self.fully_covering_polygon(),
- ]:
- assert no_labels_shape.get_labels() == []
- # Checks for labels specified and include_empty set to False
- expected_false_include_empty_labels = self.generate_labels_list(
- include_empty=False
- )
- for false_include_empty_labels_shape in [
- self.rectangle(),
- self.ellipse(),
- self.polygon(),
- ]:
- assert (
- false_include_empty_labels_shape.get_labels()
- == expected_false_include_empty_labels
- )
- # Checks for labels specified and include_empty set to True
- expected_include_empty_labels = self.generate_labels_list(include_empty=True)
- for include_empty_labels_shape in [
- self.rectangle(),
- self.ellipse(),
- self.polygon(),
- ]:
- assert (
- include_empty_labels_shape.get_labels(include_empty=True)
- == expected_include_empty_labels
- )
-
- @pytest.mark.priority_medium
- @pytest.mark.unit
- @pytest.mark.reqids(Requirements.REQ_1)
- def test_shape_append_label(self):
- """
- Description:
- Check Shape get_labels method for Rectangle, Ellipse and Polygon objects
-
- Expected results:
- Test passes if append_label method returns expected values
-
- Steps
- 1. Check append_label method to add label to Shape object with no labels specified
- 2. Check append_label method to add empty label to Shape object with no labels specified
- 3. Check append_label method to add label to Shape object with specified labels
- 4. Check append_label method to add empty label to Shape object with specified labels
- """
- appendable_label = self.appendable_label()
- empty_appendable_label = self.appendable_label(empty=True)
- # Check for adding label to Shape with no labels specified
- for no_labels_shape in [
- self.fully_covering_rectangle(),
- self.fully_covering_ellipse(),
- self.fully_covering_polygon(),
- ]:
- no_labels_shape.append_label(appendable_label)
- assert no_labels_shape.get_labels() == [appendable_label]
- # Check for adding empty label to Shape with no labels specified
- for no_labels_shape in [
- self.fully_covering_rectangle(),
- self.fully_covering_ellipse(),
- self.fully_covering_polygon(),
- ]:
- no_labels_shape.append_label(empty_appendable_label)
- assert no_labels_shape.get_labels() == []
- assert no_labels_shape.get_labels(include_empty=True) == [
- empty_appendable_label
- ]
- # Check for adding label to Shape with labels specified
- for shape in [self.rectangle(), self.ellipse(), self.polygon()]:
- expected_labels = shape.get_labels()
- expected_labels.append(appendable_label)
- shape.append_label(appendable_label)
- # Check for adding empty label to Shape with labels specified
- expected_labels_false_empty = self.generate_labels_list(include_empty=False)
- expected_include_empty_labels = self.generate_labels_list(include_empty=True)
- expected_include_empty_labels.append(empty_appendable_label)
- for shape in [self.rectangle(), self.ellipse(), self.polygon()]:
- shape.append_label(empty_appendable_label)
- assert shape.get_labels() == expected_labels_false_empty
- assert shape.get_labels(include_empty=True) == expected_include_empty_labels
-
- @pytest.mark.priority_medium
- @pytest.mark.unit
- @pytest.mark.reqids(Requirements.REQ_1)
- def test_shape_set_labels(self):
- """
- Description:
- Check Shape set_labels method for Rectangle, Ellipse and Polygon objects
-
- Expected results:
- Test passes if set_labels method returns expected values
-
- Steps
- 1. Check set_labels method to add labels list to Shape object with no labels specified
- 2. Check set_labels method to add empty labels list to Shape object with no labels specified
- 3. Check set_labels method to add labels list to Shape object with labels specified
- 4. Check set_labels method to add empty labels list to Shape object with labels specified
- """
- not_empty_label = self.appendable_label()
- new_labels_list = [
- not_empty_label,
- ScoredLabel(
- LabelEntity(
- name="new_label",
- domain=Domain.CLASSIFICATION,
- color=Color(red=183, green=31, blue=28),
- creation_date=datetime(year=2021, month=9, day=25),
- is_empty=True,
- )
- ),
- ]
- expected_not_empty_labels_list = [not_empty_label]
- # Check for adding labels list to Shape with no labels specified
- for no_labels_shape in [
- self.fully_covering_rectangle(),
- self.fully_covering_ellipse(),
- self.fully_covering_polygon(),
- ]:
- no_labels_shape.set_labels(new_labels_list)
- assert no_labels_shape.get_labels() == expected_not_empty_labels_list
- assert no_labels_shape.get_labels(include_empty=True) == new_labels_list
- # Check for adding empty labels list to Shape with no labels specified
- for no_labels_shape in [
- self.fully_covering_rectangle(),
- self.fully_covering_ellipse(),
- self.fully_covering_polygon(),
- ]:
- no_labels_shape.set_labels([])
- assert no_labels_shape.get_labels() == []
- assert no_labels_shape.get_labels(include_empty=True) == []
- # Check for adding labels list to Shape with labels specified
- for shape in [self.rectangle(), self.ellipse(), self.polygon()]:
- shape.set_labels(new_labels_list)
- assert shape.get_labels() == expected_not_empty_labels_list
- assert shape.get_labels(include_empty=True) == new_labels_list
- # Check for adding empty labels list to Shape with labels specified
- for shape in [self.rectangle(), self.ellipse(), self.polygon()]:
- shape.set_labels([])
- assert shape.get_labels() == []
- assert shape.get_labels(include_empty=True) == []
-
@pytest.mark.priority_medium
@pytest.mark.unit
@pytest.mark.reqids(Requirements.REQ_1)
diff --git a/ote_sdk/ote_sdk/tests/entities/test_annotation.py b/ote_sdk/ote_sdk/tests/entities/test_annotation.py
index 4d2177a23f8..c1ebb3a8937 100644
--- a/ote_sdk/ote_sdk/tests/entities/test_annotation.py
+++ b/ote_sdk/ote_sdk/tests/entities/test_annotation.py
@@ -81,8 +81,6 @@ def test_annotation_default_property(self):
annotation = self.annotation
- assert type(annotation.id_) == ID
- assert annotation.id_ is not None
assert str(annotation.shape) == "Rectangle(x=0.5, y=0.0, width=0.5, height=0.5)"
assert annotation.get_labels() == []
@@ -109,9 +107,6 @@ def test_annotation_setters(self):
annotation = self.annotation
ellipse = Ellipse(x1=0.5, y1=0.1, x2=0.8, y2=0.3)
annotation.shape = ellipse
- annotation.id_ = ID(123456789)
-
- assert annotation.id_ == ID(123456789)
assert annotation.shape == ellipse
@pytest.mark.priority_medium
@@ -144,7 +139,7 @@ def test_annotation_magic_methods(self):
assert (
repr(annotation)
- == "Annotation(shape=Ellipse(x1=0.5, y1=0.1, x2=0.8, y2=0.3), labels=[], id=123456789)"
+ == "Annotation(shape=Ellipse(x1=0.5, y1=0.1, x2=0.8, y2=0.3), labels=[]"
)
assert annotation == other_annotation
assert annotation != third_annotation
diff --git a/ote_sdk/ote_sdk/tests/entities/test_dataset_item.py b/ote_sdk/ote_sdk/tests/entities/test_dataset_item.py
index 71fd3ed1053..6ac0e5ab1bd 100644
--- a/ote_sdk/ote_sdk/tests/entities/test_dataset_item.py
+++ b/ote_sdk/ote_sdk/tests/entities/test_dataset_item.py
@@ -66,12 +66,10 @@ def annotations(self) -> List[Annotation]:
detection_annotation = Annotation(
shape=rectangle,
labels=[ScoredLabel(label=labels[0])],
- id=ID("detection_annotation_1"),
)
segmentation_annotation = Annotation(
shape=other_rectangle,
labels=[ScoredLabel(label=labels[1])],
- id=ID("segmentation_annotation_1"),
)
return [detection_annotation, segmentation_annotation]
@@ -109,7 +107,6 @@ def roi(self):
modification_date=datetime.datetime(year=2021, month=12, day=9),
),
labels=self.roi_scored_labels(),
- id=ID("roi_annotation"),
)
return roi
@@ -161,7 +158,6 @@ def compare_denormalized_annotations(
expected_annotation = expected_annotations[index]
# Redefining id and modification_date required because of new Annotation objects created after shape
# denormalize
- actual_annotation.id_ = expected_annotation.id_
actual_annotation.shape.modification_date = (
expected_annotation.shape.modification_date
)
@@ -191,12 +187,10 @@ def annotations_to_add(self) -> List[Annotation]:
annotation_to_add = Annotation(
shape=Rectangle(x1=0.1, y1=0.1, x2=0.7, y2=0.8),
labels=[ScoredLabel(label=labels_to_add[0])],
- id=ID("added_annotation_1"),
)
other_annotation_to_add = Annotation(
shape=Rectangle(x1=0.2, y1=0.3, x2=0.8, y2=0.9),
labels=[ScoredLabel(label=labels_to_add[1])],
- id=ID("added_annotation_2"),
)
return [annotation_to_add, other_annotation_to_add]
@@ -399,7 +393,6 @@ def test_dataset_item_roi_numpy(self):
rectangle_roi = Annotation(
Rectangle(x1=0.2, y1=0.1, x2=0.8, y2=0.9),
[ScoredLabel(roi_label)],
- ID("rectangle_roi"),
)
assert np.array_equal(
dataset_item.roi_numpy(rectangle_roi), media.numpy[1:9, 3:13]
@@ -408,7 +401,6 @@ def test_dataset_item_roi_numpy(self):
ellipse_roi = Annotation(
Ellipse(x1=0.1, y1=0.0, x2=0.9, y2=0.8),
[ScoredLabel(roi_label)],
- ID("ellipse_roi"),
)
assert np.array_equal(
dataset_item.roi_numpy(ellipse_roi), media.numpy[0:8, 2:14]
@@ -425,7 +417,6 @@ def test_dataset_item_roi_numpy(self):
]
),
labels=[],
- id=ID("polygon_roi"),
)
assert np.array_equal(
dataset_item.roi_numpy(polygon_roi), media.numpy[4:8, 5:13]
@@ -625,8 +616,6 @@ def test_dataset_item_append_annotations(self):
)
dataset_item.append_annotations(annotations_to_add)
# Random id is generated for normalized annotations
- normalized_annotations[0].id_ = dataset_item.annotation_scene.annotations[2].id_
- normalized_annotations[1].id_ = dataset_item.annotation_scene.annotations[3].id_
assert (
dataset_item.annotation_scene.annotations
== full_box_annotations + normalized_annotations
@@ -644,7 +633,6 @@ def test_dataset_item_append_annotations(self):
incorrect_shape_annotation = Annotation(
shape=incorrect_polygon,
labels=[ScoredLabel(incorrect_shape_label)],
- id=ID("incorrect_shape_annotation"),
)
dataset_item.append_annotations([incorrect_shape_annotation])
assert (
diff --git a/ote_sdk/ote_sdk/tests/entities/test_datasets.py b/ote_sdk/ote_sdk/tests/entities/test_datasets.py
index c5c0522c2de..abed07c140d 100644
--- a/ote_sdk/ote_sdk/tests/entities/test_datasets.py
+++ b/ote_sdk/ote_sdk/tests/entities/test_datasets.py
@@ -454,7 +454,6 @@ def check_empty_annotations_dataset(
assert actual_item.media is expected_item.media
assert actual_item.annotation_scene.annotations == []
assert actual_item.annotation_scene.kind == expected_kind
- assert actual_item.roi.id_ != expected_item.roi.id_
assert actual_item.roi.shape is expected_item.roi.shape
assert actual_item.roi.get_labels() == []
assert actual_item.subset is expected_item.subset
diff --git a/ote_sdk/ote_sdk/tests/entities/test_result_media.py b/ote_sdk/ote_sdk/tests/entities/test_result_media.py
index 2bddc58ccbf..73950605afb 100644
--- a/ote_sdk/ote_sdk/tests/entities/test_result_media.py
+++ b/ote_sdk/ote_sdk/tests/entities/test_result_media.py
@@ -38,7 +38,6 @@ def default_result_media_parameters() -> dict:
rectangle_annotation = Annotation(
shape=Rectangle(x1=0.1, y1=0.4, x2=0.4, y2=0.9),
labels=[ScoredLabel(rectangle_label)],
- id=ID("rectangle_annotation"),
)
annotation_scene = AnnotationSceneEntity(
annotations=[rectangle_annotation],
@@ -65,7 +64,6 @@ def optional_result_media_parameters(self) -> dict:
roi = Annotation(
shape=Rectangle(x1=0.3, y1=0.2, x2=0.7, y2=0.6),
labels=[ScoredLabel(roi_label)],
- id=ID("roi_annotation"),
)
result_media_label = LabelEntity(
"ResultMedia label",
diff --git a/ote_sdk/ote_sdk/tests/entities/test_subset.py b/ote_sdk/ote_sdk/tests/entities/test_subset.py
index a5ace251aea..ca00c0b7b5d 100644
--- a/ote_sdk/ote_sdk/tests/entities/test_subset.py
+++ b/ote_sdk/ote_sdk/tests/entities/test_subset.py
@@ -43,6 +43,7 @@ def test_subset_members(self):
TESTING = 3
UNLABELED = 4
PSEUDOLABELED = 5
+ UNASSIGNED = 6
Steps
1. Create enum instance
@@ -50,14 +51,14 @@ def test_subset_members(self):
"""
test_instance = Subset
- for i in range(0, 6):
+ for i in range(0, 7):
assert test_instance(i) in list(Subset)
with pytest.raises(AttributeError):
test_instance.WRONG
with pytest.raises(ValueError):
- test_instance(6)
+ test_instance(7)
@pytest.mark.priority_medium
@pytest.mark.unit
@@ -81,14 +82,14 @@ def test_subset_magic_str(self):
test_instance = Subset
magic_str_list = [str(i) for i in list(Subset)]
- for i in range(0, 6):
+ for i in range(0, 7):
assert str(test_instance(i)) in magic_str_list
with pytest.raises(AttributeError):
str(test_instance.WRONG)
with pytest.raises(ValueError):
- str(test_instance(6))
+ str(test_instance(7))
assert len(set(magic_str_list)) == len(magic_str_list)
@@ -113,13 +114,13 @@ def test_subset_magic_repr(self):
test_instance = Subset
magic_repr_list = [repr(i) for i in list(Subset)]
- for i in range(0, 6):
+ for i in range(0, 7):
assert repr(test_instance(i)) in magic_repr_list
with pytest.raises(AttributeError):
repr(test_instance.WRONG)
with pytest.raises(ValueError):
- repr(test_instance(6))
+ repr(test_instance(7))
assert len(set(magic_repr_list)) == len(magic_repr_list)
diff --git a/ote_sdk/ote_sdk/tests/utils/test_shape_drawer.py b/ote_sdk/ote_sdk/tests/utils/test_shape_drawer.py
index 7d55c7d980c..222f0e77cc0 100644
--- a/ote_sdk/ote_sdk/tests/utils/test_shape_drawer.py
+++ b/ote_sdk/ote_sdk/tests/utils/test_shape_drawer.py
@@ -600,7 +600,6 @@ def full_rectangle_annotation(self) -> Annotation:
return Annotation(
shape=Rectangle(x1=0, y1=0, x2=1, y2=1),
labels=self.full_rectangle_scored_labels(),
- id=ID("full_rectangle_annotation"),
)
@staticmethod
@@ -629,7 +628,6 @@ def rectangle_annotation(self) -> Annotation:
return Annotation(
shape=Rectangle(x1=0.1, y1=0.4, x2=0.4, y2=0.9),
labels=self.rectangle_scored_labels(),
- id=ID("rectangle_annotation"),
)
@staticmethod
@@ -666,7 +664,6 @@ def polygon_annotation(self) -> Annotation:
]
),
labels=self.polygon_scored_labels(),
- id=ID("polygon_annotation"),
)
@staticmethod
@@ -695,7 +692,6 @@ def ellipse_annotation(self) -> Annotation:
return Annotation(
shape=Ellipse(x1=0.5, y1=0.0, x2=1.0, y2=0.5),
labels=self.ellipse_scored_labels(),
- id=ID("ellipse_annotation"),
)
def annotation_scene(self) -> AnnotationSceneEntity:
diff --git a/ote_sdk/ote_sdk/utils/segmentation_utils.py b/ote_sdk/ote_sdk/utils/segmentation_utils.py
index 3e1c1111fe5..e19b8d698c0 100644
--- a/ote_sdk/ote_sdk/utils/segmentation_utils.py
+++ b/ote_sdk/ote_sdk/utils/segmentation_utils.py
@@ -12,11 +12,9 @@
import cv2
import numpy as np
-from bson import ObjectId
from ote_sdk.entities.annotation import Annotation
from ote_sdk.entities.dataset_item import DatasetItemEntity
-from ote_sdk.entities.id import ID
from ote_sdk.entities.label import LabelEntity
from ote_sdk.entities.scored_label import ScoredLabel
from ote_sdk.entities.shapes.polygon import Point, Polygon
@@ -254,7 +252,6 @@ def create_annotation_from_segmentation_map(
Annotation(
shape=polygon,
labels=[ScoredLabel(label, probability)],
- id=ID(ObjectId()),
)
)
else: