lightly-ai / lightly

A python library for self-supervised learning on images.
https://docs.lightly.ai/self-supervised-learning/
MIT License
3.19k stars 286 forks source link

Implementation of AddGridTransform #1731

Closed liopeer closed 2 weeks ago

liopeer commented 2 weeks ago

Motivation

AddGridTransform is meant to segment the image into local patches based on a regular grid and works on arbitrary data structures that contain BoundingBoxes and Mask instances (see torchvision.tv_tensors and torchvision.transforms.v2) following DetCon (https://arxiv.org/abs/2103.10957).

Changes

  1. Implements the transform such that
    • overwrites Maskss to create regular grid of classes
    • overwrites BoundingBoxes' to create regular grid of bounding boxes
    • leaves anything else in the data structure untouched
  2. tests transform specifically against
    • image shape non-divisible by number of columns/rows
  3. makes transform public in transforms/__init__.py
  4. adds the transform to the docs (screenshot below)

Demo

below a plot for an image size of (32, 32), mask is on the left, drawn bounding boxes on the right addgrid

Docs

Screenshot 2024-11-12 at 17 10 40

codecov[bot] commented 2 weeks ago

Codecov Report

Attention: Patch coverage is 95.65217% with 2 lines in your changes missing coverage. Please review.

Project coverage is 85.01%. Comparing base (c37ecf4) to head (ccaa553). Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
lightly/transforms/add_grid_transform.py 95.34% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1731 +/- ## ========================================== + Coverage 84.93% 85.01% +0.07% ========================================== Files 158 159 +1 Lines 6573 6619 +46 ========================================== + Hits 5583 5627 +44 - Misses 990 992 +2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.