faceswap icon indicating copy to clipboard operation
faceswap copied to clipboard

IAE Model performing poorly if faces not varied enough?

Open Kirin-kun opened this issue 8 years ago • 18 comments

I ran the same face sets than on original for about 18hours and the loss is a bit inconsistent with the results obtained:

saved model weights loss_A: 0.01015, loss_B: 0.02425

It seems it plateaued there After a few more hours, the values didn't change.

I thought it was pretty good losses, but the preview was not good: Face BtoA was still no good (scrambled) on some matches, but face AtoB, despite a loss value at 0.010, was really odd: the face didn't really match with the B face

I converted anyway, and effectively the swapped face is totally unrecognizable.

I suspect that if the A face has not many different expressions (it was from a 30secs excerpt of a video), the encoder adds in unnecessary information, like bags under the eyes (!), resulting in a totally new face.

Original encoder works with that kind of information.

I will try with several different people in face A and see how it goes.

Kirin-kun avatar Mar 12 '18 12:03 Kirin-kun

Any model needs to be trained with a data set that has variety for it to be able to eventually perform well with data sets which have very similar images.

I used a data set which had variety and let the IAE train for a while. Once I achieved low loss values on that data set, I put up a data set with less variety and it is performing just as the original one does.

Just a matter of how well your model is trained.

JayantPythonLover avatar Mar 12 '18 12:03 JayantPythonLover

I just launched a training session with several different people in face A (hopefully with variety) same model files

The loss A jumped back up to 0.5x. and it's slowly going back down. Loss B (same face than before, but with varied poses) seems pretty stable at 0.024 though.

I will see how it goes from there. Will keep you informed.

Kirin-kun avatar Mar 12 '18 12:03 Kirin-kun

I am also seeing some really weird results with IAE. Below you can see and example of the original (A) face then one example of the original model merged on to it and then the same done with IAE. Both where trained to below 0.02.

Right now I am building a dataset of over 16K faces from 10 people and am going to train that for the B side before switching back to the original B dataset I was using to see if that helps.

I am wondering if I should use the same dataset and train the A side with it as well since it involves faces from like 10 different people.

example

NagashSzarekh avatar Mar 12 '18 14:03 NagashSzarekh

@DLSauron I'd rather put the 16K faces in the A side and train the model until it can put the B face on them. Then switch the data in A with your real target and retrain a bit.

That's how I understand it would do the trick though.

Kirin-kun avatar Mar 12 '18 14:03 Kirin-kun

Unfortunately, IAE is a model with an implict limitation of being extremely "overtrainable". If you overtrain it, then it will really look funky. This is because it separates out the "pose" from the "face" completely and has no human intuition that it looks weird. The model may benefit from some changes and adjustments, but for now, its design means you'll get best results from just a basic training, not a "train until perfect". Think of IAE right now as more of a "quick and dirty" model unlike GAN (or even the original) which focus more on quality than speed.

bryanlyon avatar Mar 12 '18 16:03 bryanlyon

I decided to try training both A and B at the same time with the same 16K faces. My hope is that by training it really well it will have a good idea what a "face" is and that it will allow me to create a really well trained "template" model that will be able to use as a base model for real faceswaps to speed up future training.

NagashSzarekh avatar Mar 12 '18 17:03 NagashSzarekh

Unfortunately, this is not a very good generic model. This one especially needs the A and B to stay the same. You'd be better off doing that with the Original model.

bryanlyon avatar Mar 12 '18 17:03 bryanlyon

Yeah I did a set then I tried changing A and keeping B the same and it didn't work. However I feel this model does perform better for expressions that are not matched across sets.

babilio avatar Mar 12 '18 18:03 babilio

Yeah, after a few hours of training B with many different faces in A, the preview looks funky and the resulting conversion has nothing to do with the intended face.

Kirin-kun avatar Mar 12 '18 18:03 Kirin-kun

@bryanlyon Thanks for pointing out the problem of iae. I will try to improve it 😄

@DLSauron Could you share your dataset somehow? I myself didn't train iae with such many faces so sorry for it performs bad 😭

acsaga avatar Mar 13 '18 04:03 acsaga

Since I'm trying to do a many-to-one face model, I was thinking of adding a face recognition step in the loss, maybe this could help? (I didn't check how resource intensive it is though...)

Clorr avatar Mar 14 '18 10:03 Clorr

When you say "many-to-one", you mean making an average face, like this?

Or the reverse, putting the same face on multiple persons? Because the original model can do that partially already.

Kirin-kun avatar Mar 14 '18 17:03 Kirin-kun

I trying putting the target face on any person I present to the model. Original is not bad already, but I'm trying to refine (see left columns of my images in #247 ).

Clorr avatar Mar 14 '18 17:03 Clorr

@Clorr Yeah, I was thinking of additional loss functions (or metrics, similar idea) for faceswapping. It's kind of difficult, because there is no ground truth, unlike warping. For my benchmarking, I just ended up doing face_recognition distance measurements, but it is still unsatisfactory.

Basically, it would be nice to have the faceswap procedure itself be subject to selection.

I did think of one metric with an absolute ground truth.

X = faceA. Y = swapBtoA(swapAtoB(X))

You can now compare X and Y directly with MSE, SSIM, etc type metrics.

Possible issues:

  • You have to avoid the trivial identity solution. Any other trivial solutions? Like some weird intermediate representation that doesn't look like a faceswap but gives the identity solution when applied forwards and backwards? I guess this is avoided by the original loss function being present already.
  • I'm not sure if the X -> Y mapping is well-defined or whatever mathematical term is used, because there could be many possible paths. However, there is an absolute final correct answer, so perhaps this doesn't matter. The original loss function also adds a constraint on the path.

deepfakesclub avatar Mar 15 '18 05:03 deepfakesclub

Just to add my experience with this model, I got vastly superior results using IAE compared to original.

A contains about 2000 faces of the same person ripped at 1fps from various 720p videos. B contains about 500 pics, of my target face with less varied angles.

Original model was trained for about 24 hours (GTX 1080). A got down to about 0.017, B to about 0.025. I can never get B down much lower with this particular data set :/. Final output is more of a hybrid of A and B with some serious issues at difficult angles (understandable, given the data set).

IAE was trained for about 12 hours, and got down to about 0.020 and 0.030 for A and B respectively. It seemed to have plateaued at this point, so I though I'd give it a go, not expecting much.

The results on IAE were for more like the target B face, despite the higher loss values. There are still issues at difficult angles, but they are no way near as pronounced.

torzdf avatar Mar 16 '18 11:03 torzdf

face is totally unrecognizable

same problem

Source: 01484

Dest: out00168 3

Original (hist match, seamless): out00168

IAE: out00168 2

converted IAE face not similar to source face, it more like dest face

but of course common facial features of both faces are present

iperov avatar Mar 20 '18 08:03 iperov

but anyway IAE very interesting model :)

iperov avatar Mar 20 '18 11:03 iperov

@iperov Did you try to train the model with "-bs 16"? I found using smaller batch size can improve the result on some cases.

acsaga avatar Mar 28 '18 03:03 acsaga