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

DataDreamer - v0.2.0 #68

Merged
merged 60 commits into from
Nov 12, 2024
Merged
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
0137b8f
chore: update requirements.txt
sokovninn Apr 29, 2024
ce1d8d1
Merge branch 'main' into dev
sokovninn Apr 29, 2024
15fe38a
feature: add dataset_plugin argument
sokovninn May 8, 2024
a8f12dd
docs: improve dataset_plugin description
sokovninn May 8, 2024
a5975cf
Merge pull request #55 from luxonis/feature/luxonis-online-dataset
sokovninn May 9, 2024
0ada3cc
fix: dataset plugin default value
sokovninn Jun 26, 2024
872d001
Feature/luxonis loader dataset (#57)
sokovninn Aug 5, 2024
931390d
Merge main to dev (#58)
sokovninn Aug 8, 2024
a1ea12b
chore: fix gar publish dev action
sokovninn Aug 9, 2024
6b580ba
feature: add branch arg to Dockerfile
sokovninn Aug 9, 2024
307102c
fix: build dev docker image from dev branch
sokovninn Aug 9, 2024
b3a23ea
Fix/bbox labels in LuxonisDatasetConverter (#59)
sokovninn Aug 20, 2024
9653ec3
fix: save images as PNG with full quality (#60)
conorsim Sep 18, 2024
e563c97
Fix: loader plugin arg to load image paths (#61)
conorsim Sep 20, 2024
f800b49
Add logger, tests and refactor (#62)
sokovninn Sep 27, 2024
196e4ca
feat: add prompt weighting for sdxl-turbo (#65)
sokovninn Oct 2, 2024
a5afb36
Rework GHCR publish actions (#64)
sokovninn Oct 2, 2024
154c50e
Add profanity filter for input class names (#63)
HonzaCuhel Oct 7, 2024
725d353
Add Qwen2.5 LM as prompt generator (#66)
HonzaCuhel Oct 8, 2024
3d3c88e
Add FastSAM
HonzaCuhel Oct 17, 2024
f2dbf33
Update
HonzaCuhel Oct 19, 2024
535d09a
Update Colab notebook
HonzaCuhel Oct 19, 2024
454d749
Add vizualization
HonzaCuhel Oct 20, 2024
7bb93e9
Update README.md and tests
HonzaCuhel Oct 21, 2024
3fcb736
Update COCO converter
HonzaCuhel Oct 21, 2024
5a0795d
Refactor YOLO converter
HonzaCuhel Oct 21, 2024
c0cf6ab
Refactor visualize function
HonzaCuhel Oct 21, 2024
a1c6b6a
[Automated] Updated coverage badge
actions-user Oct 21, 2024
7879220
fix: different color for different classes in the segmenetation visua…
sokovninn Oct 21, 2024
4fae718
Switch to SlimSAM
HonzaCuhel Oct 24, 2024
f40e5a0
Switch to SlimSAM
HonzaCuhel Oct 24, 2024
853d5ad
Update instance segmentation example
HonzaCuhel Oct 24, 2024
04e91fd
Update tests
HonzaCuhel Oct 24, 2024
ff771ad
Fix: annotator tests
HonzaCuhel Oct 24, 2024
335cc05
[Automated] Updated coverage badge
actions-user Oct 24, 2024
f887910
Update docs & luxonis dataset creation
HonzaCuhel Oct 25, 2024
b8151cb
fix: return SliamSAM processor
sokovninn Oct 25, 2024
af08e4b
fix: handle empty polygon list
sokovninn Oct 25, 2024
c566bea
Fix: remove long outputs from Jupyter Notebook
HonzaCuhel Oct 25, 2024
07a58f0
Fix: README.md
HonzaCuhel Oct 25, 2024
057a9b4
Add OWLv2 non-square pixel fix
HonzaCuhel Oct 25, 2024
437d067
Rename vars
HonzaCuhel Oct 25, 2024
cd819c4
Fix: correct all SlimSAM mentions
HonzaCuhel Oct 25, 2024
5e45347
fix: different image sizes for owlv2 postprocessing
sokovninn Oct 25, 2024
3b915ba
Update OWLv2 bbox correction
HonzaCuhel Oct 25, 2024
68487e4
fix: pass segmentation annotator size
sokovninn Oct 25, 2024
5401431
fix: shifted annotations when tta is used
sokovninn Oct 25, 2024
d47253a
Fix OWLv2 device
HonzaCuhel Oct 28, 2024
cba6516
Merge pull request #67 from luxonis/feat/add-instance-segmentation
HonzaCuhel Oct 28, 2024
72608b8
Merge branch 'main' into dev
sokovninn Oct 29, 2024
3aeab4d
[Automated] Updated coverage badge
actions-user Oct 29, 2024
1914f7d
chore: update version to 0.2.0
sokovninn Oct 29, 2024
72f2aa4
Fix: convert images to RGB (#69)
HonzaCuhel Oct 30, 2024
749696d
[Automated] Updated coverage badge
actions-user Oct 30, 2024
77be96e
Fix: LuxonisDataset Converter - bbox computation (#70)
HonzaCuhel Nov 3, 2024
ec4df44
[Automated] Updated coverage badge
actions-user Nov 3, 2024
6a62e94
Add images without annotations to LuxonisDataset (#71)
sokovninn Nov 8, 2024
e9bde26
[Automated] Updated coverage badge
actions-user Nov 8, 2024
c89ca34
Add an option to keep images with no annotation (#72)
HonzaCuhel Nov 12, 2024
0ebcd68
[Automated] Updated coverage badge
actions-user Nov 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add vizualization
HonzaCuhel committed Oct 20, 2024
commit 454d749a1496ac782cda2473a9c226387ad36ba2
7 changes: 2 additions & 5 deletions datadreamer/pipelines/generate_dataset_from_scratch.py
Original file line number Diff line number Diff line change
@@ -651,16 +651,13 @@ def read_image_batch(image_batch, batch_num, batch_size):
box = boxes_batch[j][k]
score = scores_batch[j][k]
label = local_labels_batch[j][k]

if args.task == "instance-segmentation":
if k < len(masks_batch[j]):
mask = masks_batch[j][k]
# Unzip the list of points into separate x and y lists
x_points, y_points = zip(*mask)

# Fill the polygon defined by the points to create the mask
ax.fill(
x_points, y_points, "blue", alpha=0.5
) # 'blue' for mask color and alpha for transparency
ax.fill(x_points, y_points, "blue", alpha=0.5)

labels.append(label)
x1, y1, x2, y2 = box
1 change: 1 addition & 0 deletions datadreamer/utils/coco_converter.py
Original file line number Diff line number Diff line change
@@ -128,6 +128,7 @@ def process_data(
):
bbox = [box[0], box[1], box[2] - box[0], box[3] - box[1]]
segmentation = (
# (np.array(mask)*np.array([image_width, image_height])).reshape(-1).tolist()
np.array(mask).reshape(-1).tolist()
if mask is not None
else None
11 changes: 7 additions & 4 deletions datadreamer/utils/luxonis_dataset_converter.py
Original file line number Diff line number Diff line change
@@ -86,16 +86,19 @@ def dataset_generator():
}

if "masks" in data[image_path]: # polyline format
poly = []
masks = data[image_path]["masks"]
for m in masks:
poly = [[point[0] / width, point[1] / height] for point in m]
for mask, label in zip(masks, labels):
poly = []
for m in mask:
poly += [
(point[0] / width, point[1] / height) for point in m
]
yield {
"file": image_full_path,
"annotation": {
"type": "polyline",
"class": class_names[label],
"points": poly,
"points": poly, # masks,
},
}

21 changes: 12 additions & 9 deletions datadreamer/utils/yolo_converter.py
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import shutil
from typing import Dict, List

import numpy as np
from PIL import Image

from datadreamer.utils import BaseConverter
@@ -76,24 +77,26 @@ def convert_to_yolo_format(
return [x_center, y_center, width, height]

def convert_masks_to_yolo_format(
self, masks: List[List[float]], image_width: int, image_height: int
self, masks: List[List[float]], w: int, h: int
) -> List[float]:
"""Converts masks to YOLO format.

Args:
masks (list of list of float): A list containing the masks.
image_width (int): The width of the image.
image_height (int): The height of the image.
w (int): The width of the image.
h (int): The height of the image.

Returns:
list of float: A list containing the masks in YOLO format.
"""
yolo_masks = []
for mask in masks:
x, y = mask[0], mask[1]
yolo_masks.append(x / image_width)
yolo_masks.append(y / image_height)
return yolo_masks
# yolo_masks = []
# for mask in masks:
# x, y = mask[0], mask[1]
# yolo_masks.append(x / image_width)
# yolo_masks.append(y / image_height)
# return yolo_masks
return (np.array(masks) / np.array([w, h])).reshape(-1).tolist()
# return np.array(masks).reshape(-1).tolist()

def process_data(
self,
Original file line number Diff line number Diff line change
@@ -270,6 +270,9 @@
},
"outputs": [],
"source": [
"import os\n",
"os.environ['WANDB_DISABLED'] = 'true'\n",
"\n",
"results = model.train(data=\"generated_dataset_yolo/data.yaml\", epochs=50)"
]
},
21 changes: 18 additions & 3 deletions examples/visualize_detection_dataset.py
Original file line number Diff line number Diff line change
@@ -3,9 +3,10 @@
import os

import cv2
import numpy as np


def draw_rounded_rectangle(img, pt1, pt2, color, thickness, r, d):
def draw_rounded_rectangle(img, pt1, pt2, color, thickness, r, masks=None):
x1, y1 = pt1
x2, y2 = pt2

@@ -24,6 +25,13 @@ def draw_rounded_rectangle(img, pt1, pt2, color, thickness, r, d):
cv2.ellipse(img, (x2 - r, y2 - r), (r, r), 0, 0, 90, color, thickness)


def draw_mask(image, mask, color, alpha=0.5):
overlay = image.copy()
mask = np.array([[int(p[0]), int(p[1])] for p in mask])
cv2.fillPoly(overlay, [mask], color)
cv2.addWeighted(overlay, alpha, image, 1 - alpha, 0, image)


def draw_bboxes_and_labels(image, annotations, class_names):
font = cv2.FONT_HERSHEY_SIMPLEX
font_scale = 1.5 # Increased font size
@@ -32,7 +40,10 @@ def draw_bboxes_and_labels(image, annotations, class_names):
text_color = (255, 255, 255) # White text
rectangle_radius = 8

for bbox, label in zip(annotations["boxes"], annotations["labels"]):
for i in range(len(annotations["boxes"])):
bbox = annotations["boxes"][i]
label = annotations["labels"][i]

x_min, y_min, x_max, y_max = map(int, bbox)
label_text = class_names[label]

@@ -54,6 +65,10 @@ def draw_bboxes_and_labels(image, annotations, class_names):
1,
)

if "masks" in annotations:
masks = annotations["masks"][i]
draw_mask(image, masks, (0, 255, 0), 0.5)

# Draw text background
draw_rounded_rectangle(
image,
@@ -89,7 +104,7 @@ def visualize_dataset(dataset_dir, save_images):

for image_name, annotations in all_annotations.items():
image_path = image_name
image = cv2.imread(image_path)
image = cv2.imread(os.path.join(dataset_dir, image_path))
image = draw_bboxes_and_labels(image, annotations, class_names)

if save_images: