-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Advanced BoxAnnotator馃ぉ #168
Comments
@hardikdava Haha I see you want to do annotators :) How about we do this first? #49 |
Uuuu! Looks cool! 馃敟 I drove for a few hours yesterday and thought a lot about our annotators. And I think we can use that opportunity to redesign that feature and make it even more flexible. I think we should split annotators and make them composable. What do you think @hardikdava? Here is my idea: import numpy as np
from abc import ABC, abstractmethod
from typing import List
# base annotator
class BaseAnnotator(ABC):
def annotate(self, scene: np.ndarray, detections: Detections) -> np.ndarray:
pass
class ComposableAnnotator(ABC):
def __init__(self, annotators: List[BaseAnnotator]):
self.annotators = annotators
def annotate(self, scene: np.ndarray, detections: Detections) -> np.ndarray:
annotated_image = scene
for annotator in self.annotators:
annotated_image = annotator.annotate(scene=scene, detections=detections)
return annotated_image
# single responsibility annotator
class BoxAnnotator(BaseAnnotator):
def annotate(self, scene: np.ndarray, detections: Detections) -> np.ndarray:
pass
class PolygonMaskAnnotator(BaseAnnotator):
def annotate(self, scene: np.ndarray, detections: Detections) -> np.ndarray:
pass
class LabelAnnotator(BaseAnnotator):
def annotate(self, scene: np.ndarray, detections: Detections) -> np.ndarray:
pass
class PillowLabelAnnotator(BaseAnnotator):
def annotate(self, scene: np.ndarray, detections: Detections) -> np.ndarray:
pass
class TrackAnnotator(BaseAnnotator):
def annotate(self, scene: np.ndarray, detections: Detections) -> np.ndarray:
pass
class BoxMaskAnnotator(BaseAnnotator):
def annotate(self, scene: np.ndarray, detections: Detections) -> np.ndarray:
pass
# high level annotators
class DetectionAnnotator(ComposableAnnotator):
@classmethod
def init(cls):
annotators = [
BoxAnnotator(),
LabelAnnotator()
]
return cls(annotators=annotators)
class SegmentationAnnotator(ComposableAnnotator):
@classmethod
def init(cls):
annotators = [
BoxAnnotator(),
LabelAnnotator()
]
return cls(annotators=annotators)
class TrackedDetectionAnnotator(ComposableAnnotator):
@classmethod
def init(cls):
annotators = [
BoxAnnotator(),
LabelAnnotator(),
TrackAnnotator()
]
return cls(annotators=annotators) |
Hey @SkalskiP 馃憢 , this is actually a nice idea of having computer vision task based annotators along with single responsible annotators. |
Hi @hardikdava 馃憢馃徎 ! I know But I mostly mean to give people base annotators that they could freely combine. |
Hi @SkalskiP 馃憢 , I am 馃挴 agree with you about adding |
@hardikdava how about the overall idea? 馃挕 |
I would keep this as simple as possible. User can choose between
|
I don鈥檛 want to use pillow for drawing boxes. I want to use pillow only for text annotation and I want to separate drawing labels from drawing boxes. |
@SkalskiP Overall, this is really good idea and your suggested APIs are good for future. It is highly scalabel. |
Exactly. Problem is that we would need to do it in the way that people could migrate from old API to new API. |
I do not think of any problems of migration with the suggested API. This will work without any issue. |
@hardikdava I'll create the initial PR to set up the structure, and we will migrate all annotators one by one. Okey? |
@SkalskiP okay. I will be waiting for the issue. |
@hardikdava can you open PR with this annotator into the |
Of course. I will make a PR. |
Hi @hardikdava 馃憢馃徎! Sorry I move so slowly. I'm doing a lot of stuff other than |
@SkalskiP understood. It's fine. I am working on |
@maddust 馃敟! This looks amazing! You are truly a |
This task is finally completed with: https://github.com/roboflow/supervision/releases/tag/0.15.0 馃敟 |
Search before asking
Description
Current
sv.BoxAnnotator
is drawing boxes based on opencv rectangle. It can be improved for this kind of boxes. This looks pretty cool!Use case
No response
Additional
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: