feat: randomize paste brightness

Former-commit-id: f3a14bc9fe5ea633837b638cc04313566e951190 [formerly 830199ee956eed9f62f845f1406d00c14e1f1262]
Former-commit-id: 542421d35c7103812cf621af5777c88812506adb
This commit is contained in:
Laurent Fainsin 2022-06-29 15:01:57 +02:00
parent e4b155991b
commit c73b803a15
2 changed files with 6 additions and 2 deletions

View file

@ -1 +1 @@
946598e599580eb39a7de79d3607416538bc0019
fb39f9a23b728fadb88ce579f78bb419ff0eaab6

View file

@ -3,7 +3,7 @@ import random as rd
import albumentations as A
import numpy as np
from PIL import Image
from PIL import Image, ImageEnhance
class RandomPaste(A.DualTransform):
@ -112,6 +112,10 @@ class RandomPaste(A.DualTransform):
# update paste_shape after scaling
paste_shape = np.array(paste_img.size, dtype=np.uint)
# change brightness randomly
filter = ImageEnhance.Brightness(paste_img)
paste_img = filter.enhance(rd.uniform(0.5, 1.5))
# generate some positions
positions = []
NB = rd.randint(1, self.nb)