python-animeface icon indicating copy to clipboard operation
python-animeface copied to clipboard

there's alittle bit slow

Open Kiris-tingna opened this issue 2 years ago • 0 comments

i am using this within a flask backend and it works well , but i get base64 encode face image quiet slow. Theres is at least 2s delay.

def detect2(file):
    ret = []
    img = Image.open(file)
    faces = animeface.detect(img)
    
    for it in faces:
        fp = it.face.pos
        # print(fp)
        buffer = BytesIO()
        crop = img.crop((fp.x, fp.y, fp.x + fp.width, fp.y + fp.height))
        crop.save(buffer, format='png')
        byte_data = buffer.getvalue()
        image_str = base64.b64encode(byte_data).decode()
        ret.append({"face": image_str})

    return ret

Kiris-tingna avatar Jun 28 '22 15:06 Kiris-tingna