Fix BGR->RGB Bug in albumentations #8641 (#8695)
Browse files* Fix BGR->RGB Bug in albumentations https://github.com/ultralytics/yolov5/issues/8641
* Change transform methode from cv2 to numpy
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Simplify
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Update augmentations.py
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Glenn Jocher <[email protected]>
- utils/augmentations.py +3 -2
utils/augmentations.py
CHANGED
@@ -39,8 +39,9 @@ class Albumentations:
|
|
39 |
|
40 |
def __call__(self, im, labels, p=1.0):
|
41 |
if self.transform and random.random() < p:
|
42 |
-
new = self.transform(image=im, bboxes=labels[:, 1:], class_labels=labels[:, 0]) # transformed
|
43 |
-
im
|
|
|
44 |
return im, labels
|
45 |
|
46 |
|
|
|
39 |
|
40 |
def __call__(self, im, labels, p=1.0):
|
41 |
if self.transform and random.random() < p:
|
42 |
+
new = self.transform(image=im[..., ::-1], bboxes=labels[:, 1:], class_labels=labels[:, 0]) # transformed
|
43 |
+
im = new['image'][..., ::-1] # RGB to BGR
|
44 |
+
labels = np.array([[c, *b] for c, b in zip(new['class_labels'], new['bboxes'])])
|
45 |
return im, labels
|
46 |
|
47 |
|