facer icon indicating copy to clipboard operation
facer copied to clipboard

Artifacts

Open hcl14 opened this issue 1 year ago • 2 comments

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 avatar Dec 26 '22 03:12 hcl14

This is celeba model which you disabled somewhy: out

hcl14 avatar Dec 26 '22 03:12 hcl14

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

YANG-H avatar Mar 08 '23 18:03 YANG-H