Skip to content

Commit

Permalink
Fix cutout bug (#9452)
Browse files Browse the repository at this point in the history
* fix cutout bug

Signed-off-by: Junjie Zhang <46258221+Oswells@users.noreply.github.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Signed-off-by: Junjie Zhang <46258221+Oswells@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
  • Loading branch information
3 people authored Sep 18, 2022
1 parent e8a9c5a commit 8ae81a6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions utils/augmentations.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import torchvision.transforms as T
import torchvision.transforms.functional as TF

from utils.general import LOGGER, check_version, colorstr, resample_segments, segment2box
from utils.general import LOGGER, check_version, colorstr, resample_segments, segment2box, xywhn2xyxy
from utils.metrics import bbox_ioa

IMAGENET_MEAN = 0.485, 0.456, 0.406 # RGB mean
Expand Down Expand Up @@ -281,7 +281,7 @@ def cutout(im, labels, p=0.5):
# return unobscured labels
if len(labels) and s > 0.03:
box = np.array([xmin, ymin, xmax, ymax], dtype=np.float32)
ioa = bbox_ioa(box, labels[:, 1:5]) # intersection over area
ioa = bbox_ioa(box, xywhn2xyxy(labels[:, 1:5], w, h)) # intersection over area
labels = labels[ioa < 0.60] # remove >60% obscured labels

return labels
Expand Down

0 comments on commit 8ae81a6

Please sign in to comment.