Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Artifacts #6

Open
hcl14 opened this issue Dec 26, 2022 · 2 comments
Open

Artifacts #6

hcl14 opened this issue Dec 26, 2022 · 2 comments

Comments

@hcl14
Copy link

hcl14 commented Dec 26, 2022

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
Copy link
Author

hcl14 commented Dec 26, 2022

This is celeba model which you disabled somewhy:
out

@YANG-H
Copy link
Contributor

YANG-H commented Mar 8, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants