faceswap icon indicating copy to clipboard operation
faceswap copied to clipboard

Train output and preview in iPython notebook

Open flipflopbboi opened this issue 8 years ago • 4 comments

Hello and thanks everyone for the amazing work in putting this together! I am trying to setup a workflow on a Python 3 Google Colab notebook

I am currently running the train command:

source_dir = '~/drive/source/trump/extracted'
target_dir = '~/drive/target/cage/extracted'
model_dir = '~/drive/models'
!python ~/faceswap/faceswap.py train -A $source_dir -B $target_dir -m $model_dir -v

I have left the script to run for some time and currently getting the following output:

> 2018-02-04 12:15:42.099548: 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-02-04 12:15:42.228572: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:892] 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-02-04 12:15:42.229133: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Found device 0 with properties: 
> name: Tesla K80 major: 3 minor: 7 memoryClockRate(GHz): 0.8235
> pciBusID: 0000:00:04.0
> totalMemory: 11.17GiB freeMemory: 11.11GiB
> 2018-02-04 12:15:42.229170: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1120] Creating TensorFlow device (/device:GPU:0) -> (device: 0, name: Tesla K80, pci bus id: 0000:00:04.0, compute capability: 3.7)
> loaded model weights
> Loading Trainer from Model_Original plugin...
> Starting. Press "Enter" to stop training and save model
> saved model weights
> saved model weights
> saved model weights
> saved model weights
> saved model weights
> saved model weights
> saved model weights
> saved model weights
> saved model weights
> saved model weights

My questions are:

  1. I have disabled the preview argument -p because otherwise I get a display X error and the script crashes. Any ideas on how to re-route preview output in an iPython jupyter notebook? Any further details on how the preview works would be useful to try to hack something together.

  2. I am seeing only saved model weights messages and no printouts on iterations, loss functions etc. is this normal?

  3. How can i exit since I cannot provide keyboard interruprs in the notebook shell?

  • I can try writing a wrapper script around it using pexpect or something similar to supply a keystroke after a set time or after I see a low loss value (but currently loss values are not printing?)
  • If i force close the cell by pressing stop in ipython (equivalent to a Ctrl+C) does the model save progress? can i retrain from where i left?

flipflopbboi avatar Feb 04 '18 13:02 flipflopbboi

If you use -w param, you will have a file written to the disk, but I don't know if you can retrieve it from your notebook.

Otherwise, you can go in scripts/train.py, copy the code, and use this as your notebook, instead of running python from shell. Then you can modify the show function at the bottom of the file, and replace it with : display(Image.fromarray(image)). Don't forget to import the libs:

from PIL import Image
from IPython.display import display

You will have also to set the arguments manually because the arguments parsing won't work

If you have a clean way to use python notebooks, please submit a pull request, and share your notebooks with others. (put them in a /notebook/ folder at the root)

Clorr avatar Feb 04 '18 13:02 Clorr

@flipflopbboi

I think its not printing the loss outputs due to a commit I have made which sets end keyword of the print statement to '\r'. If you remove that it will print every iteration.

It should be saving the progress if it raises KeyboardInterrupt. You should exit using that method.

gdunstone avatar Feb 05 '18 07:02 gdunstone

@flipflopbboi If you solved this, let us know

Clorr avatar Feb 05 '18 12:02 Clorr

thanks for the replies, working on it; indeed removing the \r does print loss functions. Now working on embedding preview window within notebook and compiling a fully working notebook.

flipflopbboi avatar Feb 06 '18 09:02 flipflopbboi