67 Commits

Author SHA1 Message Date
Lorjuo d211795625 Staging sort fix (#584)
* fixed several bugs that prevented sort algorithms from beeing working in staging branch.
face-cnn, face-cnn-dissim and face-yaw now working again
blur, face, hist, hist-dissim already worked before
face-dissim still has an error

* applied requested changes from torzdf
2019-01-18 00:45:48 +00:00
torzdf 890d1711c7 Merge branch 'master' into staging 2019-01-15 23:56:53 +00:00
torzdf 49812ace73 Log traceback on extract exception during init 2019-01-15 23:56:17 +00:00
torzdf 900eb6c26f Revert "attempted fix of a crash in apply_new_face function (#586)" (#589)
This reverts commit 3aeb358f44.
2019-01-15 13:28:46 +00:00
d8888 3aeb358f44 attempted fix of a crash in apply_new_face function (#586)
* 1. fixed following error message when using seamless clone of openCV, if new_image
cannot be fitted into base_image in apply_new_face function
2. point structure in openCV should be (x,y) rather than (y,x)

* exchange variable name of maskx, masky so that these name corresponds to
X, Y
2019-01-13 22:49:35 +00:00
Lorjuo e9ea863b29 detection bugfixes: (#577)
-scale in detector has been used as a member variable and shared between multiple threads. however scale heavily depends on the concrete image. if thread change occurs between calculation of scale, actual detection and postprocessing, then random behaviour and exceptions might happen. especially in the case of input images with varying sizes this might cause negative effects

-wrong scale factor calculation:
scale factor was calculated as: scale = target / source
whereas target and source are variables for the total number of pixels in the image (= width * height)
However, later on it was applied on the individual dimensions/components as width/height independantly:
e.g.: dims = (int(width * scale), int(height * scale))
or: int(face.left() / scale),

therefore scaling factor often was too small and detection for very big input images was performed on very small intermediate images
Therefore calculation has been changed to:
scale = sqrt(target / source)
2019-01-06 17:44:05 +00:00
torzdf 58b291fa77 bugfix: Handle FAN detection errors 2018-12-31 13:31:50 +00:00
torzdf 45b5072efb Correctly Error out on FAN CPU 2018-12-15 00:28:52 +00:00
torzdf 7f53911453 Logging (#541)
* Convert prints to logger. Further logging improvements. Tidy  up

* Fix system verbosity. Allow SystemExit

* Fix reload extract bug

* Child Traceback handling

* Safer shutdown procedure

* Add shutdown event to queue manager

* landmarks_as_xy > property. GUI notes + linting. Aligner bugfix

* fix FaceFilter. Enable nFilter when no Filter is supplied

* Fix blurry face filter

* Continue on IO error. Better error handling

* Explicitly print stack trace tocrash log

* Windows Multiprocessing bugfix

* Add git info and conda version to crash log

* Windows/Anaconda mp bugfix

* Logging fixes for training
2018-12-04 13:31:49 +00:00
torzdf 4f4fb27410 extractor fixes 2018-11-21 17:58:41 +00:00
torzdf fb76438615 Remove DetectedFace object from plugins due to multiprocess error 2018-11-20 10:20:01 +00:00
torzdf 02935a9b42 multiprocessing race condition bugfix 2018-11-19 13:18:06 +00:00
torzdf 1e1aacab1b Further dlib-cnn bugfixes 2018-11-16 00:17:57 +00:00
torzdf 0a76b787ad dlib rotation + image size bugfix 2018-11-15 16:36:29 +00:00
torzdf 2d970ff925 dlib-cnn rotation bugfix 2018-11-15 10:51:32 +00:00
torzdf bfdae74f66 dlib-cnn: Inconsistent image size bugfix 2018-11-12 12:30:08 +00:00
torzdf 0ab340f8ea add draw transparent to adjust. Disable seamless clone with -dt flag 2018-11-09 11:40:24 +00:00
torzdf 2783c27e00 Fix convert-adjust (#531)
* Add dimensions to alignments + refactor

* Add frame_dims + funcs to DetectFaces. Add alignments lib

* Convert Adjust working

* Refactor and tidy up
2018-11-07 20:21:22 +00:00
torzdf ff10868476 Increase FAN timeout. Fallback sort and manual align to Dlib for CPU 2018-10-28 16:57:51 +00:00
torzdf 7b2cf02390 Bugfixes 2018-10-27 23:52:09 +01:00
torzdf ca63242996 Extraction - Speed improvements (#522) (#523)
* Extraction - Speed improvements (#522)

* Initial Plugin restructure

* Detectors to plugins. Detector speed improvements

* Re-implement dlib aligner, remove models, FAN to TF. Parallel processing

* Update manual, update convert, implement parallel/serial switching

* linting + fix cuda check (setup.py). requirements update keras 2.2.4

* Add extract size option. Fix dlib hog init

* GUI: Increase tooltip width

* Update alignment tool to support new DetectedFace

* Add skip existing faces option

* Fix sort tool to new plugin structure

* remove old align plugin

* fix convert -skip faces bug

* Fix convert skipping no faces frames

* Convert - draw onto transparent layer

* Fix blur threshold bug

* fix skip_faces convert bug

* Fix training
2018-10-27 10:12:08 +01:00
Artem Ivanov 779006feca - added saving of current epoch number during save_weights (#468) 2018-08-18 08:14:41 +01:00
Artem Ivanov 7bff6b5de2 Slight OriginaHightRes Model re-factoring (#464)
* Model re-factoring, might fix red screen of death on multi-gpu configurations

* Limited trainer support for various INPUT_SIZE
2018-08-02 09:04:01 +01:00
torzdf e76ab16bfe Effmpeg preview, MTCNN Extractor. HiRes model fixes (#458)
* Add preview functionality to effmpeg.  (#435)

* Add preview functionality to effmpeg.

effmpeg tool:
Preview for actions that have a video output now available.
Preview does not work when muxing audio.

* Model json unicode fix1 (#443)

* fixed Windows 10 path error while loading weights

* - fixed TypeError: the JSON object must be str, not 'bytes' with OriginalHighRes Model

* MTCNN Extractor and Extraction refactor (#453)

* implement mtcnn extractor

* mtcnn refactor and vram management changes

* cli arguments update for mtcnn/dlib split

* Add mtcnn models to gitignore

* Change multiprocessing on extract

* GUI changes to handle nargs defaults

* Early exit bugfix (#455)

* Fix extract early termination bug

* Fix extract early exit bug

* Multi face detection bugfix (#456)

* Multi face extraction fix

* Original high res cleanup 1 (#457)

* slight model re-factoring
  - removed excess threading code
  - added random kernel initialization to dense layer

* Slight OriginalHighRes re-factoring an code cleanup
2018-07-03 10:42:58 +02:00
Artem Ivanov 048e032a91 Model json unicode fix1 (#443)
* fixed Windows 10 path error while loading weights

* - fixed TypeError: the JSON object must be str, not 'bytes' with OriginalHighRes Model
2018-06-23 19:16:56 +01:00
Artem Ivanov 439b227b0d fixed Windows 10 path error while loading weights (#442) 2018-06-22 11:07:09 +02:00
torzdf 88094a064a Update Original Hi-Res (#438)
* Required for Shaonlu mode (#416)

Added two modes - Original and Shaonlu.
The later requires this file to function.

* model update (#417)

New, functional Original 128 model

* OriginalHighRes 128 model update (#418)

Required for OriginalHighRes Model to function

* Fixed memory usage at 6GB cards. (#423)

- Switched default encoder to ORIGINAL
- Fixed memory consumption. Tested with geforce gtx 9800 ti with 6Gb; batch_size 8 no OOM or memory warnings now.

* added new model

* ndeed for HighRes Model_OriginalHighRes

* added OriginalHighRes model state save

* changed saving routine to ThreadPoolExecutor (faster with Python3)

* altered trainer (#425)

altered trainer to accommodate with model change

* Update Model.py (#424)

- Added saving state (currently only saved epoch number, to be extended in future)
- Changed saving to ThreadPoolExecutor

* Requirements version bump (#431)

This bumps the versions of:

    scandir
    h5py
    Keras
    opencv-python

to their latest vesions.

Virtual Environment will need to be setup again to make use of these.
2018-06-21 16:39:17 +02:00
torzdf be8e235eab Gui v3.0b (#436)
* GUI version 3 (#411)

GUI version 3.0a

* Required for Shaonlu mode (#416)

Added two modes - Original and Shaonlu.
The later requires this file to function.

* model update (#417)

New, functional Original 128 model

* OriginalHighRes 128 model update (#418)

Required for OriginalHighRes Model to function

* Add OriginalHighRes 128 update to gui branch (#421)

* Required for Shaonlu mode (#416)

Added two modes - Original and Shaonlu.
The later requires this file to function.

* model update (#417)

New, functional Original 128 model

* OriginalHighRes 128 model update (#418)

Required for OriginalHighRes Model to function

* Dev gui (#420)

* reduce singletons

* Fix tooltips and screen boundaries on popup

* Remove dpi fix. Fix context filebrowsers

* fix tools.py execution and context filebrowser bugs

* Bugfixes (#422)

* Bump matplotlib requirement. Fix polyfit. Fix TQDM on sort

* Fixed memory usage at 6GB cards. (#423)

- Switched default encoder to ORIGINAL
- Fixed memory consumption. Tested with geforce gtx 9800 ti with 6Gb; batch_size 8 no OOM or memory warnings now.

* Staging (#426)

* altered trainer (#425)

altered trainer to accommodate with model change

* Update Model.py (#424)

- Added saving state (currently only saved epoch number, to be extended in future)
- Changed saving to ThreadPoolExecutor

* Add DPI Scaling (#428)

* Add dpi scaling

* Hotfix for effmpeg. (#429)

effmpeg fixed so it works both in cli and gui.
Initial work done to add previewing feature to effmpeg (currently does nothing).
Some small spacing changes in other files to improve PEP8 conformity.

* PEP8 Linting (#430)

* pep8 linting

* Requirements version bump (#432)

* altered trainer (#425)

altered trainer to accommodate with model change

* Update Model.py (#424)

- Added saving state (currently only saved epoch number, to be extended in future)
- Changed saving to ThreadPoolExecutor

* Requirements version bump (#431)

This bumps the versions of:

    scandir
    h5py
    Keras
    opencv-python

to their latest vesions.

Virtual Environment will need to be setup again to make use of these.

* High DPI Fixes (#433)

* dpi scaling

* DPI Fixes

* Fix and improve context manager. (#434)

effmpeg tool:
Context manager for GUI fixed.

Context manager in general:
Functionality extended to allow configuring the context with both:
  command -> action
  command -> variable (cli argument) -> action

* Change epoch option to iterations

* Change epochs to iterations
2018-06-20 19:25:31 +02:00
andenixa a5611e9d28 Changed saving weights routine (#403)
* fixed save_weights routine as per deepfakes/faceswap request to keep consistency with the rest of the plugin models
2018-05-19 00:48:50 +01:00
andenixa de9c32680d changed to old-style .format() calls (#401)
* Adjusted converter to work with OriginalHighRes model vector dim

* fixed field name to args

* New OriginalHighRes with lighter Encoder and decoder with more clarity

* changed f'' string formatting to old-style .format()
2018-05-19 00:48:50 +01:00
andenixa 95f8362c73 Added OriginalHighRes model converter (#389)
* Adjusted converter to work with OriginalHighRes model vector dim

* fixed field name to args

* New OriginalHighRes with lighter Encoder and decoder with more clarity
2018-05-19 00:48:50 +01:00
torzdf 2e9abd7c09 Model backup bugfix (#371)
* model backup bugfix - original model

* Model backup bugfix - remaining models
2018-04-23 11:44:52 +01:00
torzdf 8004a72bbd bugfix: Correctly identify sharpen option 2018-04-18 10:13:00 +01:00
bryanlyon 0ff9f75245 Merge branch 'lowmem_namechange' of https://github.com/bryanlyon/faceswap into staging 2018-04-16 17:22:27 -07:00
bryanlyon 7aa6ba5b5e Fix IAE Swap
Fix IAE's swap by correcting the model load so that the correct model is loaded for each face.
2018-04-16 17:08:10 -07:00
leftler 0610bf1874 Added explicit names to netGA and netGB's outputs to fix the name conflict error when using multiple gpus. (#341) 2018-04-16 09:41:34 +01:00
fakinated 8ecf36c3cb Model backups before saving (#349)
* Sort images properly (to make the frame range parameter meaningfull)

* Add backup mechanism for model weights.

* Replace 'print' call by 'tqdm.write' call.
2018-04-15 12:11:07 +01:00
bryanlyon 5cb65496dd Enable filename migration for lowmem
Right now, lowmem and Original use the same filenames.  Since their models are incompatible, this could lead to failure by attemptiong to  load lowmem weights in original or vice versa.  This namechange migration will rename existing lowmem models in order to prevent problems.

Recommend that all users either manually rename the lowmem files or run this branch to update to the correct filenames.
2018-04-04 15:48:15 -07:00
Othniel Cundangan 384f0ef7b9 Fix "raw"/"masked" labeling 2018-03-23 22:31:33 -04:00
Othniel Cundangan 6f5125856a Fix "raw"/"masked" preview labeling 2018-03-23 22:30:58 -04:00
Apollo122 00cd7ac6bb Mask refinement option for GAN128 (#308)
I was experimenting on GAN128 and saw that mask refinement option was missing so i added that.
Its default value is False and its optional after 15k iterations.

Based on this: https://render.githubusercontent.com/view/ipynb?commit=87d6e7a28ce754acd38d885367b6ceb0be92ec54&enc_url=68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f7368616f616e6c752f66616365737761702d47414e2f383764366537613238636537353461636433386438383533363762366365623062653932656335342f46616365537761705f47414e5f76325f737a3132385f747261696e2e6970796e62&nwo=shaoanlu%2Ffaceswap-GAN&path=FaceSwap_GAN_v2_sz128_train.ipynb&repository_id=115182783&repository_type=Repository#Tips-for-mask-refinement-(optional-after-%3E15k-iters)
2018-03-23 21:28:42 +01:00
bryanlyon db8324230b Fix gan128 (#288)
* Complete parity fix for GAN128.

This brings GAN128 to parity with GAN in terms of multi GPU support.

Unfortunately, it fails to run due to a naming error.

('The name "model_4" is used 2 times in the model. All layer names should be unique. Layer names: ', ['input_6', 'lambda_1', 'lambda_2', 'model_6', 'model_4', 'model_4'])

* Fix for GAN128 until #287 can be resolved

Issue #287 details why GAN128 cannot be fixed until Keras is fixed upstream.

* Changes to PR as per Clorr

Made changes to error handling to split into separate PR as requested by Clorr.
2018-03-14 11:53:33 +01:00
Ognjen 1af4bc9fa2 Converted LowMem model to the new structure (#292)
* converted lowmem to the new structure

* removed old lowmem
2018-03-13 18:56:45 -07:00
Othniel Cundangan b8ade19b05 Align Eyes Horizontally After Umeyama + Blur Detection (#242)
* Align eyes after umeyama

* Remove comment

* Add cli option

* Update Extract_Crop.py

* Fix convert

* Add blur threshold

* Use mask in blur detection

* Improve blur detection

* Fix indents

* Update extract.py
2018-03-13 20:35:14 -04:00
Othniel Cundangan 8c3eecb329 Fix padding problem with gan conversion (#289)
* Fix padding problem with gan conversion

* Revert gan transform_args
2018-03-13 20:27:19 -04:00
JayantPythonLover eec8636b18 Output Sharpening Added (#285)
* Updated to support Output Sharpening arguments

Two new types of output sharpening methods have been added.

One that deals with a Box Blur method and the other with a Gaussian Blur method.

Box Blur method can be called using argument '-sh bsharpen' --- This method is not dynamic and can produce strong sharpening on your images. Sometimes it can yield great results and sometimes entirely the opposite.

Gaussian Blur method can be called using argument '-sh gsharpen' --- This method is dynamic and tries to adjust to your data set. As a result, while the sharpening effect might not be as strong as bsharpen, it is bound to produce a more natural looking sharpened image.

By default the parameter is set to none which will not run any sharpening on your output.

* Output Sharpening added

Two ways of sharpening your output have been added

-sh bsharpen
-sh gsharpen

* Update convert.py
2018-03-13 23:54:09 +01:00
bryanlyon fc457b69aa Fix broken multigpu GAN loading. (#280)
* Fix broken multigpu GAN loading.

Fix for loading into the multi GPU model when it needs to load/save the original model.

* Move reference change.

Move reference change for single model so it is defined before load

* Add mutliGPU support to GAN128

Added support for mutligpu to GAN128
2018-03-12 20:58:43 +01:00
bryanlyon f6cb3941ad Add Multi-GPU support (#272)
* Add Improved AutoEncoder model.

* Refactoring Model_IAE to match the new model folder structure

* Add Model_IAE in plugins

* Add Multi-GPU support

I added multi-GPU support to the new model layout.  Currently, Original is not tested (due to OOM on my 2x 4gb 970s).  LowMem is not tested with the current commit due to it not being available since the new pluginloader misses it.
2018-03-11 18:03:33 +01:00
JayantPythonLover 4e3b49c78b Fix to Model_IAE not working (#275)
Fix to Model_IAE giving excess positional arguments error.
2018-03-11 14:37:44 +01:00
Clorr 79d8893147 Renaming model files 2018-03-11 14:37:30 +01:00