polish transform compose

This commit is contained in:
Dun Liang 2022-07-31 20:18:53 +08:00
parent 23c4de4901
commit 2c91bc1405
3 changed files with 9 additions and 4 deletions

View File

@ -9,7 +9,7 @@
# file 'LICENSE.txt', which is part of this source code package.
# ***************************************************************
__version__ = '1.3.4.19'
__version__ = '1.3.4.20'
from jittor_utils import lock
with lock.lock_scope():
ori_int = int

View File

@ -671,8 +671,13 @@ class Compose:
def __init__(self, transforms):
self.transforms = transforms
def __call__(self, *data):
for t in self.transforms:
data = t(*data)
if len(data) == 1:
data = data[0]
for t in self.transforms:
data = t(data)
else:
for t in self.transforms:
data = t(*data)
return data
class Resize:

View File

@ -245,7 +245,7 @@ def adjust_gamma(img, gamma, gain=1):
input_mode = img.mode
img = img.convert('RGB')
gamma_map = [(255 + 1 - 1e-3) * gain * pow(ele / 255., gamma) for ele in range(256)] * 3
gamma_map = [int((255 + 1 - 1e-3) * gain * pow(ele / 255., gamma)) for ele in range(256)] * 3
img = img.point(gamma_map) # use PIL's point-function to accelerate this part
img = img.convert(input_mode)