[go: nahoru, domu]

Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redesigned annotators #170

Merged
merged 73 commits into from
Sep 29, 2023
Merged

redesigned annotators #170

merged 73 commits into from
Sep 29, 2023

Conversation

SkalskiP
Copy link
Collaborator
@SkalskiP SkalskiP commented Jul 2, 2023

This PR expands our range of Annotators and makes them more reusable.

bounding-box-annotator-example
box-corner-annotator-example
ellipse-annotator-example
label-annotator-example-2
mask-annotator-example

@SkalskiP SkalskiP self-assigned this Jul 2, 2023
@SkalskiP
Copy link
Collaborator Author
SkalskiP commented Jul 2, 2023

@hardikdava I created a feature branch that we can use to redesign annotators and make them more modular according to our discussion here #168

I decided that we will conduct all work around annotators on this feature branch and when we are done we will merge this branch as a whole into main.

@hardikdava
Copy link
Collaborator
hardikdava commented Jul 3, 2023

Hi @SkalskiP 👋 , cool!. I will add modified box annotators in this branch.

@hardikdava hardikdava mentioned this pull request Jul 3, 2023
1 task
@hardikdava
Copy link
Collaborator

@SkalskiP I have created initial PR as #171 . Let me know how can I contribute in this week.

@hardikdava
Copy link
Collaborator

@SkalskiP Related feature request to this PR #172

@hardikdava
Copy link
Collaborator
hardikdava commented Jul 4, 2023

Test script to test new annotators.

import supervision as sv
import cv2
import numpy as np
from ultralytics import YOLO


img = cv2.imread("../data/zidane.jpg")

model = YOLO("yolov8s-seg.pt")

yolo_detect_result = model.predict([img], conf=0.5)[0]
detections = sv.Detections.from_yolov8(yolo_detect_result)

annotated_img = img.copy()

cat_maps = {0: "person", 27: "tie"}
labels = [f"{cat_maps[class_id]}" for _, _, _, class_id, _ in detections]

tracker_ids = np.array([1, 2, 3], dtype=int)
detections.tracker_id = tracker_ids  # Add tracker id to visualize color by tracker id


color_by_track = False   # Test with True and False
font_path = "font_path" # Test with actual path and None
skip_label = False  # Test with True and False

detection_annotator = sv.DetectionAnnotator(color_by_track=color_by_track, skip_label=skip_label)
segmentation_annotator = sv.SegmentationAnnotator(color_by_track=color_by_track, skip_label=skip_label)

box_annotator = sv.BoxAnnotator(color_by_track=color_by_track)
label_annotator = sv.LabelAnnotator(color_by_track=color_by_track)
mask_annotator = sv.MaskAnnotator(color_by_track=color_by_track)

boxmask_annotator = sv.BoxMaskAnnotator(color_by_track=color_by_track)
cornered_box_annotator = sv.CorneredBoxAnotator(color_by_track=color_by_track)
pil_label_annotator = sv.PillowLabelAnnotator(color_by_track=color_by_track, font=font_path )


annotators = {"label": label_annotator, "pill-label": pil_label_annotator, "box": box_annotator, "cornered_box": cornered_box_annotator, "box-mask": boxmask_annotator, "mask": mask_annotator, "detection":
              detection_annotator, "segmentation": segmentation_annotator}


for key, value in annotators.items():
    if key in ["label", "detection", "segmentation", "pill-label"]:
        annotated_img = annotators[key].annotate(scene=img.copy(), detections=detections, labels=labels)
    elif key == "pill-label":
        annotated_img = pil_label_annotator.annotate(scene=img.copy(), detections=detections, labels=labels)
    else:
        annotated_img = annotators[key].annotate(scene=img.copy(), detections=detections)
    cv2.imshow(key, annotated_img)
    cv2.waitKey(0)


@hardikdava
Copy link
Collaborator

@SkalskiP I made progress on this feature. PillowLabelAnnotator is only not implemented yet. All other annotators are implemented and tested locally.

@hardikdava
Copy link
Collaborator

Hi @SkalskiP 👋 I am planning to keep continue contribute to supervision. I have some questions 😕,

  • How to update docs?
  • Should we start using Github Projects? That will be useful for planning, prioritization, task assignment and keeping tracks on the issue.

@SkalskiP SkalskiP added the version: 0.12.0 Feature to be added in `0.12.0` release label Jul 4, 2023
@SkalskiP
Copy link
Collaborator Author
SkalskiP commented Jul 4, 2023

@hardikdava, how about meeting for 30 minutes on video call and talking through the priorities?

In principle, I would like us to be focused on those tasks in the first place: #181, but with all the loose ends I think meeting is the right move.

@hardikdava
Copy link
Collaborator

@SkalskiP Of course, we can talk. Let me know when we can have a short call.

@SkalskiP
Copy link
Collaborator Author
SkalskiP commented Jul 5, 2023

@hardikdava zoom or google meet?

@hardikdava
Copy link
Collaborator
hardikdava commented Jul 5, 2023

@SkalskiP Google meet is fine.

@SkalskiP
Copy link
Collaborator Author
SkalskiP commented Jul 5, 2023

@hardikdava you are based in Germany? Can we meet at 8 PM? Or you'd like to do it earlier?

@hardikdava
Copy link
Collaborator

@SkalskiP Yeah, I am based in Germany. Would it possible to talk at 6 PM?

@SkalskiP
Copy link
Collaborator Author
SkalskiP commented Jul 5, 2023

@hardikdava, not today, but I could meet at 6 PM tomorrow. How about that?

@hardikdava
Copy link
Collaborator

@SkalskiP let's talk at 8 PM today then. I can make it.

@hardikdava
Copy link
Collaborator

@SkalskiP On side note, I am adding PillowLabelAnnotator(). Do we have any specific default font?

@SkalskiP
Copy link
Collaborator Author

@onuralpszr sure you can merge it in once I'm ready. I'm still not done, but tests are looking good. You can take a look here:

https://colab.research.google.com/drive/1iso4sYNNERe6KqH6zUixF7XwsapbCgzZ?usp=sharing

@SkalskiP
Copy link
Collaborator Author

@hardikdava and @onuralpszr take a look at the PR 🙏🏻

I dropped a few things from PR. We will add them to the next PRs. Still, we are getting most of the functionalities here.

I tested the changes here: https://colab.research.google.com/drive/1iso4sYNNERe6KqH6zUixF7XwsapbCgzZ?usp=sharing

Copy link
Collaborator
@hardikdava hardikdava left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks fine to me.

@onuralpszr
Copy link
Collaborator

I am still looking and adding something will post soon

@SkalskiP
Copy link
Collaborator Author

@onuralpszr let me know when you are ready ;)

…on adjusted

Signed-off-by: Onuralp SEZER <thunderbirdtr@gmail.com>
@SkalskiP
Copy link
Collaborator Author

@onuralpszr, are we ready to merge?

Copy link
Collaborator
@onuralpszr onuralpszr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hardikdava @SkalskiP thank you both for your awesome work. I am merging into develop let's continue make supervision even better.

@onuralpszr onuralpszr merged commit 36f95d0 into develop Sep 29, 2023
6 checks passed
@SkalskiP
Copy link
Collaborator Author
SkalskiP commented Oct 2, 2023

@onuralpszr I'm going to promote that feature hard this and next week!

@SkalskiP SkalskiP deleted the feature/redesigned_annotators branch January 2, 2024 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
version: 0.12.0 Feature to be added in `0.12.0` release version: 0.13.0 Feature to be added in `0.13.0` release version 0.14.0 Feature to be added in `0.14.0` release version: 0.15.0 Feature to be added in `0.15.0` release
Projects
Status: Current Release: Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants