1
0
Fork 0
mirror of https://github.com/deepfakes/faceswap synced 2025-06-09 04:36:50 -04:00
Commit graph

71 commits

Author SHA1 Message Date
torzdf
983901466f linting: Reduce Class min-public-methods and fix spacing 2024-04-03 14:37:48 +01:00
torzdf
4502824481 Add mask dilation/erosion option for training 2024-03-26 18:06:48 +00:00
torzdf
cf0efff6ba
Learning Rate finder (#1341)
* Add LR Finder support structure

* Move trainer.Feeder to lib.training.generator

* Expose model.io

* Add lr_finder

* Update docs and locales

* Pre-PR fixups
  - Fix training graph not displaying
  - CI fixes
  - Switch lr finder progress to tqdm
  - Exit lr finder early on NaN
  - Display lr finder progress in GUI
2023-08-22 17:07:36 +01:00
torzdf
6a3b674bef
Rebase code (#1326)
* Remove tensorflow_probability requirement

* setup.py - fix progress bars

* requirements.txt: Remove pre python 3.9 packages

* update apple requirements.txt

* update INSTALL.md

* Remove python<3.9 code

* setup.py - fix Windows Installer

* typing: python3.9 compliant

* Update pytest and readthedocs python versions

* typing fixes

* Python Version updates
  - Reduce max version to 3.10
  - Default to 3.10 in installers
  - Remove incompatible 3.11 tests

* Update dependencies

* Downgrade imageio dep for Windows

* typing: merge optional unions and fixes

* Updates
  - min python version 3.10
  - typing to python 3.10 spec
  - remove pre-tf2.10 code
  - Add conda tests

* train: re-enable optimizer saving

* Update dockerfiles

* Update setup.py
  - Apple Conda deps to setup.py
  - Better Cuda + dependency handling

* bugfix: Patch logging to prevent Autograph errors

* Update dockerfiles

* Setup.py - Setup.py - stdout to utf-8

* Add more OSes to github Actions

* suppress mac-os end to end test
2023-06-27 11:27:47 +01:00
torzdf
03f5c671bc
Remove plaidML support (#1325)
* Remove PlaidML reference from readme files

* Remove AMD option from installers

* remove amd requirements and update setup.py

* remove plaidml test from CI workflow

* gpustats: remove plaidml backend

* plaid removals:
  - faceswap.py - python version check
  - setup.cfg - plaidml typing ignore
  - lib.keras_utils - All plaid code
  - lib.launcher.py - All plaidml checks and configuration

* remove tf2.2 specific code from GUI event reader

* lib.model - remove all plaidml implementations

* plugins.extract - remove plaidml code

* plugins.train remove plaidml code

* lib.convert - remove plaidml code

* tools.model: remove plaidml code

* Remove plaidML tests from unit tests

* remove plaidml_utils and docsting cleanups

* Remove plaidML refs from configs

* fix keras imports
2023-06-21 12:57:33 +01:00
torzdf
02239d4183 locales: Train settings 2023-06-11 23:30:05 +01:00
torzdf
2028579756 Preview - Allow mask color/opacity configuration
- typing: lib.config
  - docs: lib.config
  - bugfix: popup_configure - keep assets on top
2023-02-13 15:03:34 +00:00
torzdf
28cb2fcffb Unhide options for ROCm 2023-01-11 14:34:30 +00:00
torzdf
dc94ed9cad
DirectML Support (#1291)
* DML Support
  - Add requirements. Update setup.py. Update Windows Installer
  - Add 'directml' backend. Update backend supporting logic
  - GPUStats - Add GPU querying from Win SDK for DML backend
  - Windows PlaidML - Deprecation Warning
  - Remove deprecated '-d' training flag
  - Logging in DML functions
- Unittest
  - Windows Unit Test
  - lib.utils
2023-01-06 14:45:57 +00:00
torzdf
629c02a61e Add "custom" mask 2022-08-05 14:09:05 +01:00
torzdf
582c2ce40c Add Flip Loss Function
- Add Flip for AMD and TF
    - Split Perceptual Loss functions to own modules
    - Fix allowed input shape for models
    - Allow GUI tooltip to display at higher width
2022-07-07 01:02:11 +01:00
torzdf
c279ac3518 Disable saving optimizer state option 2022-06-24 13:43:26 +01:00
torzdf
8ec1e1a091 Nvidia: Add AutoClip training option 2022-06-23 18:00:22 +01:00
torzdf
06468c97d4 Training: Add setting option to save optimizer weights 2022-06-23 14:54:09 +01:00
torzdf
0d2eafa485 Enable change of precision for existing models 2022-06-22 01:58:59 +01:00
torzdf
d7ffcda3b0 Add LPIPS loss function 2022-06-19 18:42:34 +01:00
torzdf
1d434b73a4 Enable LogCosh Loss for AMD 2022-06-18 16:12:39 +01:00
torzdf
308c5edf39 Loss updates
- Split Loss to own package
  - Add Focal Frequency Loss (Nvidia only)
  - Enable GMSD for AMD
2022-06-18 14:33:45 +01:00
torzdf
d9c84a5f9f Add Laplacian Pyramid Loss 2022-06-18 02:29:19 +01:00
torzdf
04337e0c5e SSIM Updates
- Standardize DSSIM Function
  - Implement MSSIM function for AMD
2022-06-18 00:02:28 +01:00
torzdf
94c3dcff7e Training updates
- Add multiple selected loss functions
  - Unlock loss as a model configuration
  - Phaze-A remove encoder scaling max xap
2022-06-17 20:24:26 +01:00
torzdf
5569abbb63 training - Add MS-SSIM loss function 2022-05-04 01:58:00 +01:00
torzdf
6f1e6743df Bugfixes:
- Gui - Stats - Return empty dict on state file look up error
  - Gui - Last Session - Don't load saved project information when loading project from last session
  - Train - Set default coverage to 87.5%
2021-08-28 10:40:01 +00:00
torzdf
4c1631b58e lib.model - Add AdaBelief Optimizer 2021-05-25 13:11:35 +01:00
torzdf
6c439944cd Masks updates
- Add head centering support to training
  - Update helptext/tooltips
2021-05-17 18:20:08 +01:00
torzdf
46cb53e6f0 Training updates:
- Expose optimizer epsilon param
  - Add NaN protection
GUI - slider - add support for discreet values
2021-03-19 18:22:35 +00:00
torzdf
48ca4d1b0e bugfix - FIx rare bug that fails to load configuration files on some windows installs 2021-02-17 18:36:30 +00:00
torzdf
ce786ec273 plugins.train.config - Update coverage helptext 2020-12-15 22:44:01 +00:00
torzdf
05018f6119
Extract - Increase area and move centering (#1095)
* Extract
  - Implement aligner re-feeding
  - Add extract type to pipeline.ExtractMedia
  - Add pose annotation to debug
* Convert
  - implement centering
  - remove usage of feed and reference face properties
  - Remove distributed option from convert
  - Force update of alignments file on legacy receive
* Train
  - Resize preview image to model output size
  - Force legacy centering if centering does not exist in model's state file
  - Enable training on legacy face sets

* Alignments Tool
  - Update draw to include head/pose
  - Remove DFL drop + linting
  - Remove remove-frames job
  - remove align-eyes option
  - Update legacy masks to new extract type
  - Exit if attempting to merge version 1.0 alignments files with version 2.0 alignments files
  - Re-generate thumbnails on legacy upgrade
* Mask Tool
  - Update for new extract + bugfix full frame
* Manual Tool
  - Update to new extraction method
   - Disable legacy alignments,
   - extract box bugfix
   - extract faces - size to 512 and center on head
* Preview Tool
  - Display based on model centering
* Sort Tool
  - Use alignments for sort by face

* lib.aligner
  - Add Pose Class
  - Add AlignedFace Class
  - center _MEAN_FACE on x
  - Add meta information with versioning to alignments file
  - lib.aligner.get_align_matrix to use landmarks not face
  - Refactor aligned faces in lib.faces_detect
* lib.logger
  - larger file log padding
* lib.config
  - Fix global changeable_items
* lib.face_filter
  - Use new extracted face images
* lib.image
  - bump thumbnail default size to 96px
2020-12-08 01:31:56 +00:00
torzdf
b7ecad058d GUI: Consolidate settings to single menu 2020-10-24 00:06:52 +01:00
torzdf
961f8ff283 - Bugfix: Training - Disable loss multipliers if penalized loss not selected
- Training: Half mouth/eye multiplier defaults
- GUI: Remove analysis callback from convert tab
2020-09-24 11:31:54 +01:00
torzdf
10da0c40eb Loss multipliers:
- Lower defaults.
  - Set to updateable
2020-09-05 14:13:33 +01:00
torzdf
3433928133
Add Mouth and Eye Priority to Loss options (#1054)
* Priority Training for Mouth and Eyes - Tensorflow

* Use chosen loss function for area multipliers

* loss multipliers for AMD

* Fix mask multipliers for plaid and roll PenalizedMaskLoss into LossWrapper

* losses_tf: roll PenalizedMaskLoss into LossWrapper
2020-08-27 16:49:57 +01:00
torzdf
1f9e834719 typofix 2020-08-23 23:57:45 +01:00
torzdf
0e31b98d36 Training - Add L2 Regularization to Structural Losses 2020-08-23 23:08:19 +01:00
torzdf
8c8e1b2c14 Training Config - Split Loss to it's own section 2020-08-23 00:33:25 +01:00
torzdf
445aa4944c Bugfix - Legacy Models. Set penalized_loss and learn_mask to "False" if mask_type is None 2020-08-20 13:21:40 +01:00
torzdf
0a25dff896 model.config - Make convert batchsize a user configurable option 2020-08-19 23:51:28 +01:00
torzdf
725d864975 Training - Move Mixed Precision to model config 2020-08-17 09:24:37 +01:00
torzdf
fa4783fa11 training config - Add selectable optimizers 2020-08-16 23:33:09 +01:00
torzdf
d8557c1970
Faceswap 2.0 (#1045)
* Core Updates
    - Remove lib.utils.keras_backend_quiet and replace with get_backend() where relevant
    - Document lib.gpu_stats and lib.sys_info
    - Remove call to GPUStats.is_plaidml from convert and replace with get_backend()
    - lib.gui.menu - typofix

* Update Dependencies
Bump Tensorflow Version Check

* Port extraction to tf2

* Add custom import finder for loading Keras or tf.keras depending on backend

* Add `tensorflow` to KerasFinder search path

* Basic TF2 training running

* model.initializers - docstring fix

* Fix and pass tests for tf2

* Replace Keras backend tests with faceswap backend tests

* Initial optimizers update

* Monkey patch tf.keras optimizer

* Remove custom Adam Optimizers and Memory Saving Gradients

* Remove multi-gpu option. Add Distribution to cli

* plugins.train.model._base: Add Mirror, Central and Default distribution strategies

* Update tensorboard kwargs for tf2

* Penalized Loss - Fix for TF2 and AMD

* Fix syntax for tf2.1

* requirements typo fix

* Explicit None for clipnorm if using a distribution strategy

* Fix penalized loss for distribution strategies

* Update Dlight

* typo fix

* Pin to TF2.2

* setup.py - Install tensorflow from pip if not available in Conda

* Add reduction options and set default for mirrored distribution strategy

* Explicitly use default strategy rather than nullcontext

* lib.model.backup_restore documentation

* Remove mirrored strategy reduction method and default based on OS

* Initial restructure - training

* Remove PingPong
Start model.base refactor

* Model saving and resuming enabled

* More tidying up of model.base

* Enable backup and snapshotting

* Re-enable state file
Remove loss names from state file
Fix print loss function
Set snapshot iterations correctly

* Revert original model to Keras Model structure rather than custom layer
Output full model and sub model summary
Change NNBlocks to callables rather than custom keras layers

* Apply custom Conv2D layer

* Finalize NNBlock restructure
Update Dfaker blocks

* Fix reloading model under a different distribution strategy

* Pass command line arguments through to trainer

* Remove training_opts from model and reference params directly

* Tidy up model __init__

* Re-enable tensorboard logging
Suppress "Model Not Compiled" warning

* Fix timelapse

* lib.model.nnblocks - Bugfix residual block
Port dfaker
bugfix original

* dfl-h128 ported

* DFL SAE ported

* IAE Ported

* dlight ported

* port lightweight

* realface ported

* unbalanced ported

* villain ported

* lib.cli.args - Update Batchsize + move allow_growth to config

* Remove output shape definition
Get image sizes per side rather than globally

* Strip mask input from encoder

* Fix learn mask and output learned mask to preview

* Trigger Allow Growth prior to setting strategy

* Fix GUI Graphing

* GUI - Display batchsize correctly + fix training graphs

* Fix penalized loss

* Enable mixed precision training

* Update analysis displayed batch to match input

* Penalized Loss - Multi-GPU Fix

* Fix all losses for TF2

* Fix Reflect Padding

* Allow different input size for each side of the model

* Fix conv-aware initialization on reload

* Switch allow_growth order

* Move mixed_precision to cli

* Remove distrubution strategies

* Compile penalized loss sub-function into LossContainer

* Bump default save interval to 250
Generate preview on first iteration but don't save
Fix iterations to start at 1 instead of 0
Remove training deprecation warnings
Bump some scripts.train loglevels

* Add ability to refresh preview on demand on pop-up window

* Enable refresh of training preview from GUI

* Fix Convert
Debug logging in Initializers

* Fix Preview Tool

* Update Legacy TF1 weights to TF2
Catch stats error on loading stats with missing logs

* lib.gui.popup_configure - Make more responsive + document

* Multiple Outputs supported in trainer
Original Model - Mask output bugfix

* Make universal inference model for convert
Remove scaling from penalized mask loss (now handled at input to y_true)

* Fix inference model to work properly with all models

* Fix multi-scale output for convert

* Fix clipnorm issue with distribution strategies
Edit error message on OOM

* Update plaidml losses

* Add missing file

* Disable gmsd loss for plaidnl

* PlaidML - Basic training working

* clipnorm rewriting for mixed-precision

* Inference model creation bugfixes

* Remove debug code

* Bugfix: Default clipnorm to 1.0

* Remove all mask inputs from training code

* Remove mask inputs from convert

* GUI - Analysis Tab - Docstrings

* Fix rate in totals row

* lib.gui - Only update display pages if they have focus

* Save the model on first iteration

* plaidml - Fix SSIM loss with penalized loss

* tools.alignments - Remove manual and fix jobs

* GUI - Remove case formatting on help text

* gui MultiSelect custom widget - Set default values on init

* vgg_face2 - Move to plugins.extract.recognition and use plugins._base base class
cli - Add global GPU Exclude Option
tools.sort - Use global GPU Exlude option for backend
lib.model.session - Exclude all GPUs when running in CPU mode
lib.cli.launcher - Set backend to CPU mode when all GPUs excluded

* Cascade excluded devices to GPU Stats

* Explicit GPU selection for Train and Convert

* Reduce Tensorflow Min GPU Multiprocessor Count to 4

* remove compat.v1 code from extract

* Force TF to skip mixed precision compatibility check if GPUs have been filtered

* Add notes to config for non-working AMD losses

* Rasie error if forcing extract to CPU mode

* Fix loading of legace dfl-sae weights + dfl-sae typo fix

* Remove unused requirements
Update sphinx requirements
Fix broken rst file locations

* docs: lib.gui.display

* clipnorm amd condition check

* documentation - gui.display_analysis

* Documentation - gui.popup_configure

* Documentation - lib.logger

* Documentation - lib.model.initializers

* Documentation - lib.model.layers

* Documentation - lib.model.losses

* Documentation - lib.model.nn_blocks

* Documetation - lib.model.normalization

* Documentation - lib.model.session

* Documentation - lib.plaidml_stats

* Documentation: lib.training_data

* Documentation: lib.utils

* Documentation: plugins.train.model._base

* GUI Stats: prevent stats from using GPU

* Documentation - Original Model

* Documentation: plugins.model.trainer._base

* linting

* unit tests: initializers + losses

* unit tests: nn_blocks

* bugfix - Exclude gpu devices in train, not include

* Enable Exclude-Gpus in Extract

* Enable exclude gpus in tools

* Disallow multiple plugin types in a single model folder

* Automatically add exclude_gpus argument in for cpu backends

* Cpu backend fixes

* Relax optimizer test threshold

* Default Train settings - Set mask to Extended

* Update Extractor cli help text
Update to Python 3.8

* Fix FAN to run on CPU

* lib.plaidml_tools - typofix

* Linux installer - check for curl

* linux installer - typo fix
2020-08-12 10:36:41 +01:00
torzdf
ac40b0f52f
Remove subpixel upscaling option (#1024) 2020-05-13 13:50:48 +01:00
torzdf
43a4d06540
Smart Masks - Training Implementation (#914)
* Smart Masks - Training

- Reinstate smart mask training code
- Reinstate mask_type back to model.config
- change 'replicate_input_mask to 'learn_mask'
- Add learn mask option
- Add mask loading from alignments to plugins.train.trainer
- Add mask_blur and mask threshold options
- _base.py - Pass mask options through training_opts dict
- plugins.train.model - check for mask_type not None for learn_mask and penalized_mask_loss
- Limit alignments loading to just those faces that appear in the training folder
- Raise error if not all training images have an alignment, and alignment file is required
- lib.training_data - Mask generation code
- lib.faces_detect - cv2 dimension stripping bugfix
- Remove cv2 linting code

* Update mask helptext in cli.py

* Fix Warp to Landmarks
Remove SHA1 hashing from training data

* Update mask training config

* Capture missing masks at training init

* lib.image.read_image_batch - Return filenames with batch for ordering

* scripts.train - Documentation

* plugins.train.trainer - documentation

* Ensure backward compatibility.
Fix convert for new predicted masks

* Update removed masks to components for legacy models.
2019-12-05 16:02:01 +00:00
torzdf
70ee125283 Serialize masks to alignments file
- Add new serializers (npy + compressed)
- Remove Serializer option from cli
- Revert get_aligned call in scripts/extract
- Default alignments to compressed
- Size masks to 128px and compress
- Remove mask thresholding/blur from generation code
- Add Mask class to lib/faces_detect
- Revert debug landmarks to aligned face
- Revert non-extraction code to staging version
2019-10-13 22:50:28 +00:00
kvrooman
995a857154 Smart Mask Exposure for Extraction & Training (#831)
Smart Masks - Initial Commit
2019-10-07 16:16:18 +01:00
Kyle
9a57af45d5 loss name correction 2019-09-22 16:37:43 -05:00
torzdf
105af8a02a GUI Tweaks 2019-08-25 11:07:34 +01:00
torzdf
e1fdb25673 Add grouping for GUI options 2019-08-23 02:48:59 +00:00
torzdf
f7ecae2997 Add "mask_blur" option for training 2019-08-08 00:09:30 +01:00
torzdf
28cc7c254d config: Update helptext for conv_aware_init 2019-08-06 16:38:37 +00:00