# AI : Faceswap : CLI : faceswap train
```
python faceswap.py train -m MODELDIR -A FACES1 -B FACES2 [OPTIONS]
```
## Options
```
-A|--input-A DIR Input directory. A directory containing training images for face A.
This is the original face, i.e. the face that you want to remove and replace with face B.
-B|--input-B DIR Input directory. A directory containing training images for face B.
This is the swap face, i.e. the face that you want to place onto the head of person A.
-m|--model-dir DIR Model directory. This is where the training data will be stored. You should always specify a new folder for new models.
If starting a new model, select either an empty folder, or a folder which does not exist (which will be created).
If continuing to train an existing model, specify the location of the existing model.
-l|--load-weights WGHTS Load the weights from a pre-existing model into a newly created model.
For most models this will load weights from the Encoder of the given model into the encoder of the newly created model.
Some plugins may have specific configuration options allowing you to load weights from other layers.
Weights will only be loaded when creating a new model. This option will be ignored if you are resuming an existing model.
Generally you will also want to 'freeze-weights' whilst the rest of your model catches up with your Encoder.
NB: Weights can only be loaded from models of the same plugin as you intend to train.
-t|--trainer {dfaker,dfl-h128,dfl-sae,dlight,iae,lightweight,original,phaze-a,realface,unbalanced,villain}
Select which trainer to use. Trainers can be configured from the Settings menu or the config folder.
- original : The original model created by /u/deepfakes.
- dfaker : 64px in/128px out model from dfaker. Enable 'warp-to-landmarks' for full dfaker method.
- dfl-h128 : 128px in/out model from deepfacelab
- dfl-sae : Adaptable model from deepfacelab
- dlight : A lightweight, high resolution DFaker variant.
- iae : A model that uses intermediate layers to try to get better details
- lightweight : A lightweight model for low-end cards. Don't expect great results. Can train as low as 1.6GB with batch size 8.
- realface : A high detail, dual density model based on DFaker, with customizable in/out resolution.
The autoencoders are unbalanced so B>A swaps won't work so well. By andenixa et al. Very configurable.
- unbalanced : 128px in/out model from andenixa. The autoencoders are unbalanced so B>A swaps won't work so well. Very configurable.
- villain : 128px in/out model from villainguy. Very resource hungry (You will require a GPU with a fair amount of VRAM).
Good for details, but more susceptible to color differences.
-u|--summary Output a summary of the model and exit. If a model folder is provided then a summary of the saved model is displayed.
Otherwise a summary of the model that would be created by the chosen plugin and configuration settings is displayed.
-f|--freeze-weights Freeze the weights of the model.
Freezing weights means that some of the parameters in the model will no longer continue to learn, but those that are not frozen will continue to learn.
For most models, this will freeze the encoder, but some models may have configuration options for freezing other layers.
-b|--batch-size BATCH_SIZE Batch size. This is the number of images processed through the model for each side per iteration.
NB: As the model is fed 2 sides at a time, the actual number of images within the model at any one time is double the number that you set here.
Larger batches require more GPU RAM.
-i|--iterations ITERATIONS Length of training in iterations. This is only really used for automation. There is no 'correct' number of iterations a model should be trained for.
You should stop training when you are happy with the previews.
However, if you want the model to stop automatically at a set number of iterations, you can set that value here.
-D|--distribution-strategy {default,central-storage,mirrored}
Select the distribution stategy to use.
- default : Use Tensorflow's default distribution strategy.
- central-storage : Centralizes variables on the CPU whilst operations are performed on 1 or more local GPUs.
This can help save some VRAM at the cost of some speed by not storing variables on the GPU.
Note: Mixed-Precision is not supported on multi-GPU setups.
- mirrored : Supports synchronous distributed training across multiple local GPUs.
A copy of the model and all variables are loaded onto each GPU with batches distributed to each GPU at each iteration.
-n|--no-logs Disables TensorBoard logging.
NB: Disabling logs means that you will not be able to use the graph or analysis for this session in the GUI.
-r|--use-lr-finder Use the Learning Rate Finder to discover the optimal learning rate for training.
For new models, this will calculate the optimal learning rate for the model.
For existing models this will use the optimal learning rate that was discovered when initializing the model.
Setting this option will ignore the manually configured learning rate (configurable in train settings).
-s|--save-interval N Sets the number of iterations between each model save.
-I|--snapshot-interval N Sets the number of iterations before saving a backup snapshot of the model in it's current state. Set to 0 for off.
-p|--preview Show training preview output in a separate window.
-w|--write-image Writes the training result to a file. The image will be stored in the root of your FaceSwap folder.
-M|--warp-to-landmarks Warps training faces to closely matched Landmarks from the opposite face-set rather than randomly warping the face.
This is the 'dfaker' way of doing warping.
-P|--no-flip To effectively learn, a random set of images are flipped horizontally. Sometimes it is desirable for this not to occur.
Generally this should be left off except for during 'fit training'.
-c|--no-augment-color Color augmentation helps make the model less susceptible to color differences between the A and B sets, at an increased training time cost.
Enable this option to disable color augmentation.
-W|--no-warp Warping is integral to training the Neural Network.
This option should only be enabled towards the very end of training to try to bring out more detail.
Think of it as 'fine-tuning'. Enabling this option from the beginning is likely to kill a model and lead to terrible results.
--- Optional for creating a timelapse. ---
-x|--timelapse-input-A A Timelapse will save an image of your selected faces into the timelapse-output folder at every save iteration.
This should be the input folder of 'A' faces that you would like to use for creating the timelapse.
You must also supply a --timelapse-output and a --timelapse-input-B parameter.
-y|--timelapse-input-B B Timelapse will save an image of your selected faces into the timelapse-output folder at every save iteration.
This should be the input folder of 'B' faces that you would like to use for creating the timelapse.
You must also supply a --timelapse-output and a --timelapse-input-A parameter.
-z|--timelapse-output OUT Timelapse will save an image of your selected faces into the timelapse-output folder at every save iteration.
If the input folders are supplied but no output folder, it will default to your model folder/timelapse/.
```