Dimitri Korsch 6 роки тому
батько
коміт
7824f0b44a
1 змінених файлів з 17 додано та 0 видалено
  1. 17 0
      nabirds/dataset/part.py

+ 17 - 0
nabirds/dataset/part.py

@@ -48,6 +48,7 @@ class Parts(object):
 	def visible_crops(self, *args, **kwargs):
 		return np.array([p.crop(*args, **kwargs) for p in self._parts])
 
+
 class BasePart(ABC):
 	def __init__(self, image, annotation):
 		super(BasePart, self).__init__()
@@ -79,6 +80,22 @@ class BasePart(ABC):
 	@property
 	def xy(self):
 		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
 	def crop(self, padding_mode="edge", *args, **kwargs):