From c73b803a1517da59f0467fc5b4948347f764c975 Mon Sep 17 00:00:00 2001 From: Laurent Fainsin Date: Wed, 29 Jun 2022 15:01:57 +0200 Subject: [PATCH] feat: randomize paste brightness Former-commit-id: f3a14bc9fe5ea633837b638cc04313566e951190 [formerly 830199ee956eed9f62f845f1406d00c14e1f1262] Former-commit-id: 542421d35c7103812cf621af5777c88812506adb --- comp.ipynb.REMOVED.git-id | 2 +- src/utils/paste.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/comp.ipynb.REMOVED.git-id b/comp.ipynb.REMOVED.git-id index 00cc96d..b1ef6f5 100644 --- a/comp.ipynb.REMOVED.git-id +++ b/comp.ipynb.REMOVED.git-id @@ -1 +1 @@ -946598e599580eb39a7de79d3607416538bc0019 \ No newline at end of file +fb39f9a23b728fadb88ce579f78bb419ff0eaab6 \ No newline at end of file diff --git a/src/utils/paste.py b/src/utils/paste.py index 60ded70..2db7f01 100644 --- a/src/utils/paste.py +++ b/src/utils/paste.py @@ -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)