高层api例程transforms报错
Created by: skywalk163
执行飞桨2.0高层api例子里的语句:https://github.com/PaddlePaddle/FluidDoc/blob/release/2.0-alpha/doc/fluid/beginners_guide/hapi.md
from paddle.incubate.hapi.vision.transforms import transforms import cv2
img_path = "./work/testpd.jpg" img = cv2.imread(img_path)
使用Compose 将可以将多个数据增强函数组合在一起
trans_funcs = transforms.Compose([transforms.RandomResizedCrop(224), transforms.RandomHorizontalFlip(), transforms.BrightnessTransform(0.2)]) label = None img_processed, label = trans_funcs(img,label)
执行报错: fail to perform transform [<paddle.incubate.hapi.vision.transforms.transforms.RandomResizedCrop object at 0x7fee5f5b8bd0>] with error: call() takes 2 positional arguments but 3 were given and stack: Traceback (most recent call last): File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/incubate/hapi/vision/transforms/transforms.py", line 94, in call data = f(*data) TypeError: call() takes 2 positional arguments but 3 were given
---------------------------------------------------------------------------TypeError Traceback (most recent call last) in 10 transforms.BrightnessTransform(0.2)]) 11 label = None ---> 12 img_processed, label = trans_funcs(img,label) 13 #img_processed=trans_funcs(img) /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/incubate/hapi/vision/transforms/transforms.py in call(self, *data) 100 print("fail to perform transform [{}] with error: " 101 "{} and stack:\n{}".format(f, e, str(stack_info))) --> 102 raise e 103 return data 104 /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/incubate/hapi/vision/transforms/transforms.py in call(self, *data) 92 # multi-fileds in a sample 93 if isinstance(data, Sequence): ---> 94 data = f(*data) 95 # single field in a sample, call transform directly 96 else: TypeError: call() takes 2 positional arguments but 3 were given