mchong6 / JoJoGAN

Official PyTorch repo for JoJoGAN: One Shot Face Stylization
MIT License
1.42k stars 206 forks source link

Face not detected error. #18

Closed onzie9 closed 2 years ago

onzie9 commented 2 years ago

I have tried two different images, one with a white background and one with a brown background, but both give the same error below. What are the suggestions for the photo being modified?

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-14-81c009706d54> in <module>()
     11 
     12 # aligns and crops face
---> 13 aligned_face = align_face(filepath)
     14 
     15 # my_w = restyle_projection(aligned_face, name, device, n_iters=1).unsqueeze(0)

1 frames
/content/JoJoGAN/util.py in get_landmark(filepath, predictor)
    110     img = dlib.load_rgb_image(filepath)
    111     dets = detector(img, 1)
--> 112     assert len(dets) > 0, "Face not detected, try another face image"
    113 
    114     for k, d in enumerate(dets):

AssertionError: Face not detected, try another face image
mchong6 commented 2 years ago

This happens because dlib cannot detect a face, happens sometimes when the image looks too different from a human face. One way is to manually crop the face, name it xxx_aligned.png and skip the align_face function. Or maybe just try another image.