Skip to content

Commit

Permalink
change header
Browse files Browse the repository at this point in the history
  • Loading branch information
liopeer committed Nov 12, 2024
1 parent 357c4dc commit c91fdb8
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions lightly/transforms/add_grid_transform.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#
# Copyright (c) Lightly AG and affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
# Copyright (c) 2020. Lightly AG and its affiliates.
# All Rights Reserved
from math import ceil
from typing import Any, Dict, Tuple

Expand All @@ -17,19 +12,19 @@

# ignore typing due to Any type used in torchvison.transforms.v2.Transform
class AddGridTransform(Transform): # type: ignore[misc]
"""Implements the naive segmentation into a regular grid from DetCon. [0]
"""Implements the naive segmentation into a regular grid from DetCon. [0]_
Input to this transform:
Any datastructure containing one or several `torchvision.tv_tensor.BoundingBoxes`
and/or `torchvision.tv_tensor.Mask`. Masks should be of size (*, H, W) and
BoundingBoxes can be of arbitrary shape.
BoundingBoxes can be of arbitrary shape. For all supported data structures check [1]_.
Output of this transform:
Leaves any images in the data structure untouched, but overwrites any bounding
boxes and masks by a regular grid. Bounding boxes will take shape (num_rows*num_cols, 4)
and masks will be of shape (1, H, W) with integer values in the range [0, num_rows*num_cols-1].
Useage example:
Example::
img = torch.randn((3, 16, 16))
bboxes = BoundingBoxes(torch.randn((1, 4)), format="XYXY", canvas_size=img.shape[-2:])
Expand All @@ -40,8 +35,9 @@ class AddGridTransform(Transform): # type: ignore[misc]
# bboxes of shape (num_rows*num_cols, 4)
# mask with value range [0, num_rows*num_cols-1]
- [0]: DetCon, 2021, https://arxiv.org/abs/2103.10957
- [1]: torchvision Getting started with transforms v2, https://pytorch.org/vision/main/auto_examples/transforms/plot_transforms_getting_started.html
References:
.. [0] DetCon, 2021, https://arxiv.org/abs/2103.10957
.. [1] torchvision Getting started with transforms v2, https://pytorch.org/vision/main/auto_examples/transforms/plot_transforms_getting_started.html
Attributes:
num_rows: number of grid rows in the segmentation
Expand Down

0 comments on commit c91fdb8

Please sign in to comment.