Faster HSV augmentation (#3462)
Browse filesremove datatype conversion process that can be skipped
- utils/datasets.py +2 -2
utils/datasets.py
CHANGED
@@ -655,12 +655,12 @@ def augment_hsv(img, hgain=0.5, sgain=0.5, vgain=0.5):
|
|
655 |
hue, sat, val = cv2.split(cv2.cvtColor(img, cv2.COLOR_BGR2HSV))
|
656 |
dtype = img.dtype # uint8
|
657 |
|
658 |
-
x = np.arange(0, 256, dtype=
|
659 |
lut_hue = ((x * r[0]) % 180).astype(dtype)
|
660 |
lut_sat = np.clip(x * r[1], 0, 255).astype(dtype)
|
661 |
lut_val = np.clip(x * r[2], 0, 255).astype(dtype)
|
662 |
|
663 |
-
img_hsv = cv2.merge((cv2.LUT(hue, lut_hue), cv2.LUT(sat, lut_sat), cv2.LUT(val, lut_val)))
|
664 |
cv2.cvtColor(img_hsv, cv2.COLOR_HSV2BGR, dst=img) # no return needed
|
665 |
|
666 |
|
|
|
655 |
hue, sat, val = cv2.split(cv2.cvtColor(img, cv2.COLOR_BGR2HSV))
|
656 |
dtype = img.dtype # uint8
|
657 |
|
658 |
+
x = np.arange(0, 256, dtype=r.dtype)
|
659 |
lut_hue = ((x * r[0]) % 180).astype(dtype)
|
660 |
lut_sat = np.clip(x * r[1], 0, 255).astype(dtype)
|
661 |
lut_val = np.clip(x * r[2], 0, 255).astype(dtype)
|
662 |
|
663 |
+
img_hsv = cv2.merge((cv2.LUT(hue, lut_hue), cv2.LUT(sat, lut_sat), cv2.LUT(val, lut_val)))
|
664 |
cv2.cvtColor(img_hsv, cv2.COLOR_HSV2BGR, dst=img) # no return needed
|
665 |
|
666 |
|