From fef84c5b44d8b2d0317351f3cc1d09d686ea908c Mon Sep 17 00:00:00 2001 From: Michael Feldstein Date: Sun, 30 Oct 2016 19:24:50 -0700 Subject: [PATCH 1/4] Remove cnmem theano flag since it doesn't work if you're sharing GPU with display. --- enhance.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enhance.py b/enhance.py index 23ca9d2..cb67e17 100755 --- a/enhance.py +++ b/enhance.py @@ -96,7 +96,7 @@ print("""{} {}Super Resolution for images and videos powered by Deep Learning! # Load the underlying deep learning libraries based on the device specified. If you specify THEANO_FLAGS manually, # the code assumes you know what you are doing and they are not overriden! os.environ.setdefault('THEANO_FLAGS', 'floatX=float32,device={},force_device=True,allow_gc=True,'\ - 'print_active_device=False,lib.cnmem=1.0'.format(args.device)) + 'print_active_device=False'.format(args.device)) # Scientific & Imaging Libraries import numpy as np From 02d2fca6c53311d87f2f64831ed8470b8ddc06ac Mon Sep 17 00:00:00 2001 From: "Alex J. Champandard" Date: Mon, 31 Oct 2016 20:55:11 +0100 Subject: [PATCH 2/4] Corrected value for adversarial loss. Don't refactor math the day after stopping coffee. --- README.rst | 2 +- enhance.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index ffa3331..a4948f8 100644 --- a/README.rst +++ b/README.rst @@ -64,7 +64,7 @@ Pre-trained models are provided in the GitHub releases. Training your own is a # Train the model using an adversarial setup based on [4] below. python3.4 enhance.py --train "data/*.jpg" --model custom --scales=2 --epochs=250 \ - --perceptual-layer=conv5_2 --smoothness-weight=2e4 --adversary-weight=2e5 \ + --perceptual-layer=conv5_2 --smoothness-weight=2e4 --adversary-weight=1e3 \ --generator-start=5 --discriminator-start=0 --adversarial-start=5 \ --discriminator-size=64 diff --git a/enhance.py b/enhance.py index cb67e17..c4fd9fb 100755 --- a/enhance.py +++ b/enhance.py @@ -374,7 +374,7 @@ class Model(object): return T.mean(((x[:,:,:-1,:-1] - x[:,:,1:,:-1])**2 + (x[:,:,:-1,:-1] - x[:,:,:-1,1:])**2)**1.25) def loss_adversarial(self, d): - return T.mean(1.0 - T.nnet.softplus(d[args.batch_size:])) + return T.mean(1.0 - T.nnet.softminus(d[args.batch_size:])) def loss_discriminator(self, d): return T.mean(T.nnet.softminus(d[args.batch_size:]) - T.nnet.softplus(d[:args.batch_size])) From 34f8e629c25c8f6732a9bd94469f2f94c31ebebb Mon Sep 17 00:00:00 2001 From: "Alex J. Champandard" Date: Tue, 1 Nov 2016 09:54:58 +0100 Subject: [PATCH 3/4] Improve the alias used to invoke docker, so it's more robust to directory locations and input paths. --- README.rst | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index a4948f8..8531152 100644 --- a/README.rst +++ b/README.rst @@ -84,16 +84,23 @@ Pre-trained models are provided in the GitHub releases. Training your own is a The easiest way to get up-and-running is to `install Docker `_. Then, you should be able to download and run the pre-built image using the ``docker`` command line tool. Find out more about the ``alexjc/neural-enhance`` image on its `Docker Hub `_ page. -We recommend you setup an alias called ``enhance`` to automatically expose your ``images`` folder from the current directory so the script can access files and store results where you can access them. This is how you can do it in your terminal console on OSX or Linux: +**Single Image** — We suggest you setup an alias called ``enhance`` to automatically expose the folder containing your specified image, so the script can read it and store results where you can access them. This is how you can do it in your terminal console on OSX or Linux: .. code:: bash # Setup the alias. Put this in your .bash_rc or .zshrc file so it's available at startup. - alias enhance="docker run -v $(pwd)/images:/ne/images -it alexjc/neural-enhance" + alias enhance="function ne() { docker run -v \`dirname \$1\`:/ne/input -it alexjc/neural-enhance input/\`basename \$1\`; }; ne" # Now run any of the examples above using this alias, without the `.py` extension. enhance images/example.jpg +**Multiple Images** — To enhance multiple images in a row (faster) from a folder or widlcard specification, make sure to quote the argument to the alias: + +.. code:: bash + + # Process multiple images, make sure to quote the argument! + enhance "images/*.jpg" + If you want to run on your NVIDIA GPU, you can instead use the image ``alexjc/neural-enhance:gpu`` which comes with CUDA and CUDNN pre-installed in the image. Then run it within `nvidia-docker `_ and it should use your physical hardware! From 0c31e5373184b729b87fe453070b8e43576f4342 Mon Sep 17 00:00:00 2001 From: "Alex J. Champandard" Date: Tue, 1 Nov 2016 15:11:55 +0100 Subject: [PATCH 4/4] Fix suggested alias for relative paths. Closes #37 #28. --- README.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 8531152..e0110f3 100644 --- a/README.rst +++ b/README.rst @@ -89,12 +89,12 @@ The easiest way to get up-and-running is to `install Docker