matthewearl / faceswap Goto Github PK
View Code? Open in Web Editor NEWPython script to put facial features from one face onto another
License: MIT License
Python script to put facial features from one face onto another
License: MIT License
Hello, I need to extract the eyes out of the input image, my goal is to later classify if the eyes are closed or open. So far I could do that with haar eye-cascade but the results are poor, so I been searching for another method and came across your code. Great code btw!
And since your code can place the landmarks, and you even know the range list of the eyes it shouldnt be hard to crop the eyes, I tried several changes but I couldnt get it to work.
So if you are willing could you give me a hand with that?
Thank you
Hi ,there! A app named ZAO got hot in China this week, i just want to share this with you.I'm assigned to implement one like that, this why i'm here.But your idea is awesome and you made this 4 years ago,amazing!
The code is perfect to swap whole face to whole face.
But who knows how to swap partial face to whole face?
Hey Matthew,
Hope u are doing well !
Do u have a c++ version of your face swap demo with the camera stream ?
How would be u replace numpy ?
Cheers,
Luc Michalski
i miss this wrong on line 103
points = cv2.convexHull(points)
i find some solutions,but they cant work.
can you tell me how to deal with it?
thaks
I've noticed that the correct_colours
routine is misbehaving in the mouth area. Here's an example with Kanye West’s body and a replacement face image:
You will get this output, where the lips appear white:
This shows just the transformed output by setting the output of get_face_mask()
to all white:
And here is what the faceswap looks like if the correct_color step is skipped:
Here is a second example with Gwyneth Paltrow's body and a replacement face.
The colour correction this time causes a crazy bloody mouth look:
Turning off colour correction fixes this:
I might look into this more and be able to offer a pull request to tweak the correct_colours() routine to fix this, but wanted to go ahead and report the issue.
hello,
I'm a beginner. For the two images as input , after detecting human faces in the images I need to swap those human faces. I could do the detecting part...But need to swap the human faces. Can anyone help me how to begin and combine the code of face detection with face swap?
Hello, I was wondering how to change the shape of the mask to something like an eclipse instead of a convex polygon. Or is there a way I can fit an eclipse around the convex polygon and then have that eclipse that be polyfilled.
Hi Matthew,
Great piece of code. And thanks for putting this together from the Switching Eds blog post.
And I found some wrong in the codes, its confused me a lot, then i fixed that. See below.
im1 ---
======================
that's because output_im(type is np.float64), some pixels value out of range(0~255)!!!
We only need to add two line scripts as below to before this code line output_im_t = output_im.astype(np.uint8)
.
output_im = np.maximum(output_im, 0) output_im = np.minimum(output_im, 255)
I cannot use this without a license.
So, I have cloned the repository. I have downloaded the shape_predictor_68_face_landmarks.dat
I have changed the path to the file, but I get this error. I really can't understand why.
Much appreciate the code and the extensive guide. I had a simple question that hopefully will not consume too much of your time.
Is it possible to change the size of the output image? So that all faces are aligned in the same box, but they have the rest of the image extending outward (to a user defined extent)
Thanks!
Here is a paper Poisson Image Editing
Hi Matthew,
Great piece of code. Thanks for putting this together from the Switching Eds blog post.
On line 197 inside correct_colours(), the following error happens on a x64 Windows 10 machine with Python 2.7.11:
im2_blur += 128 * (im2_blur <= 1.0)
TypeError: Cannot cast ufunc add output from dtype('int32') to dtype('uint8') with casting rule 'same_kind'
Cheers
Hi,
I an new to python and I am getting error like in line no. 202 im1, landmarks1 = read_im_and_landmarks(sys.argv[1]) IndexError: list index out of range. Please can any one tell me how to fix this error.
Thanks in advance..
Was wondering if anyone else got this error...
Here is the full traceback:
File "./faceswap.py", line 208, in
mask = get_face_mask(im2, landmarks2)
File "./faceswap.py", line 120, in get_face_mask
color=1)
File "./faceswap.py", line 111, in draw_convex_hull
points = cv2.convexHull(points)
TypeError: points data type = 9 is not supported
In faceswap.py there is this chunk of code:
def annotate_landmarks(im, landmarks):
im = im.copy()
for idx, point in enumerate(landmarks):
pos = (point[0, 0], point[0, 1])
cv2.putText(im, str(idx), pos,
fontFace=cv2.FONT_HERSHEY_SCRIPT_SIMPLEX,
fontScale=0.4,
color=(0, 0, 255))
cv2.circle(im, pos, 3, color=(0, 255, 255))
return im
Which I assume was used to generate like this image. However, the code was never used and despite my attempts I can't seem to get it working. Can you show me how it worked?
Line 156 in 00cd826
Line 162 in 00cd826
Numpy element wise multiplication (*) is not appropriate here according to the Orthogonal Procrustes problem (https://en.wikipedia.org/wiki/Orthogonal_Procrustes_problem).
I think the np.matmul function should be used instead of the * operator. Not 100% sure though...
I use that code run two face pictures,but that happen a error.
IndexError: index 22 is out of bounds for axis 0 with size 5
how to solve it ?t hanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.