Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: alexjc/neural-enhance
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f9d4d50636a7c4c31a92f4172dac3519a2405b2b
Choose a base ref
..
head repository: alexjc/neural-enhance
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3965e4d0a4d8a82f74a9caf933bc9aa04b6d4af5
Choose a head ref
Showing with 256 additions and 130 deletions.
  1. +20 −13 README.rst
  2. +2 −3 docker-cpu.df
  3. +2 −3 docker-gpu.df
  4. +178 −111 enhance.py
  5. +18 −0 scripts/small-1x.sh
  6. +18 −0 scripts/small-2x.sh
  7. +18 −0 scripts/small-4x.sh
33 changes: 20 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
@@ -37,14 +37,14 @@ The default is to use ``--device=cpu``, if you have NVIDIA card setup with CUDA

.. code:: bash
# Run the super-resolution script for one image.
python3 enhance.py example.png
# Run the super-resolution script for one image, factor 1:1.
python3 enhance.py --zoom=1 example.png
# Also process multiple files with a single run.
python3 enhance.py file1.jpg file2.jpg
# Also process multiple files with a single run, factor 2:1.
python3 enhance.py --zoom=2 file1.jpg file2.jpg
# Display output images that were given `_ne4x.png` suffix.
open *_ne4x.png
# Display output images that were given `_ne?x.png` suffix.
open *_ne?x.png
1.b) Training Super-Resolution
@@ -84,17 +84,24 @@ 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 <https://www.docker.com/>`_. 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 <https://hub.docker.com/r/alexjc/neural-enhance/>`_ 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"
# Setup the alias. Put this in your .bashrc or .zshrc file so it's available at startup.
alias enhance='function ne() { docker run --rm -v "$(pwd)/`dirname ${@:$#}`":/ne/input -it alexjc/neural-enhance ${@:1:-1} "input/`basename ${@:$#}`"; }; ne'
# Now run any of the examples above using this alias, without the `.py` extension.
enhance images/example.jpg
enhance --zoom=1 --model=small 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 command:

.. code:: bash
# Process multiple images, make sure to quote the argument!
enhance --zoom=2 --model=small "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 <https://github.com/NVIDIA/nvidia-docker>`_ and it should use your physical hardware!
If you want to run on your NVIDIA GPU, you can instead change the alias to use the image ``alexjc/neural-enhance:gpu`` which comes with CUDA and CUDNN pre-installed. Then run it within `nvidia-docker <https://github.com/NVIDIA/nvidia-docker>`_ and it should use your physical hardware!


2.b) Manual Installation [developers]
@@ -172,7 +179,7 @@ You need to install Lasagne and Theano directly from the versions specified in `
ValueError: unknown locale: UTF-8
---------------------------------

It seems your terminal is misconfigured and not compatible with the way Python treats locales. You may need to change this in your ``.bash_rc`` or other startup script. Alternatively, this command will fix it once for this shell instance.
It seems your terminal is misconfigured and not compatible with the way Python treats locales. You may need to change this in your ``.bashrc`` or other startup script. Alternatively, this command will fix it once for this shell instance.

**FIX:** ``export LC_ALL=en_US.UTF-8``

5 changes: 2 additions & 3 deletions docker-cpu.df
Original file line number Diff line number Diff line change
@@ -26,9 +26,8 @@ RUN /opt/conda/bin/python3.5 -m pip install -q -r "requirements.txt"
COPY enhance.py .

# Get a pre-trained neural networks, non-commercial & attribution.
RUN wget -q "https://github.com/alexjc/neural-enhance/releases/download/v0.1/ne4x-small-0.1.pkl.bz2"
RUN wget -q "https://github.com/alexjc/neural-enhance/releases/download/v0.1/ne4x-medium-0.1.pkl.bz2"
RUN wget -q "https://github.com/alexjc/neural-enhance/releases/download/v0.1/ne4x-large-0.1.pkl.bz2"
RUN wget -q "https://github.com/alexjc/neural-enhance/releases/download/v0.2/ne1x-small-0.2.pkl.bz2"
RUN wget -q "https://github.com/alexjc/neural-enhance/releases/download/v0.2/ne2x-small-0.2.pkl.bz2"

# Set an entrypoint to the main enhance.py script
ENTRYPOINT ["/opt/conda/bin/python3.5", "enhance.py", "--device=cpu"]
5 changes: 2 additions & 3 deletions docker-gpu.df
Original file line number Diff line number Diff line change
@@ -24,9 +24,8 @@ RUN /opt/conda/bin/python3.5 -m pip install -q -r "requirements.txt"
COPY enhance.py .

# Get a pre-trained neural networks, non-commercial & attribution.
RUN wget -q "https://github.com/alexjc/neural-enhance/releases/download/v0.1/ne4x-small-0.1.pkl.bz2"
RUN wget -q "https://github.com/alexjc/neural-enhance/releases/download/v0.1/ne4x-medium-0.1.pkl.bz2"
RUN wget -q "https://github.com/alexjc/neural-enhance/releases/download/v0.1/ne4x-large-0.1.pkl.bz2"
RUN wget -q "https://github.com/alexjc/neural-enhance/releases/download/v0.2/ne1x-small-0.2.pkl.bz2"
RUN wget -q "https://github.com/alexjc/neural-enhance/releases/download/v0.2/ne2x-small-0.2.pkl.bz2"

# Set an entrypoint to the main enhance.py script
ENTRYPOINT ["/opt/conda/bin/python3.5", "enhance.py", "--device=gpu"]
Loading