Commit Graph

534 Commits

Author SHA1 Message Date
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
Xin SU
1b80de81cd Add Improved AutoEncoder model. (#251)
* Add Improved AutoEncoder model.

* Refactoring Model_IAE to match the new model folder structure

* Add Model_IAE in plugins
2018-03-11 11:35:48 +01:00
Clorr
69789663e7
Fixing number of args 2018-03-10 13:30:48 +01:00
CyberDain
59ca996eb1 PluginLoader.get_available_models()
PluginLoader.get_default_model()
provides easy integration of Model_* folders without changing convert.py and train.py
2018-03-10 11:18:39 +01:00
Clorr
5007d8e996
Fixes (#267) 2018-03-10 10:38:50 +01:00
Othniel Cundangan
810bd0bce7
Update GAN64 to v2 (#217)
* Clearer requirements for each platform

* Refactoring of old plugins (Model_Original + Extract_Align) + Cleanups

* Adding GAN128

* Update GAN to v2

* Create instance_normalization.py

* Fix decoder output

* Revert "Fix decoder output"

This reverts commit 3a8ecb8957fe65e66282197455d775eb88455a77.

* Fix convert

* Enable all options except perceptual_loss by default

* Disable instance norm

* Update Model.py

* Update Trainer.py

* Match GAN128 to shaoanlu's latest v2

* Add first_order to GAN128

* Disable `use_perceptual_loss`

* Fix call to `self.first_order`

* Switch to average loss in output

* Constrain average to last 100 iterations

* Fix math, constrain average to intervals of 100

* Fix math averaging again

* Remove math and simplify this damn averagin

* Add gan128 conversion

* Update convert.py

* Use non-warped images in masked preview

* Add K.set_learning_phase(1) to gan64

* Add K.set_learning_phase(1) to gan128

* Add missing keras import

* Use non-warped images in masked preview for gan128

* Exclude deleted faces from conversion

* --input-aligned-dir defaults to "{input_dir}/aligned"

* Simplify map operation

* port 'face_alignment' from PyTorch to Keras. It works x2 faster, but initialization takes 20secs.

2DFAN-4.h5 and mmod_human_face_detector.dat included in lib\FaceLandmarksExtractor

fixed dlib vs tensorflow conflict: dlib must do op first, then load keras model, otherwise CUDA OOM error

if face location not found by CNN, its try to find by HOG.

removed this:
-        if face.landmarks == None:
-            print("Warning! landmarks not found. Switching to crop!")
-            return cv2.resize(face.image, (size, size))
because DetectedFace always has landmarks

* Enabled masked converter for GAN models

* Histogram matching, cli option for perceptual loss

* Fix init() positional args error

* Add backwards compatibility for aligned filenames

* Fix masked converter

* Remove GAN converters
2018-03-09 19:43:24 -05:00
babilio
fc5a88518d Allows applying dilation by passing negative erosion kernel values. If value is negative, … (#238)
* Allows for negative erosion kernel for -e arg. If value is negative, it turns it into a dilation kernel, which allow facehullandrect to cover more space. Can help to cover double eyebrows. Also could be useful with Masked converter for GAN that oatsss is working on.

* Update convert.py

Modified argument help to clarify the effects of erosion and dilation as parameters
2018-03-03 12:01:07 +01:00
iperov
232d9313af port 'face_alignment' from PyTorch to Keras. (#228)
* port 'face_alignment' from PyTorch to Keras. It works x2 faster, but initialization takes 20secs.

2DFAN-4.h5 and mmod_human_face_detector.dat included in lib\FaceLandmarksExtractor

fixed dlib vs tensorflow conflict: dlib must do op first, then load keras model, otherwise CUDA OOM error

if face location not found by CNN, its try to find by HOG.

removed this:
-        if face.landmarks == None:
-            print("Warning! landmarks not found. Switching to crop!")
-            return cv2.resize(face.image, (size, size))
because DetectedFace always has landmarks

* removing DetectedFace.landmarks
2018-03-01 11:32:11 +01:00
dfaker
ab8ee42ead lowercase mask_type (#181)
The mask_type passed in to this function is lowercase, changing string literals to match.
2018-02-11 17:21:03 +01:00
Clorr
6bea4c2b27 Correcting model paths 2018-02-07 15:25:26 +01:00
Clorr
1fd9e99555
Adding GAN plugin (#102)
Update GAN plugin to latest official version
2018-02-07 15:00:49 +01:00
czfhhh
d5b4c919ae Update Convert_Masked.py (#130)
correct issue when seamless_clone is true
2018-02-07 12:20:01 +01:00
czfhhh
23de50214c Add demosaic (#131)
Copy from https://github.com/dfaker/df/blob/master/merge_faces_larger.py#L127-L133
2018-02-07 12:09:30 +01:00
Gareth Dunstone
7e7cf0bd2d
extended arguments for convert.py (#89)
* extended arguments for convert re https://github.com/deepfakes/faceswap/issues/85

* helptext for extended arguments.

* changed default mask type to facehullandrect
2018-02-01 23:19:03 +11:00
Clorr
34945cfcd7
Adding models as plugins + Face filtering (#53) + #39 + #43 + #44 + #49 (#61)
* Making Models as plugins

* Do not reload model on each image #39 + Adding FaceFilter #53

* Adding @lukaville PR for #43 and #44 (possibly)

* Training done in a separate thread

* Better log for plugin load

* Adding a prefetch to train.py #49
(Note that we prefetch 2 batches of images, due to the queue behavior)
+ More compact logging with verbose info included

* correction of DirectoryProcessor signature

* adding missing import

* Convert with parallel preprocessing of files

* Added coverage var for trainer

Added a var with comment. Feel free to add it as argument

* corrections

* Modifying preview and normalization of image + correction

* Cleanup
2018-01-31 18:56:44 +01:00
Clorr
e518206c8e Adding PluginLoader 2018-01-03 14:01:02 +01:00
Clorr
bb489f4f51 Adding new plugins (Extract_Align & Convert_Masked) 2018-01-03 10:33:42 +01:00
Clorr
3e2976ab03 Adding plugins 2018-01-03 10:33:39 +01:00