deepfakes / faceswap-playground

User dedicated repo for the faceswap project
303 stars 194 forks source link

Convert error #140

Closed theoldgun closed 6 years ago

theoldgun commented 6 years ago

Expected behavior

I have trained the model with data from Trump and Cage, but when I make a conversion, I get an error.

Actual behavior

I use a Trump's photo to convert,and use the fellow commend: python faceswap.py convert -i ~/faceswap/photo/trump/ -o ~/faceswap/output/ -m ~/faceswap/models_17k/ but an error has occurred:

Input Directory: /home/dms/faceswap/photo/trump
Output Directory: /home/dms/faceswap/output
Filter: filter.jpg
Using json serializer
Starting, this may take a while...
Loading Model from Model_Original plugin...
/home/dms/faceswap_env/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
Using TensorFlow backend.
WARNING:tensorflow:From /home/dms/faceswap_env/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:1264: calling reduce_prod (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and will be removed in a future version.
Instructions for updating:
keep_dims is deprecated, use keepdims instead
WARNING:tensorflow:From /home/dms/faceswap_env/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:1349: calling reduce_mean (from tensorflow.python.ops.math_ops) with keep_dims is deprecated and will be removed in a future version.
Instructions for updating:
keep_dims is deprecated, use keepdims instead
2018-04-23 14:29:10.896784: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2018-04-23 14:29:10.956105: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:895] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2018-04-23 14:29:10.956335: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1105] Found device 0 with properties: 
name: GeForce GTX 1060 6GB major: 6 minor: 1 memoryClockRate(GHz): 1.7845
pciBusID: 0000:01:00.0
totalMemory: 5.93GiB freeMemory: 5.72GiB
2018-04-23 14:29:10.956348: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1195] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:01:00.0, compute capability: 6.1)
loaded model weights
Aligned directory is empty, no faces will be converted!
Loading Convert from Convert_Masked plugin...
Reading alignments from: /home/dms/faceswap/photo/trump/alignments.json
/home/dms/faceswap/photo/trump/alignments.json not read!
[Errno 2] No such file or directory: '/home/dms/faceswap/photo/trump/alignments.json'
100%|██████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 32.65it/s]
Failed to convert image: /home/dms/faceswap/photo/trump/95eef01f3a292df5cebfc423b0315c6034a87383.jpg. Reason: module 'dlib' has no attribute 'get_frontal_face_detector'
-------------------------
Images found:        1
Faces detected:      0
-------------------------
Done!

And I also don't know what is the alignments.json. I only put a Trump's picture in /home/dms/faceswap/photo/trump/.

Loading Convert from Convert_Masked plugin... Reading alignments from: /home/dms/faceswap/photo/trump/alignments.json /home/dms/faceswap/photo/trump/alignments.json not read! [Errno 2] No such file or directory: '/home/dms/faceswap/photo/trump/alignments.json'

please help me ~~~Thank you

Other relevant information

torzdf commented 6 years ago

Have you run the extract process? This would generate your alignments.json (It is a mapping of face locations within images).

Either way, there is a Pull Request on the way which should address this issue.

Kirin-kun commented 6 years ago

Note: if the alignments.json file is missing, faceswap is supposed to attempt an extraction.

For my numerous convert attempts (lol), I tested not having an alignment file and it was ugly

It doesnt work. Either with -D hog or cnn.

With hog it loads a keras model then it crashes.

With cnn, it errors with a out of memory error.

So, the alignments file is a MUST have.

Also module 'dlib' has no attribute 'get_frontal_face_detector'

Looks like your dlib is weirdly installed.

torzdf commented 6 years ago

The changes have just been pushed to https://github.com/deepfakes/faceswap/tree/staging which should address this. Please feel free to test and see if it solves your issue.

So, the alignments file is a MUST have.

Not any more, but it's definitely preferable as the alignments will just be extracted with default settings and no scope for review if you don't have it.

theoldgun commented 6 years ago

thanks you for help me @torzdf @Kirin-kun !!! when I execute the commend: python faceswap.py extract -i ~/faceswap/photo/trump -o ~/faceswap/data/trump it says:

Input Directory: /home/dms/faceswap/photo/trump
Output Directory: /home/dms/faceswap/data/trump
Filter: filter.jpg
Using json serializer
Starting, this may take a while...
Loading Extract from Extract_Align plugin...
  0%|                                                                                   | 0/1 [00:00<?, ?it/s]/home/dms/.virtualenvs/faceswap_env_python36/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
Using TensorFlow backend.
100%|███████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.89it/s]
Alignments filepath: /home/dms/faceswap/photo/trump/alignments.json
Writing alignments to: /home/dms/faceswap/photo/trump/alignments.json
-------------------------
Images found:        1
Faces detected:      0
-------------------------
Done!

and in the /faceswap/photo/trump folder:it generate "aligned" folder and "alignments.json" file the "aligned" folder has nothing in it and the "alignments.json" 's context is "{}"... Is my problem is "dlib" not installed?

Then I execute sudo pip install -r requirements-gpu-python36-cuda9.txt again and all lib is installed successfully. There is only one photo in the /faceswap/photo/cage and /faceswap/photo/trump folder, then I execute python faceswap.py extract -i ~/faceswap/photo/trump -o ~/faceswap/data/trump and python faceswap.py extract -i ~/faceswap/photo/cage -o ~/faceswap/data/cage:

Input Directory: /home/dms/faceswap/photo/cage
Output Directory: /home/dms/faceswap/data/cage
Filter: filter.jpg
Using json serializer
Starting, this may take a while...
Loading Extract from Extract_Align plugin...
  0%|                                                                                   | 0/1 [00:00<?, ?it/s]/home/dms/.virtualenvs/faceswap_env_python36/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
Using TensorFlow backend.
100%|███████████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  1.88it/s]
Alignments filepath: /home/dms/faceswap/photo/cage/alignments.json
Writing alignments to: /home/dms/faceswap/photo/cage/alignments.json
-------------------------
Images found:        1
Faces detected:      0
-------------------------
Done!

outcome is both in the /faceswap/photo/cage and /faceswap/photo/trump folder's "alignments.json" 's context is "{}",and there is nothing in /faceswap/data/cage and /faceswap/data/trump folder.so what should I do? please help me ,If my question is not stated clearly, please tell me.Thank you~

gessyoo commented 6 years ago

theoldgun, I'm not using Ubuntu, but how about trying more than one trump and cage photo and running the extract process again to test? Your output indicates that convert found the image but couldn't recognize the face. If the face is too small, or a face profile or sharp face angle or a blurry face, the extract or convert process may not recognize it. Try extract with more input photos, most should have recognized faces. If no faces are recognized in multiple photos, there may be an issue with your python install.

theoldgun commented 6 years ago

Thank you for help me @gessyoo .I tried more photo but also Faces detected: 0.some photo came from Internet and I also tried some photo from train data.The outcomes is same,the problem is still unresolved.

Kirin-kun commented 6 years ago

There's a possibility that your dlib, although installed, doesn't support CUDA.

Can you run python and type:

import dlib dlib.DLIB_USE_CUDA

If it doesn't say "True", your dlib isn't compiled properly.

torzdf commented 6 years ago

Also run your extract with the -v flag: python faceswap.py extract -i ~/faceswap/photo/trump -o ~/faceswap/data/trump -v

It should hopefully give you a message about why a face wasn't found