FacePerceiver / facer

Face analysis tools for modern research, equipped with state-of-the-art Face Parsing and Face Alignment
MIT License
347 stars 37 forks source link

Artifacts #6

Open hcl14 opened 1 year ago

hcl14 commented 1 year ago

Hi, the segmentation seems better than commonly used Bisenet, espectially it is not limited to crop - which is great. But I see artifacs (wide vertical line) on some images like this: out

The problem is that I inferenced on video which I cannot share and there those artifacts are quite frequent:

image

Is there any way to deal with them?

My code:

import sys
import torch
from PIL import Image
import numpy as np
#sys.path.append('..')

device = 'cuda' if torch.cuda.is_available() else 'cpu' 

import facer

image = facer.hwc2bchw(facer.read_hwc('girls.jpg')).to(device=device) # image: 1 x 3 x h x w
face_detector = facer.face_detector('retinaface/mobilenet', device=device)
faces = face_detector(image)

face_parser = facer.face_parser('farl/lapa/448', device=device)

with torch.inference_mode():
    faces = face_parser(image, faces)

seg_logits = faces['seg']['logits']
seg_probs = seg_logits.softmax(dim=1)  # nfaces x nclasses x h x w
print(seg_probs.shape)

from facer.util import bchw2hwc

out = facer.draw_bchw(image, faces)
print(out.shape)

image = bchw2hwc(out)

if image.dtype != torch.uint8:
        image = image.to(torch.uint8)
if image.size(2) == 1:
    image = image.repeat(1, 1, 3)
pimage = Image.fromarray(image.cpu().numpy())

pimage.save('out.png')
hcl14 commented 1 year ago

This is celeba model which you disabled somewhy: out

YANG-H commented 1 year ago

Thanks for reporting this bug. It should be caused by the tanh warping. We would try fixing it recently.