diff --git a/robots-at-runes/research/dataset/blend/examples/logo.xml b/robots-at-runes/research/dataset/blend/examples/logo.xml index 3257c42a214d14f0e57eca4057ff28e00be864cb..b3d47c380c48ee78c5a264568ed62ee8271f5ec7 100644 --- a/robots-at-runes/research/dataset/blend/examples/logo.xml +++ b/robots-at-runes/research/dataset/blend/examples/logo.xml @@ -2,9 +2,11 @@ <point> <x>432</x> <y>76</y> + <label>green</label> </point> <point> <x>432</x> <y>13</y> + <label>blue</label> </point> </annotation> diff --git a/robots-at-runes/research/dataset/blend/image_blender.py b/robots-at-runes/research/dataset/blend/image_blender.py index 8e30abde4758af840f452bf95b5c0ad6eb389eef..c19202e3d159e3298ede9df9695cf388a5f20c7f 100644 --- a/robots-at-runes/research/dataset/blend/image_blender.py +++ b/robots-at-runes/research/dataset/blend/image_blender.py @@ -56,7 +56,7 @@ class ImageBlender: @staticmethod def _translate_poi(poi: PointOfInterest, x: int, y: int) -> PointOfInterest: - return PointOfInterest(poi.x + x, poi.y + y) + return PointOfInterest(poi.x + x, poi.y + y, poi.label) def _crop_background(self, background: Image) -> Image: h, w, _ = background.shape @@ -89,7 +89,8 @@ if __name__ == "__main__": res.save(EXAMPLES_DIR, f"test_{i}") plt.imshow(res.image) - plt.plot([poi.x for poi in res.point_of_interests], [poi.y for poi in res.point_of_interests], "r.") + for poi in res.point_of_interests: + plt.plot([poi.x], [poi.y], f"{poi.label[0]}.") plt.axis("off") plt.tight_layout() plt.show() diff --git a/robots-at-runes/research/dataset/blend/labeled_image_modifiers/labeled_image_rotator.py b/robots-at-runes/research/dataset/blend/labeled_image_modifiers/labeled_image_rotator.py index b73c1eb06c6bbd84666ba74df4a1b1281af8610a..860972cbf0cc10519f982ef1a799c342bfc43361 100644 --- a/robots-at-runes/research/dataset/blend/labeled_image_modifiers/labeled_image_rotator.py +++ b/robots-at-runes/research/dataset/blend/labeled_image_modifiers/labeled_image_rotator.py @@ -25,7 +25,9 @@ class LabeledImageRotator(LabeledImageModifierABC): prev_vector_to_center = np.array((poi.x - original_image.shape[1] / 2, poi.y - original_image.shape[0] / 2)) new_vector_to_center = np.dot(rotation_matrix, prev_vector_to_center) return PointOfInterest( - int(new_vector_to_center[0] + new_image.shape[1] / 2), int(new_vector_to_center[1] + new_image.shape[0] / 2) + int(new_vector_to_center[0] + new_image.shape[1] / 2), + int(new_vector_to_center[1] + new_image.shape[0] / 2), + poi.label, ) def _get_value_from_factor(self, factor: float) -> float: diff --git a/robots-at-runes/research/dataset/blend/labeled_image_modifiers/labeled_image_scaler.py b/robots-at-runes/research/dataset/blend/labeled_image_modifiers/labeled_image_scaler.py index 73f9255d5f4dc537bc93e38291c3ea862328bd67..b98e25f4fa1a32e4197984864fe887dd7690b024 100644 --- a/robots-at-runes/research/dataset/blend/labeled_image_modifiers/labeled_image_scaler.py +++ b/robots-at-runes/research/dataset/blend/labeled_image_modifiers/labeled_image_scaler.py @@ -19,7 +19,7 @@ class LabeledImageScaler(LabeledImageModifierABC): def _generate_modified_poi( self, poi: PointOfInterest, original_image: Image, new_image: Image, scale: float ) -> PointOfInterest: - return PointOfInterest(int(poi.x * scale), int(poi.y * scale)) + return PointOfInterest(int(poi.x * scale), int(poi.y * scale), poi.label) def _get_value_from_factor(self, factor: float) -> float: intensity = (self.max_scale - 1) * abs(factor) + 1 diff --git a/robots-at-runes/research/dataset/labeled_image.py b/robots-at-runes/research/dataset/labeled_image.py index 2d66cc32e32af2979e13c7a24944b298040d6a41..30d0dac6880f554786789cff8364ccac0d93a663 100644 --- a/robots-at-runes/research/dataset/labeled_image.py +++ b/robots-at-runes/research/dataset/labeled_image.py @@ -13,13 +13,14 @@ from polystar.common.models.image import Image class PointOfInterest: x: int y: int + label: str def to_dict(self) -> Dict[str, int]: return self.__dict__ @classmethod def from_dict(cls, d: Dict[str, Any]): - return cls(x=int(d["x"]), y=int(d["y"])) + return cls(x=int(d["x"]), y=int(d["y"]), label=d["label"]) @classmethod def from_annotation_file(cls, annotation_path: Path) -> List["PointOfInterest"]: