1
0
Fork 0
mirror of https://github.com/deepfakes/faceswap synced 2025-06-07 19:05:02 -04:00
Commit graph

51 commits

Author SHA1 Message Date
torzdf
1c081aea7d
Add ability to export and import alignment data (#1383)
* tools.alignments - add export job

* plugins.extract: Update __repr__ for ExtractorBatch dataclass

* plugins.extract: Initial implementation of external import plugins

* plugins.extract: Disable lm masks on ROI alignment data import

* lib.align: Add `landmark_type` property to AlignedFace and return dummy data for ROI Landmarks pose estimate

* plugins.extract: Add centering config item for align import and fix filename mapping for images

* plugins.extract: Log warning on downstream plugins on limited alignment data

* tools: Fix plugins for 4 point ROI landmarks (alignments, sort, mask)

* tools.manual: Fix for 2D-4 ROI landmarks

* training: Fix for 4 point ROI landmarks

* lib.convert: Average color plugin. Avoid divide by zero errors

* extract - external:
  - Default detector to 'external' when importing alignments
  - Handle different frame origin co-ordinates

* alignments: Store video extension in alignments file

* plugins.extract.external: Handle video file keys

* plugins.extract.external: Output warning if missing data

* locales + docs

* plugins.extract.align.external: Roll the corner points to top-left for different origins

* Clean up

* linting fix
2024-04-15 12:19:15 +01:00
torzdf
a9d87ae007 linting: Remove pylint hint for logger 2024-04-03 14:03:54 +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
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
9e2026f6fe Extract: Implement re-align/2nd pass
- implement configurable re-align function in extract
  - update locales + documentation
  - re-factor align._base and split to separate modules
  - move normalization method to plugin parent
  - bugfix: FAN use zeros for pre-processing crop
  - lint AlignedFilter
2022-11-22 00:37:29 +00:00
torzdf
1d1face00d Update Face Filter
- Remove old face filter
  - plugins.extract.pipeline: Expose plugins directly
  - Change `is_aligned` from plugin level to ExtractMedia level
  - Allow extract pipeline to take faceswap aligned images
  - Add ability for recognition plugins to accept aligned faces as input
  - Add face filter to recognition plugin
  - Move extractor pipeline IO ops to own class
2022-10-31 18:25:32 +00:00
torzdf
f1e3339fbe Add vggface2 to extraction pipeline 2022-10-10 13:09:02 +01:00
torzdf
765e385177 Extract: Typing and standardization 2022-09-30 18:36:35 +01:00
torzdf
376c419498 Bugfix: Manual tool. Explicitly disable aligner filters 2022-09-24 01:09:41 +01:00
torzdf
f5fa5b4337 Extract filter: Allow saving of filtered images 2022-09-19 00:13:41 +01:00
torzdf
a8f22cc019 Extract updates:
- Default CPU detector to MTCNN
  - add basic Aligner false positive filters
  - Typing: align + plugins
  - Use specific AlignerBatch class for alignment
  -
2022-09-18 19:44:41 +01:00
torzdf
2d312a9db2 Minor updates and fixups
- Mask Tool - Typing + BiSeNet mask update fix
  - Alignments Tool - Auto search for alignments file
2022-09-14 19:14:03 +01:00
torzdf
13cfb3f39e extract: Add batch processing mode 2022-08-31 19:48:47 +01:00
torzdf
1022651eb8 Bugfix: convert - Gif Writer
- Fix non-launch error on Gif Writer
  - convert plugins - linting
  - convert/fs_media/preview/queue_manager - typing
  - Change convert items from dict to Dataclass
2022-08-26 23:56:03 +01:00
torzdf
d9c84a5f9f Add Laplacian Pyramid Loss 2022-06-18 02:29:19 +01:00
torzdf
ac22d40a91 extract: mask - Delete any mask from outside of frame boundaries 2021-07-22 13:04:29 +01:00
torzdf
1763c44383 Bugfix - Extract
- Set fallback scaling amount for parallel plugins
2021-06-10 10:20:17 +01: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
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
ab4ef75671 Extract - Allow multiple pipelines to be loaded 2020-04-02 15:53:29 +01:00
torzdf
8d4f381e7c Extract - Better VRAM Allocation in Extraction Pipeline 2020-03-31 15:24:32 +01:00
torzdf
bb3e3d0f16 Extraction - Auto generate Components and Extended Masks 2020-03-30 19:24:29 +01:00
torzdf
924d53789b
Core updates (#982)
* plugins.extract.align
  - Expose normalization method

* lib.gui core updates
  - Minor updates to support future development.
2020-03-10 14:48:12 +00:00
torzdf
4fdeb67fba Bugfix - Manual tool. Use new ExtractMedia class 2019-11-29 23:53:00 +00:00
torzdf
46309771bb plugins.extract - Create ExtractMedia class for pipeline flow
Bugfix - Fix memory leak in extract
2019-11-29 00:46:27 +00:00
torzdf
73ff840fbd scripts.extract - code optimizations
Limit queue sizes to reduce RAM usage
Rename lib.image.BackgroundIO to ImageIO
Create separate ImagesLoader and ImagesSaver classes
Load/Save images from centralized lib.image.ImageIO
scripts.extract documentation
2019-11-13 19:16:25 +00:00
torzdf
68109fcc80 bugfix: plugins.extract.pipeline - Exclude CPU plugins from vram calculations 2019-10-29 22:41:01 +00:00
torzdf
ef49d121e1 Add masker to Travis Tests
Bugfix: Parallel VRAM calculation for non-gpu extractors
2019-10-28 11:56:38 +00:00
Vyacheslav Linnik
9af7726897 Always set batchsize as int (#913) 2019-10-26 22:51:04 +01:00
torzdf
c065916f23 Extract - Mask updates
- Remove none mask plugin
- Make pipeline more flexible
- Add support for pre-aligned faces to masker plugin
- Migrate blur and threshold settings to mask output
2019-10-23 15:05:24 +00:00
torzdf
ad035f2a24 Optimize Extract parallel VRAM allocation 2019-10-19 23:53:42 +00:00
torzdf
d93e7b1114 Smart Mask - Extract code review
- Lint simple_tests.py
- Only reformat alignments file if it exists otherwise change filename
- Update legacy alignments to new format at all stages
- faces_detect.Mask.from_dict - logging format fix
- convert.py fix otf for new pipeline
- cli.py - Add note that masks not used. Revert convert masks
- faces_detect.py - Revert non-extract code
- Add .p and .pickle extensions for serializer
- plugins/extract revert some changes
- scripts/fsmedia - Revert code changes
- Pipeline - cleanup
- Consistant alpha channel stripping (fixes single-process)
- Store landmarks as numpy array
- Code attribution
- Normalize feed face and reference face to 0.0 - 1.0 in convert
- Lock in mask VRAM sized
- Add documentation to plugin_loader
- Update alignments tool to work with new format
2019-10-18 15:44:25 +00:00
torzdf
468e2709de Mask plugin cleanup
- PEP8 Fixes
- Remove config for non NN Masks
- Tidy up defaults helptext
- cli.py fix typos
- Remove unused imports and functions _base.py
- Standardize input_size param
- Enable and update documentation
- Change references from `aligner` to `masker`
- Change  input_size, output_size and coverage_ratio from kwargs to params
- Move load_aligned to batch input iterator
- Remove unnecessary self.input param
- Add softmax layer append function to KSession
- Remove references to KSession protected objects
- Standardize plugin output into finalize method
- Make masks full frame and add to lib.faces_detect
- Add masks to alignments.json (temporary zipped base64 solution)
2019-10-11 18:17:39 +00:00
kvrooman
995a857154 Smart Mask Exposure for Extraction & Training (#831)
Smart Masks - Initial Commit
2019-10-07 16:16:18 +01:00
torzdf
1cdbc5ea27 Update cli for MTCNN 2019-09-18 23:37:22 +00:00
torzdf
a14bb9d636 extract: Autoset batchsize if it is too large in singleprocess mode 2019-09-18 23:00:55 +00:00
kilroythethird
b7cd51a2f1 Optimized mtcnn a bit + added batching (#874) 2019-09-18 23:09:00 +01:00
torzdf
88352b0268
De-Multiprocess Extract (#871)
* requirements.txt: - Pin opencv to 4.1.1 (fixes cv2-dnn error)

* lib.face_detect.DetectedFace: change LandmarksXY to landmarks_xy. Add left, right, top, bottom attributes

* lib.model.session: Session manager for loading models into different graphs (for Nvidia + CPU)

* plugins.extract._base: New parent class for all extract plugins

* plugins.extract.pipeline. Remove MultiProcessing. Dynamically limit batchsize for Nvidia cards. Remove loglevel input

* S3FD + FAN plugins. Standardise to Keras version for all backends

* Standardize all extract plugins to new threaded codebase

* Documentation. Start implementing Numpy style docstrings for Sphinx Documentation

* Remove s3fd_amd. Change convert OTF to expect DetectedFace object

* faces_detect - clean up and documentation

* Remove PoolProcess

* Migrate manual tool to new extract workflow

* Remove AMD specific extractor code from cli and plugins

* Sort tool to new extract workflow

* Remove multiprocessing from project

* Remove multiprocessing queues from QueueManager

* Remove multiprocessing support from logger

* Move face_filter to new extraction pipeline

* Alignments landmarksXY > landmarks_xy and legacy handling

* Intercept get_backend for sphinx doc build

# Add Sphinx documentation
2019-09-15 17:07:41 +01:00
torzdf
e6653dd027 Disable parallel processing when non-amd user uses a Keras extractor + non Keras extractor 2019-06-25 09:58:02 +00:00
torzdf
b11ef60a2b Update parallel process checking for plaidML 2019-06-23 18:04:39 +01:00
torzdf
240751aff0 PlaidML Updates
- Add fan-amd details to Cli
- Update Extract Parallel Processing rules for plaidML
- Handle missing plaidML lib on amd flag
- Pass through correct loglevel from GPUStats to plaidml_tools
2019-06-23 17:57:09 +01:00
torzdf
11f35fa798 Fix Active Devices for plaidML. Add Supports PlaidML to Extractors 2019-06-20 18:25:28 +01:00
torzdf
3c80794ff8 GUI: Show more previews for extract and convert 2019-06-14 12:25:29 +00:00
torzdf
6ac422ac27 Extraction Improvements
Default to parallel processing
Add Image normalization options for aligners
2019-06-13 15:22:56 +00:00
torzdf
0eff0a1719 Config Changes + Bugfixes
Bugfix: Fully disable keypress monitor for GUI
Bugfix: Preview - Handle missing alignments file
Config changes:
    - Separate plugin defaults into their own files
    - Move mask_type to global training config
    - Add ability to pass in custom config files
2019-06-11 01:13:42 +00:00
torzdf
98db63c585 Bugfixes
- Switch to correct Tools tab when loading recent file.
- Fix on-the-fly conversion cuDNN error
2019-06-08 15:39:14 +00:00
torzdf
7b12021dc1 Fixups
vgg_face: to own module
vgg_face: correct output and normalization
Extract: more aggressive queue sizes
sys_info: Fix cudnn check error on Linux
2019-05-14 16:06:15 +00:00