faceswap icon indicating copy to clipboard operation
faceswap copied to clipboard

'WindowsPath' object has no attribute 'encode' when running train

Open modelsex opened this issue 8 years ago • 7 comments

I just updated latest version. But failed to use any models on Windows10. I am sure all things work well before I update. After updated, even replace model still can't fix this problem.

Actual behavior

Output as follow: Model A Directory: D:\project5\data_A\aligned Model B Directory: D:\project5\data_B\aligned Training data directory: D:\face\project5\models Loading data, this may take a while... Using live preview Loading Model from Model_Original plugin... Using TensorFlow backend. Failed loading existing training data. 'WindowsPath' object has no attribute 'encode' <<----- this error happened Loading Trainer from Model_Original plugin... Starting. Press "Enter" to stop training and save model 2018-02-07 21:30:46.586834: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2 2018-02-07 21:30:46.897958: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:1030] Found device 0 with properties: name: GeForce GTX 1080 major: 6 minor: 1 memoryClockRate(GHz): 1.7715 pciBusID: 0000:01:00.0 totalMemory: 8.00GiB freeMemory: 6.66GiB 2018-02-07 21:30:46.898121: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0, compute capability: 6.1) 'WindowsPath' object has no attribute 'encode'.18783 <<------ Freeze in this state

Steps to reproduce

python faceswap.py train -A D:/project5/data_A/aligned -B D:/project5/data_B/aligned -m D:/face/project5/models -p

Describe, in some detail, the steps you tried that resulted in the behavior described above.

Other relevant information

  • **Windows
  • Python version: 3.5.2
  • Faceswap version: latest version

modelsex avatar Feb 07 '18 13:02 modelsex

Can you give me also the pathlib version? (pip show pathlib or pip3 show pathlib)

Also is python 3.5.2 latest version on windows?

Clorr avatar Feb 07 '18 13:02 Clorr

Also, can you go in scripts/train.py and remove this:

        except Exception as e:
            print(e)
            exit(1)

And rerun so that I can have more explicit error

Clorr avatar Feb 07 '18 13:02 Clorr

Thanks a lot for reply, really appreciate your work. Should I update to latest python 3.6.4 ?

After removed Exception, log as follow: 2018-02-07 22:02:40.101480: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\gpu\gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: GeForce GTX 1080, pci bus id: 0000:01:00.0, compute capability: 6.1) Exception in thread Thread-1:.14971, loss_B: 0.19145 Traceback (most recent call last): File "C:\Users\xxx\Anaconda3\lib\threading.py", line 914, in _bootstrap_inner self.run() File "C:\Users\xxx\Anaconda3\lib\threading.py", line 862, in run self._target(*self._args, **self._kwargs) File "D:\face\faceswap\scripts\train.py", line 143, in processThread model.save_weights() File "D:\face\faceswap\lib\ModelAE.py", line 36, in save_weights self.encoder.save_weights(self.model_dir / encoderH5) File "C:\Users\xxx\Anaconda3\lib\site-packages\keras\engine\topology.py", line 2603, in save_weights f = h5py.File(filepath, 'w') File "C:\Users\xxx\Anaconda3\lib\site-packages\h5py_hl\files.py", line 267, in init name = name.encode(sys.getfilesystemencoding()) AttributeError: 'WindowsPath' object has no attribute 'encode'


pathlib output: Name: pathlib Version: 1.0.1 Summary: Object-oriented filesystem paths Home-page: https://pathlib.readthedocs.org/ Author: Antoine Pitrou Author-email: [email protected] License: MIT License Location: c:\users\xxx\anaconda3\lib\site-packages Requires:

modelsex avatar Feb 07 '18 14:02 modelsex

It is always better but, I don't think your issue relates to that. It seems something really Windows related. I'll try to check ASAP on a windows machine...

Thanks for your report, it is top quality ;-)

Clorr avatar Feb 07 '18 14:02 Clorr

Can you update to the latest version and let me know if it ok?

Clorr avatar Feb 07 '18 14:02 Clorr

Hi Clorr Issue fixed, I updated all, not sure which one effect, updated python/cmake/dlib to latest one, then all work. Now I have smoke test on extract, thanks a lot !!! This issue can be closed.

BR ModelSex

modelsex avatar Feb 07 '18 16:02 modelsex

It was really a bug in the code, but that i did not have on Linux... Thanks for reporting!

Clorr avatar Feb 07 '18 16:02 Clorr