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

63 commits

Author SHA1 Message Date
torzdf
696692dc08 Fixups
- Deprecations - display correct long argument
  - Minor spelling + linting
2024-04-21 16:22:42 +01:00
torzdf
d75898f718 Bugfixes for video file alignments storage:
- extract/convert: Load images with correct video extension
  - Manual tool: Cache thumbnails with correct extension
  - Mask tool + Preview tool:: Update legacy alignment keys for pre-video extension storage
2024-04-18 12:45:33 +01:00
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
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
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
a1ef5edd39 tests:
- unit test: tools.alignments.media
  - Add mypy test
  - Typing fixes
2023-01-21 00:41:18 +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
1c8eb24b38 Bugfix: Correct naming of alignments file for videos with dots in filename 2022-09-23 14:14:29 +01:00
torzdf
71726c1ff5 Extract: Add metric information to debug images 2022-09-19 02:14:09 +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
9e503bdaa2 bugfix: debug landmarks 2022-08-23 19:19:16 +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
ef22c576f6 Bugfix - Extract - Fix skip existing faces 2021-02-20 14:55:45 +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
2b5b871156
lib.alignments - Slight update (#978)
* lib.alignments update:
  - Minor structure change (faces to nested dictionary)
  - Refactor internal and external methods
  - Documentation
2020-03-02 17:13:32 +00:00
torzdf
1bdc9da02f
Smart Masks to Convert (#957)
- scripts.convert - Use Smart Masks for Convert
    * Make on-the-fly conversion an explicit option

- Move BlurMask to lib.faces_detect

- tools.preview - Fix for smart masks
    * Subclass from tk.Tk
    * Options to lib.gui.control_helper
    *variable cleanup

- lib.logger - Demote more tensorflow deprecation messages

- Documentation:
    * lib.faces_detect.BlurMask
    * plugins.convert.mask
    * lib.convert
    * scripts.convert
    * scripts.fsmedia
    * tools.preview
2019-12-29 23:13:25 +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
46309771bb plugins.extract - Create ExtractMedia class for pipeline flow
Bugfix - Fix memory leak in extract
2019-11-29 00:46:27 +00:00
kvrooman
47681a8bab Landmarks stored and used as floating point numbers (#928)
* remove and fix int adjustments
* masking rounding
2019-11-15 11:01:37 +00:00
torzdf
2921c2e51a scripts.fsmedia - remove blurry face filter. Fix debug landmarks 2019-11-14 00:23:09 +00:00
torzdf
baac4f53bf extract bugfixes - post_processing, correctly reference aligned face 2019-11-13 22:05:44 +00:00
torzdf
11ab910c5e Reinstate fast frame count for convert and extract. Exit early if count is wrong. 2019-10-31 11:55:51 +00:00
torzdf
b1dd0dbdc5 bugfix: lib.image - Ensure video frame count is always read correctly 2019-10-31 01:45:27 +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
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
torzdf
3deb79392d Merge branch 'staging' into smart-mask-alpha 2019-10-12 09:41:19 +00:00
torzdf
e35918cadf
Standardize serialization (#903)
* Standardize serialization

- Linting
- Standardize serializer use throughout code
- Extend serializer to load and save files
- Always load and save in utf-8
- Create documentation
2019-10-10 23:11:12 +01:00
kvrooman
995a857154 Smart Mask Exposure for Extraction & Training (#831)
Smart Masks - Initial Commit
2019-10-07 16:16:18 +01:00
torzdf
bf2510dfc4 Force imageio to use ffmpeg 2019-09-29 00:33:28 +01: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
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
kilroythethird
0ec9b31a26 Ensure frames are only counted once (#834) 2019-08-12 22:37:01 +01:00
torzdf
1c29344072 Bugfix: Fix extract/convert hanging when ffmpeg fails to get frame count 2019-08-09 12:17:25 +01:00
torzdf
286f6b28b3 Bugfixes
- Fix filter/nfilter for convert
- Remove existing snapshot folder before creating if it pre-exists
- Don't initialize training session until after first save. "Nonetype" session fix
2019-07-29 16:53:04 +00:00
torzdf
3896de3dba Bugfixes
Merge Alignments fix
Face Filter. Set default aligner/detector on convert
2019-07-10 09:44:50 +00:00
torzdf
bf9f264565 Replace CV2 video loading with ImageIO 2019-07-04 10:28:14 +00:00
torzdf
8bd1389b14 bugfix: Stop convert hanging at the last few frames on some input videos 2019-06-28 00:52:12 +01:00
torzdf
3c040e3ccd Filetype Bugfix + Max TF Version
- Fix bug for uppercase video filetypes
- Set maximum supported Tensorflow version to 1.13
2019-06-21 14:30:23 +01:00
torzdf
4725f8ab6a BugFix: FaceFilter 2019-06-19 15:18:51 +01:00
torzdf
a3294523aa Centralize cv2 image reading and handle bad filenames 2019-06-02 16:34:43 +01:00
torzdf
236c35f11a
Convert settings tool (#737)
* Initial prediction pipeline and display

* Patch faces from convert pipeline. Load configs

* Add tkinter canvas for image display

* Radio buttons to config gui. Standardise config gui. Remove dssim loss from realface

* Add action frame

* Live update cli options

* Live update config changes

* Quicker frame loading. Refresh faces button callback

* remove debug code

* Add saving and reloading config buttons

* Reduce lag with threading

* Busy indicator + geometry updates

* Fix options canvas resizing

* Add global config saving and resetting

* tools to own tab

* Rename tool to 'preview'

* geometry tweak

* pep8 fixes
2019-05-30 18:15:25 +01:00
torzdf
12d83c6e68
Remove dlib (#725)
* Sort to vgg_face. Remove Face Recognition requirements

* Remove dlib components from setup.py

* Remove dlib from Windows Installer script

* Remove dlib and cmake from requirements.txt

* Update INSTALL.md to remove all dlib requirements

* Remove dlib and cmake from dockerfiles

* Windows installer. Output cli to details Window. Setup.py bugfix

* Skip FaceFilter if invalid paths passed in
2019-05-12 23:24:25 +01:00
torzdf
148318778c
Face filter vgg face (#724)
* Implement extraction pipeline

* Face filter to vgg_face. Resume partial model downloads

* On-the-fly conversion to extraction pipeline

* Move git model ids from get_model to model definition
2019-05-11 18:43:09 +01:00
torzdf
eef922c2ca Bugfix: Filter and NFilter for convert 2019-04-30 22:35:38 +00:00
torzdf
0d567f1696 Fix on-the-fly conversion 2019-02-25 12:51:50 +00:00
torzdf
cd00859c40
model_refactor (#571) (#572)
* model_refactor (#571)

* original model to new structure

* IAE model to new structure

* OriginalHiRes to new structure

* Fix trainer for different resolutions

* Initial config implementation

* Configparse library added

* improved training data loader

* dfaker model working

* Add logging to training functions

* Non blocking input for cli training

* Add error handling to threads. Add non-mp queues to queue_handler

* Improved Model Building and NNMeta

* refactor lib/models

* training refactor. DFL H128 model Implementation

* Dfaker - use hashes

* Move timelapse. Remove perceptual loss arg

* Update INSTALL.md. Add logger formatting. Update Dfaker training

* DFL h128 partially ported

* Add mask to dfaker (#573)

* Remove old models. Add mask to dfaker

* dfl mask. Make masks selectable in config (#575)

* DFL H128 Mask. Mask type selectable in config.

* remove gan_v2_2

* Creating Input Size config for models

Creating Input Size config for models

Will be used downstream in converters.

Also name change of image_shape to input_shape to clarify ( for future models with potentially different output_shapes)

* Add mask loss options to config

* MTCNN options to config.ini. Remove GAN config. Update USAGE.md

* Add sliders for numerical values in GUI

* Add config plugins menu to gui. Validate config

* Only backup model if loss has dropped. Get training working again

* bugfixes

* Standardise loss printing

* GUI idle cpu fixes. Graph loss fix.

* mutli-gpu logging bugfix

* Merge branch 'staging' into train_refactor

* backup state file

* Crash protection: Only backup if both total losses have dropped

* Port OriginalHiRes_RC4 to train_refactor (OriginalHiRes)

* Load and save model structure with weights

* Slight code update

* Improve config loader. Add subpixel opt to all models. Config to state

* Show samples... wrong input

* Remove AE topology. Add input/output shapes to State

* Port original_villain (birb/VillainGuy) model to faceswap

* Add plugin info to GUI config pages

* Load input shape from state. IAE Config options.

* Fix transform_kwargs.
Coverage to ratio.
Bugfix mask detection

* Suppress keras userwarnings.
Automate zoom.
Coverage_ratio to model def.

* Consolidation of converters & refactor (#574)

* Consolidation of converters & refactor

Initial Upload of alpha

Items
- consolidate convert_mased & convert_adjust into one converter
-add average color adjust to convert_masked
-allow mask transition blur size to be a fixed integer of pixels and a fraction of the facial mask size
-allow erosion/dilation size to be a fixed integer of pixels and a fraction of the facial mask size
-eliminate redundant type conversions to avoid multiple round-off errors
-refactor loops for vectorization/speed
-reorganize for clarity & style changes

TODO
- bug/issues with warping the new face onto a transparent old image...use a cleanup mask for now
- issues with mask border giving black ring at zero erosion .. investigate
- remove GAN ??
- test enlargment factors of umeyama standard face .. match to coverage factor
- make enlargment factor a model parameter
- remove convert_adjusted and referencing code when finished

* Update Convert_Masked.py

default blur size of 2 to match original...
description of enlargement tests
breakout matrxi scaling into def

* Enlargment scale as a cli parameter

* Update cli.py

* dynamic interpolation algorithm

Compute x & y scale factors from the affine matrix on the fly by QR decomp.
Choose interpolation alogrithm for the affine warp based on an upsample or downsample for each image

* input size
input size from config

* fix issues with <1.0 erosion

* Update convert.py

* Update Convert_Adjust.py

more work on the way to merginf

* Clean up help note on sharpen

* cleanup seamless

* Delete Convert_Adjust.py

* Update umeyama.py

* Update training_data.py

* swapping

* segmentation stub

* changes to convert.str

* Update masked.py

* Backwards compatibility fix for models
Get converter running

* Convert:
Move masks to class.
bugfix blur_size
some linting

* mask fix

* convert fixes

- missing facehull_rect re-added
- coverage to %
- corrected coverage logic
- cleanup of gui option ordering

* Update cli.py

* default for blur

* Update masked.py

* added preliminary low_mem version of OriginalHighRes model plugin

* Code cleanup, minor fixes

* Update masked.py

* Update masked.py

* Add dfl mask to convert

* histogram fix & seamless location

* update

* revert

* bugfix: Load actual configuration in gui

* Standardize nn_blocks

* Update cli.py

* Minor code amends

* Fix Original HiRes model

* Add masks to preview output for mask trainers
refactor trainer.__base.py

* Masked trainers converter support

* convert bugfix

* Bugfix: Converter for masked (dfl/dfaker) trainers

* Additional Losses (#592)

* initial upload

* Delete blur.py

* default initializer = He instead of Glorot (#588)

* Allow kernel_initializer to be overridable

* Add ICNR Initializer option for upscale on all models.

* Hopefully fixes RSoDs with original-highres model plugin

* remove debug line

* Original-HighRes model plugin Red Screen of Death fix, take #2

* Move global options to _base. Rename Villain model

* clipnorm and res block biases

* scale the end of res block

* res block

* dfaker pre-activation res

* OHRES pre-activation

* villain pre-activation

* tabs/space in nn_blocks

* fix for histogram with mask all set to zero

* fix to prevent two networks with same name

* GUI: Wider tooltips. Improve TQDM capture

* Fix regex bug

* Convert padding=48 to ratio of image size

* Add size option to alignments tool extract

* Pass through training image size to convert from model

* Convert: Pull training coverage from model

* convert: coverage, blur and erode to percent

* simplify matrix scaling

* ordering of sliders in train

* Add matrix scaling to utils. Use interpolation in lib.aligner transform

* masked.py Import get_matrix_scaling from utils

* fix circular import

* Update masked.py

* quick fix for matrix scaling

* testing thus for now

* tqdm regex capture bugfix

* Minor ammends

* blur size cleanup

* Remove coverage option from convert (Now cascades from model)

* Implement convert for all model types

* Add mask option and coverage option to all existing models

* bugfix for model loading on convert

* debug print removal

* Bugfix for masks in dfl_h128 and iae

* Update preview display. Add preview scaling to cli

* mask notes

* Delete training_data_v2.py

errant file

* training data variables

* Fix timelapse function

* Add new config items to state file for legacy purposes

* Slight GUI tweak

* Raise exception if problem with loaded model

* Add Tensorboard support (Logs stored in model directory)

* ICNR fix

* loss bugfix

* convert bugfix

* Move ini files to config folder. Make TensorBoard optional

* Fix training data for unbalanced inputs/outputs

* Fix config "none" test

* Keep helptext in .ini files when saving config from GUI

* Remove frame_dims from alignments

* Add no-flip and warp-to-landmarks cli options

* Revert OHR to RC4_fix version

* Fix lowmem mode on OHR model

* padding to variable

* Save models in parallel threads

* Speed-up of res_block stability

* Automated Reflection Padding

* Reflect Padding as a training option

Includes auto-calculation of proper padding shapes, input_shapes, output_shapes

Flag included in config now

* rest of reflect padding

* Move TB logging to cli. Session info to state file

* Add session iterations to state file

* Add recent files to menu. GUI code tidy up

* [GUI] Fix recent file list update issue

* Add correct loss names to TensorBoard logs

* Update live graph to use TensorBoard and remove animation

* Fix analysis tab. GUI optimizations

* Analysis Graph popup to Tensorboard Logs

* [GUI] Bug fix for graphing for models with hypens in name

* [GUI] Correctly split loss to tabs during training

* [GUI] Add loss type selection to analysis graph

* Fix store command name in recent files. Switch to correct tab on open

* [GUI] Disable training graph when 'no-logs' is selected

* Fix graphing race condition

* rename original_hires model to unbalanced
2019-02-09 18:35:12 +00:00