垃圾小武与Python的类初始化参数和实例化

class Random2DTranslation(object):

def __init__(self, height, width, p=0.5):
    self.height = height
    self.width = width
    self.p = p


def __call__(self, img):
    """
    Args:
    - img (PIL Image): Image to be cropped.
    """
    
    img = img * self.height
    
    return img

C = Random2DTranslation(100,2)
D = C(1000)

print(D)

猜你喜欢

转载自blog.csdn.net/weixin_37721058/article/details/93892305