1
0
Fork 0
mirror of https://github.com/deepfakes/faceswap synced 2025-06-08 03:26:47 -04:00
Commit graph

92 commits

Author SHA1 Message Date
torzdf
95b4431c57 Deprecate multi-character cli switches 2024-04-05 13:51:57 +01:00
torzdf
70c064ca7d Minor fixups and linting 2024-04-03 15:14:32 +01:00
torzdf
983901466f linting: Reduce Class min-public-methods and fix spacing 2024-04-03 14:37:48 +01: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
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
2e8ef5e3c8 GUI - Preview updates
- Training preview. Embed preview pop-out window
  - Bugfix - convert/extract previews
2022-10-20 18:51:39 +01:00
torzdf
f32f460e3f Refactoring
- Change saved previews to PNG
  - Split lib.gui.utils
  - Disable flake8 on __init__ imports
2022-10-15 19:17:24 +01:00
torzdf
952d79922b Bugfixes:
- Extract - batch mode. Exclude folders with no images
  - Train. Trigger the correct preview/mask update from gui trigger
2022-09-13 18:54:01 +01:00
torzdf
7da2cc3dd2 Training - Use custom preview pop-out 2022-09-07 11:49:52 +01:00
torzdf
2ea05623bd Update Distibution Strategies:
- Add Central Storage Stategy
  - Deprecate 'distributed' cli argument
2022-07-19 18:23:16 +01:00
torzdf
c8122bc499 bugfix: Stop preview window from stealing focus 2022-07-06 11:15:51 +01:00
torzdf
3c73ae4ec9 bugfix: Update preview screen in GUI 2022-07-01 19:06:42 +01:00
torzdf
7b9fc0454d Live Preview - Replace cv2 with matplotlib viewer 2022-07-01 13:07:01 +01:00
torzdf
b1a8183ab4 scripts.train - type checking 2022-06-30 18:41:58 +01:00
torzdf
c279ac3518 Disable saving optimizer state option 2022-06-24 13:43:26 +01:00
torzdf
06468c97d4 Training: Add setting option to save optimizer weights 2022-06-23 14:54:09 +01:00
torzdf
b11ed6ead0 typofix 2022-05-13 12:10:51 +01:00
torzdf
0f7ee1603f training - Enable resize in popup preview image 2022-05-13 12:08:25 +01:00
Dhyey Patel
feac8a0108
trainer: add support for non-interactive jobs (#1193)
Add support for training in non-interactive shell environment such
as Sun Grid Engine, Univa Grid Engine and others.

Tested on Univa Grid Engine.

Reference: https://stackoverflow.com/questions/967369/python-find-out-if-running-in-shell-or-not-e-g-sun-grid-engine-queue.
2022-05-04 23:07:31 +01:00
torzdf
cf4b567cc6
Tensorflow 2.6 Support (#1182)
* lib.cli.launcher - Bump max tf version to 2.6

* Remove pathlib requirement

* Update requirements files

* Update setup.py

* bugfix - GUI: Supress errors when attempting to load previews in extract

* GUI: Suppress ptxas error messages for Windows
2021-09-05 02:25:12 +01:00
torzdf
60a4231832 Bugfixes
- extract - debug landmarks - fix non integer errror
  - training (gui) - fix mask toggling
2021-05-30 11:45:03 +01:00
torzdf
18e3139275 Updates
- Change shortcut key to M
  - Slight optimizations
  - GUI support for mask toggling
2021-05-28 19:41:11 +01:00
AnDenixa
486375ec99 - added push t to disable mask display at preview window
trsprmvd

- added extra checks for mask presence in the set
2021-05-28 18:00:08 +01:00
torzdf
29cfdaad46 Training startup updates
- Remove alignments path option from cli
  - Restructure training_data.py
  - Load alignment data from PNG header during first epoch
  - lib.image.read_image_batch - Add option to return metadata
  - lib.utils.get_image_paths - Add option for explicit extension
  - plugins.train.trainer._base - remove pre-cache alignments code
  - scripts.train - Check first image in training folders for metadata
  - Documentation
2021-03-21 23:29:31 +00:00
torzdf
1d07dbaa5d train - Add option to output model summary and exit 2021-03-11 01:35:00 +00:00
torzdf
d392dfbdf7 Bugfixes
- Manual Tool:
    - Hide annotations for faces not meeting criteria
    - Update landmarks on face add/del
    - Clearer landmark annotations
    - Handle non-numerics in frame number box
  - Training
    - Fix mis-aligned preview images
    - Allows mixing legacy + new alignments for A and B
    - Catch non-training images in training folder
    - Catch inconsistently sized training images
    - Standardize coverage ratio calculation
    - lib.image - Add option to get image shape along with hash
Dfaker model:
  - Add 256px mode
2020-12-15 12:11:26 +00:00
torzdf
fe664e2748 Bugfix - Fix Timelapse when alignments files are used 2020-10-09 23:15:40 +01:00
torzdf
dfc118fd6d bugfix: Training - Make timelapse image extensions case insensitive 2020-09-24 10:21:38 +01:00
torzdf
d5c62d16a1 bugfix - Training - Prevent crash on manual preview update 2020-08-23 09:17:09 +01:00
torzdf
956cfdaabb Training: Catch too few images in training folders and error out 2020-08-18 08:56:02 +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
ff8d85118e
Cli Restructure + Multi-Mask Select on Extract (#1012)
- Split up cli.py to smaller modules
- Enable Multi Mask Selection in Extraction
- Handle multi option selection options in the GUI
- Document lib/cli
2020-04-22 00:04:21 +01:00
torzdf
9461c59773 Bugfixes and minor updates:
- Remove preview option from effmpeg tool
  - Remove json filetypes from GUI for alignments files
  - Capture and raise empty timelapse folder errors
  - Move convert to use centralized ImagesLoader
2020-04-09 14:33:29 +01:00
xirvian
4483553195
Fix no-augment-color deprecation warning (#972)
* Update sphinx_requirements.txt

* Fix no-augment-color deprecation warning

Co-authored-by: torzdf <36920800+torzdf@users.noreply.github.com>
2020-02-21 11:45:21 +00:00
torzdf
c1e6080d92 Training: Cleaner loss printing 2019-12-12 13:27:14 +00:00
torzdf
6efed85490 lib,cli: Add suppressed colab flag 2019-12-12 01:22:02 +00:00
torzdf
ef03be1706
Update Dependencies (#950)
* 1st Round update for Python 3.7, TF1.15, Keras2.3
    Move Tensorflow logging verbosity prior to first tensorflow import
    Keras Optimizers and nn_block update
    lib.logger - Change tf deprecation messages from WARNING to DEBUG
    Raise Tensorflow Max version check to 1.15
    Update requirements and conda check for python 3.7+
    Update install scripts, travis and documentation to Python 3.7

* Revert Keras to 2.2.4
2019-12-10 02:01:20 +00: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
dba5ccdd13 bugfix: scripts.train - Check images are in input folders 2019-11-23 14:07:55 +00:00
torzdf
701b2f1f51 Minor Fixes
scripts.train - default to .fsa alignments file
setup.py - Lower non-root message to info level
2019-10-25 17:18:04 +00:00
torzdf
174e6950ea Logging format fixes 2019-09-25 13:01:24 +01:00
torzdf
e83819fcb4 Deprecation warning update 2019-09-24 22:26:21 +00:00
torzdf
5110315df2 no-flip & no-augment-color deprecation warnings 2019-09-24 21:58:42 +00:00
torzdf
66ed005ef3
Optimize Data Augmentation (#881)
* Move image utils to lib.image
* Add .pylintrc file
* Remove some cv2 pylint ignores
* TrainingData: Load images from disk in batches
* TrainingData: get_landmarks to batch
* TrainingData: transform and flip to batches
* TrainingData: Optimize color augmentation
* TrainingData: Optimize target and random_warp
* TrainingData - Convert _get_closest_match for batching
* TrainingData: Warp To Landmarks optimized
* Save models to threadpoolexecutor
* Move stack_images, Rename ImageManipulation. ImageAugmentation Docstrings
* Masks: Set dtype and threshold for lib.masks based on input face
* Docstrings and Documentation
2019-09-24 12:16:05 +01:00
kvrooman
b7b1bd5c6f documentation, pep8, style, clarity updates - Prep for Segmentation (#812)
* documentation, pep8, style, clarity updates

* Update cli.py

* Update _config.py

remove extra mask and coverage

mask type as dropdown

* Update training_data.py

move coverage / LR to global
cut down on loss description

style change
losses working in PR

* simpler logging

* legacy update
2019-08-03 12:38:43 +01:00
torzdf
03d419c505 Training improvements
Add Optimizer Savings option to offload some optimizer calculations to the CPU
Add output_shape to NNMeta class for referencing when building models
2019-07-10 22:35:41 +00:00
torzdf
e1fca14716 Add Restore Model Tool
Tool: Add tool to restore models from backup
Snapshot: Create snapshot based on total iterations rather than session iterations
Models: Move backup/snapshot functions to lib/model
Training: Output average loss since last save at each save iteration
GUI: display_page.py: minor logging update
2019-07-01 23:28:31 +00:00
torzdf
533025215d GUI responsiveness and feature updates
- Add error handling to LongRunningTask
- Analysis: Fix timestats bug for missing session data
- Training: Update training graph inside LongRunningTask
- Training: Smoothing Amount Slider geometry fix
- Training: Auto update Analysis tab on training start and save interval
- Scripts: Keep control of the UI when terminating by terminating using LongRunningTask
2019-06-28 16:34:32 +00:00
torzdf
0e76422805 Expose Augmentation Options to config 2019-06-26 10:48:38 +00:00