|
@@ -48,6 +48,7 @@ class Parts(object):
|
|
def visible_crops(self, *args, **kwargs):
|
|
def visible_crops(self, *args, **kwargs):
|
|
return np.array([p.crop(*args, **kwargs) for p in self._parts])
|
|
return np.array([p.crop(*args, **kwargs) for p in self._parts])
|
|
|
|
|
|
|
|
+
|
|
class BasePart(ABC):
|
|
class BasePart(ABC):
|
|
def __init__(self, image, annotation):
|
|
def __init__(self, image, annotation):
|
|
super(BasePart, self).__init__()
|
|
super(BasePart, self).__init__()
|
|
@@ -79,6 +80,22 @@ class BasePart(ABC):
|
|
@property
|
|
@property
|
|
def xy(self):
|
|
def xy(self):
|
|
return np.array([self.x, self.y])
|
|
return np.array([self.x, self.y])
|
|
|
|
+ @property
|
|
|
|
+ def c(self):
|
|
|
|
+ h, w, c = utils.dimensions(self.image)
|
|
|
|
+ return c
|
|
|
|
+
|
|
|
|
+ @abstractmethod
|
|
|
|
+ def crop(self, ratio=None, padding_mode="edge"):
|
|
|
|
+ raise NotImplementedError
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+class LocationPart(BasePart):
|
|
|
|
+
|
|
|
|
+ def read_annotation(self, annotation):
|
|
|
|
+ # here x,y are the center of the part
|
|
|
|
+ self._id, self.x, self.y, self.is_visible = annotation
|
|
|
|
+ self._ratio = None
|
|
|
|
|
|
@abstractmethod
|
|
@abstractmethod
|
|
def crop(self, padding_mode="edge", *args, **kwargs):
|
|
def crop(self, padding_mode="edge", *args, **kwargs):
|