faceswap icon indicating copy to clipboard operation
faceswap copied to clipboard

IAE Plugin model not working

Open babilio opened this issue 8 years ago • 5 comments

I tried running the new IAE model here and I am getting this error.

My input was python faceswap.py train -A E:...\aligned -B E:...\aligned -m E:\data\models\trbl -p -t IAE -bs 128

Loading Trainer from Model_IAE plugin... init() takes from 4 to 5 positional arguments but 6 were given

babilio avatar Mar 11 '18 11:03 babilio

Also, should be mentioned it is not compatible with previously trained original model:

Failed loading existing training data.
You are trying to load a weight file containing 7 layers into a model with 4 layers.

Will have to start from scratch.

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

you can load partial weights into Keras, haven't tested it

https://keras.io/models/about-keras-models/

model.load_weights(filepath, by_name=False): loads the weights of the model from a HDF5 file (created by save_weights). By default, the architecture is expected to be unchanged. To load weights into a different architecture (with some layers in common), use by_name=True to load only those layers with the same name.

try adding true at load_weights, https://github.com/deepfakes/faceswap/blob/master/plugins/Model_IAE/AutoEncoder.py

seranus avatar Mar 11 '18 11:03 seranus

Ah I assumed it was ok, did not test. However that's not a bad thing as I will add a suffix to distinguish these model files from original at the same time of fixing

Clorr avatar Mar 11 '18 12:03 Clorr

Here's what you can do to fix this.

Go to plugins/Model_IAE/ folder and open the Trainer.py file.

Replace

def init(self, model, fn_A, fn_B, batch_size=64):

with

def init(self, model, fn_A, fn_B, batch_size, *args):


And yes, the model files for the IAE model are different from the original. So you will need to create a new folder for those and start the process anew.

I'm testing out the new model currently. So far the results have been pretty blurry but I think it will require some hours of proper training. I'll report back later.


I pushed a pull request for this fix. @Clorr

JayantPythonLover avatar Mar 11 '18 13:03 JayantPythonLover

Your fix is merged

Important notice: I renamed the model files so that users who try this don't overwrite their original model

Clorr avatar Mar 11 '18 13:03 Clorr