Exemple #1
0
def gen_captcha(text):
    image = ImageCaptcha(width=width, height=height, fonts=fonts[2:3])
    data = image.generate(text)
    image = Image.open(data)
    image = torch.ByteTensor(torch.ByteStorage.from_buffer(image.tobytes()))
    image = image.view(height, width, 3)
    image = image.float()
    image.div_(255)
    return image