IAE Model performing poorly if faces not varied enough?
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.
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.
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.
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.

@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.
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.
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.
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.
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.
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.
@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 😭
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...)
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.
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 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.
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.
face is totally unrecognizable
same problem
Source:

Dest:

Original (hist match, seamless):

IAE:

converted IAE face not similar to source face, it more like dest face
but of course common facial features of both faces are present
but anyway IAE very interesting model :)
@iperov Did you try to train the model with "-bs 16"? I found using smaller batch size can improve the result on some cases.