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

Feat/add instance segmentation #67

Merged
merged 29 commits into from
Oct 28, 2024
Merged

Conversation

HonzaCuhel
Copy link
Contributor

@HonzaCuhel HonzaCuhel commented Oct 21, 2024

This PR includes adding the option to generate an instance-segmentation dataset.

It includes:

  • OWLv2 + SlimSAM for image annotation
  • Updated documentation, examples, tests
  • Annotation bug fixes

Copy link

github-actions bot commented Oct 21, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
1662 1051 63% 0% 🟢

New Files

File Coverage Status
datadreamer/dataset_annotation/slimsam_annotator.py 82% 🟢
TOTAL 82% 🟢

Modified Files

File Coverage Status
datadreamer/dataset_annotation/init.py 100% 🟢
datadreamer/dataset_annotation/owlv2_annotator.py 70% 🟢
datadreamer/dataset_annotation/utils.py 75% 🟢
datadreamer/pipelines/generate_dataset_from_scratch.py 38% 🟢
datadreamer/utils/coco_converter.py 96% 🟢
datadreamer/utils/config.py 100% 🟢
datadreamer/utils/convert_dataset.py 21% 🟢
datadreamer/utils/dataset_utils.py 84% 🟢
datadreamer/utils/luxonis_dataset_converter.py 75% 🟢
datadreamer/utils/yolo_converter.py 83% 🟢
TOTAL 74% 🟢

updated for commit: d47253a by action🐍

Copy link

github-actions bot commented Oct 21, 2024

Test Results

  6 files    6 suites   1h 39m 49s ⏱️
 69 tests  55 ✅ 14 💤 0 ❌
414 runs  326 ✅ 88 💤 0 ❌

Results for commit d47253a.

♻️ This comment has been updated with latest results.

Copy link

@klemen1999 klemen1999 left a comment

Choose a reason for hiding this comment

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

Added some comments, otherwise LGTM

README.md Outdated Show resolved Hide resolved
requirements.txt Outdated Show resolved Hide resolved
Comment on lines +93 to +106
n = len(images)

for i in range(n):
boxes = boxes_batch[i].tolist()
if len(boxes) == 0:
final_segments.append([])
continue

inputs = self.processor(
images[i], input_boxes=[boxes], return_tensors="pt"
).to(self.device)

with torch.no_grad():
outputs = self.model(**inputs, return_dict=True)
Copy link
Member

Choose a reason for hiding this comment

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

SlimSAM doesn't support batched inference?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The thing is that each image can have different number of detected objects, and in that case the batched inference isn't possible straight away , so that's why I implemented it per image. But now that you've mentioned it, I thought about it again and realized that we could "padd" the bboxes with dummy bboxes, so that we can have batch inference, I'm currrently testing it. Let me know @sokovninn, if you'd find this small hack better.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I see. Dummy bboxes is a good solution. However, I am not sure if it will bring any boost in inference speed, but it is worth a try I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly, I'll test it and let you know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It turned out not to be faster, so not gonna use it.

README.md Outdated Show resolved Hide resolved
@HonzaCuhel HonzaCuhel merged commit cba6516 into dev Oct 28, 2024
9 checks passed
@sokovninn sokovninn deleted the feat/add-instance-segmentation branch November 12, 2024 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants