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
Show file tree
Hide file tree
Changes from 52 commits
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
6 changes: 4 additions & 2 deletions .github/workflows/gar-publish-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@main
with:
ref: dev # Checkout the dev branch

- id: 'auth'
name: 'Authenticate to Google Cloud'
Expand All @@ -34,5 +36,5 @@ jobs:
- name: 'Build Inventory Image'
working-directory: .
run: |
docker build --build-arg GITHUB_TOKEN=${{secrets.GHCR_PAT}} . --tag $GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/internal/datadreamer:dev
docker push $GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/internal/datadreamer --all-tags
docker build --build-arg GITHUB_TOKEN=${{secrets.GHCR_PAT}} --build-arg BRANCH=dev . --tag $GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/internal/datadreamer:dev
docker push $GAR_LOCATION-docker.pkg.dev/$PROJECT_ID/internal/datadreamer --all-tags
2 changes: 0 additions & 2 deletions .github/workflows/gar-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ name: Deploy single image to GAR (Google Artifact Registry)

on:
workflow_dispatch:
release:
types: [published]
env:
PROJECT_ID: easyml-394818
GAR_LOCATION: us-central1
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/ghcr-publish-manual.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Manually deploy image to GHCR

on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to deploy'
required: true
default: 'dev'

env:
GHCR_REGISTRY: ghcr.io
IMAGE_NAME: datadreamer

jobs:
push-store:
name: Push the image to GHCR
runs-on: ubuntu-latest

steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v2
with:
ref: ${{ inputs.branch }} # Checkout the selected branch

- name: 'Extract short commit hash'
id: commit_hash
run: echo "short_hash=$(git rev-parse --short HEAD)" >> $GITHUB_ENV

- name: Docker login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: luxonis-ml
password: ${{ secrets.GHCR_PAT }}

- name: 'Build and Push Image to GHCR'
run: |
docker build --build-arg GITHUB_TOKEN=${{secrets.GHCR_PAT}} --build-arg BRANCH=${{ inputs.branch }} . \
--tag ghcr.io/luxonis/datadreamer:${{ steps.commit_hash.outputs.short_hash }}
docker push ghcr.io/luxonis/datadreamer --all-tags
2 changes: 1 addition & 1 deletion .github/workflows/ghcr-publish.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Docker Build and Publish
name: Deploy latest image to GHCR on release

on:
workflow_dispatch:
Expand Down
34 changes: 17 additions & 17 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,23 @@ name: Tests

on:
pull_request:
branches: [ dev, main ]
branches: [ main ]
paths:
- 'datadreamer/**/**.py'
- 'tests/**/**.py'
- 'tests/core_tests/**/**.py'
- .github/workflows/tests.yaml
workflow_dispatch:

jobs:
run_tests:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
os: [buildjet-8vcpu-ubuntu-2204, windows-latest, macOS-latest]
version: ['3.10', '3.11']
exclude:
- os: buildjet-8vcpu-ubuntu-2204
version: '3.11'

runs-on: ${{ matrix.os }}

Expand All @@ -31,56 +35,52 @@ jobs:
cache: pip

- name: Install dependencies [Ubuntu]
if: matrix.os == 'ubuntu-latest'
if: matrix.os == 'buildjet-8vcpu-ubuntu-2204'
run: |
sudo apt update
sudo apt install -y pandoc
pip install -e .[dev]
pip install coverage-badge>=1.1.0 pytest-cov>=4.1.0

- name: Install dependencies [Windows]
if: matrix.os == 'windows-latest'
run: |
pip install -e .[dev]
pip install coverage-badge>=1.1.0 pytest-cov>=4.1.0

- name: Install dependencies [macOS]
if: matrix.os == 'macOS-latest'
run: |
pip install -e .[dev]
pip install coverage-badge>=1.1.0 pytest-cov>=4.1.0

- name: Run tests with coverage [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10'
run: pytest tests --cov=datadreamer --cov-report xml --junit-xml pytest.xml
if: matrix.os == 'buildjet-8vcpu-ubuntu-2204' && matrix.version == '3.10'
run: pytest tests/core_tests --cov=datadreamer --cov-report xml --junit-xml pytest.xml

- name: Run tests [Windows, macOS]
if: matrix.os != 'ubuntu-latest' || matrix.version != '3.10'
run: pytest tests --junit-xml pytest.xml
if: matrix.os != 'buildjet-8vcpu-ubuntu-2204'
run: pytest tests/core_tests --junit-xml pytest.xml

- name: Generate coverage badge [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10'
if: matrix.os == 'buildjet-8vcpu-ubuntu-2204' && matrix.version == '3.10'
run: coverage-badge -o media/coverage_badge.svg -f

- name: Generate coverage report [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10'
if: matrix.os == 'buildjet-8vcpu-ubuntu-2204' && matrix.version == '3.10'
uses: orgoro/[email protected]
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}

- name: Commit coverage badge [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10'
if: matrix.os == 'buildjet-8vcpu-ubuntu-2204' && matrix.version == '3.10'
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
git diff --quiet media/coverage_badge.svg || {
git add media/coverage_badge.svg
git commit -m "[Automated] Updated coverage badge"
}

- name: Push changes [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10'
if: matrix.os == 'buildjet-8vcpu-ubuntu-2204' && matrix.version == '3.10'
uses: ad-m/github-push-action@master
with:
branch: ${{ github.head_ref }}
Expand Down Expand Up @@ -117,4 +117,4 @@ jobs:
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: "artifacts/**/*.xml"
files: "artifacts/**/*.xml"
116 changes: 116 additions & 0 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Unit tests

on:
pull_request:
branches: [ dev ]
paths:
- 'datadreamer/**/**.py'
- 'tests/core_tests/unittests/**.py'
- .github/workflows/unit-tests.yaml

jobs:
run_tests:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
version: ['3.10', '3.11']

runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.version }}
cache: pip

- name: Install dependencies [Ubuntu]
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt update
sudo apt install -y pandoc
pip install -e .[dev]
pip install coverage-badge>=1.1.0 pytest-cov>=4.1.0
- name: Install dependencies [Windows]
if: matrix.os == 'windows-latest'
run: |
pip install -e .[dev]
pip install coverage-badge>=1.1.0 pytest-cov>=4.1.0
- name: Install dependencies [macOS]
if: matrix.os == 'macOS-latest'
run: |
pip install -e .[dev]
pip install coverage-badge>=1.1.0 pytest-cov>=4.1.0
- name: Run tests with coverage [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10'
run: pytest tests/core_tests/unittests --cov=datadreamer --cov-report xml --junit-xml pytest.xml

- name: Run tests [Windows, macOS]
if: matrix.os != 'ubuntu-latest' || matrix.version != '3.10'
run: pytest tests/core_tests/unittests --junit-xml pytest.xml

- name: Generate coverage badge [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10'
run: coverage-badge -o media/coverage_badge.svg -f

- name: Generate coverage report [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10'
uses: orgoro/[email protected]
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}

- name: Commit coverage badge [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10'
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
git diff --quiet media/coverage_badge.svg || {
git add media/coverage_badge.svg
git commit -m "[Automated] Updated coverage badge"
}
- name: Push changes [Ubuntu]
if: matrix.os == 'ubuntu-latest' && matrix.version == '3.10'
uses: ad-m/github-push-action@master
with:
branch: ${{ github.head_ref }}

- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: Test Results [${{ matrix.os }}] (Python ${{ matrix.version }})
path: pytest.xml
retention-days: 10
if-no-files-found: error

publish-test-results:
name: "Publish Tests Results"
needs: run_tests
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
if: always()

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts

- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: "artifacts/**/*.xml"
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ WORKDIR /app
## instal
RUN apt-get update && apt-get install ffmpeg libsm6 libxext6 -y
RUN apt-get install -y git
RUN git clone https://github.com/luxonis/datadreamer.git -b main

## Define a build argument for the branch, defaulting to "main"
ARG BRANCH=main

## Clone the repository with the specified branch
RUN git clone --branch ${BRANCH} https://github.com/luxonis/datadreamer.git

RUN cd datadreamer && pip install .

## define image execution
ENTRYPOINT ["datadreamer"]
ENTRYPOINT ["datadreamer"]
29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,13 @@ datadreamer --config <path-to-config>

### 🔧 Additional Parameters

- `--task`: Choose between detection and classification. Default is `detection`.
- `--task`: Choose between detection, classification and instance segmentation. Default is `detection`.
- `--dataset_format`: Format of the dataset. Defaults to `raw`. Supported values: `raw`, `yolo`, `coco`, `luxonis-dataset`, `cls-single`.
- `--split_ratios`: Split ratios for train, validation, and test sets. Defaults to `[0.8, 0.1, 0.1]`.
- `--num_objects_range`: Range of objects in a prompt. Default is 1 to 3.
- `--prompt_generator`: Choose between `simple`, `lm` (language model) and `tiny` (tiny LM). Default is `simple`.
- `--prompt_generator`: Choose between `simple`, `lm` (Mistral-7B), `tiny` (tiny LM), and `qwen2` (Qwen2.5 LM). Default is `qwen2`.
- `--image_generator`: Choose image generator, e.g., `sdxl`, `sdxl-turbo` or `sdxl-lightning`. Default is `sdxl-turbo`.
- `--image_annotator`: Specify the image annotator, like `owlv2` for object detection or `clip` for image classification. Default is `owlv2`.
- `--image_annotator`: Specify the image annotator, like `owlv2` for object detection or `clip` for image classification or `owlv2-slimsam` for instance segmentation. Default is `owlv2`.
- `--conf_threshold`: Confidence threshold for annotation. Default is `0.15`.
- `--annotation_iou_threshold`: Intersection over Union (IoU) threshold for annotation. Default is `0.2`.
- `--prompt_prefix`: Prefix to add to every image generation prompt. Default is `""`.
Expand All @@ -175,6 +175,7 @@ datadreamer --config <path-to-config>
- `--image_tester_patience`: Patience level for image tester. Default is `1`.
- `--lm_quantization`: Quantization to use for Mistral language model. Choose between `none` and `4bit`. Default is `none`.
- `--annotator_size`: Size of the annotator model to use. Choose between `base` and `large`. Default is `base`.
- `--disable_lm_filter`: Use only a bad word list for profanity filtering. Default is `False`.
- `--batch_size_prompt`: Batch size for prompt generation. Default is 64.
- `--batch_size_annotation`: Batch size for annotation. Default is `1`.
- `--batch_size_image`: Batch size for image generation. Default is `1`.
Expand All @@ -190,12 +191,15 @@ datadreamer --config <path-to-config>
| ----------------- | ------------------------------------------------------------------------------------- | --------------------------------------- |
| Prompt Generation | [Mistral-7B-Instruct-v0.1](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.1) | Semantically rich prompts |
| | [TinyLlama-1.1B-Chat-v1.0](https://huggingface.co/TinyLlama/TinyLlama-1.1B-Chat-v1.0) | Tiny LM |
| | [Qwen2.5-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct) | Qwen2.5 LM |
| | Simple random generator | Joins randomly chosen object names |
| Profanity Filter | [Qwen2.5-1.5B-Instruct](https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct) | Fast and accurate LM profanity filter |
| Image Generation | [SDXL-1.0](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0) | Slow and accurate (1024x1024 images) |
| | [SDXL-Turbo](https://huggingface.co/stabilityai/sdxl-turbo) | Fast and less accurate (512x512 images) |
| | [SDXL-Lightning](https://huggingface.co/ByteDance/SDXL-Lightning) | Fast and accurate (1024x1024 images) |
| Image Annotation | [OWLv2](https://huggingface.co/google/owlv2-base-patch16-ensemble) | Open-Vocabulary object detector |
| | [CLIP](https://huggingface.co/openai/clip-vit-base-patch32) | Zero-shot-image-classification |
| | [SlimSAM](https://huggingface.co/Zigeng/SlimSAM-uniform-50) | Zero-shot-instance-segmentation |

<a name="example"></a>

Expand Down Expand Up @@ -268,6 +272,23 @@ save_dir/
}
```

3. Instance Segmentation Annotations (instance_segmentation_annotations.json):

- Each entry corresponds to an image and contains bounding boxes, masks and labels for objects in the image.
- Format:

```bash
{
"image_path": {
"boxes": [[x_min, y_min, x_max, y_max], ...],
"masks": [[[x0, y0],[x1, y1],...], [[x0, y0],[x1, y1],...], ....]
"labels": [label_index, ...]
},
...
"class_names": ["class1", "class2", ...]
}
```

<a name="limitations"></a>

## ⚠️ Limitations
Expand All @@ -292,7 +313,7 @@ The above license does not cover the models. Please see the license of each mode

## 🙏 Acknowledgements

This library was made possible by the use of several open-source projects, including Transformers, Diffusers, and others listed in the requirements.txt.
This library was made possible by the use of several open-source projects, including Transformers, Diffusers, and others listed in the requirements.txt. Furthermore, we utilized a bad words list from [`@coffeeandfun/google-profanity-words`](https://github.com/coffee-and-fun/google-profanity-words) Node.js module created by Robert James Gabriel from Coffee & Fun LLC.

[SD-XL 1.0 License](https://github.com/Stability-AI/generative-models/blob/main/model_licenses/LICENSE-SDXL1.0)
[SDXL-Turbo License](https://github.com/Stability-AI/generative-models/blob/main/model_licenses/LICENSE-SDXL-Turbo)
9 changes: 8 additions & 1 deletion datadreamer/dataset_annotation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@
from .clip_annotator import CLIPAnnotator
from .image_annotator import BaseAnnotator, TaskList
from .owlv2_annotator import OWLv2Annotator
from .slimsam_annotator import SlimSAMAnnotator

__all__ = ["BaseAnnotator", "TaskList", "OWLv2Annotator", "CLIPAnnotator"]
__all__ = [
"BaseAnnotator",
"TaskList",
"OWLv2Annotator",
"CLIPAnnotator",
"SlimSAMAnnotator",
]
Loading
Loading