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

Commit 9d8ab0e

Browse files
authored
Merge pull request #69 from alexjc/v0.3
Release 0.3
2 parents c8e8056 + 80d7b57 commit 9d8ab0e

File tree

4 files changed

+90
-56
lines changed

4 files changed

+90
-56
lines changed

README.rst

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,27 @@ The default is to use ``--device=cpu``, if you have NVIDIA card setup with CUDA
3535
1.a) Enhancing Images
3636
---------------------
3737

38+
A list of example command lines you can use with the pre-trained models provided in the GitHub releases:
39+
3840
.. code:: bash
3941
40-
# Run the super-resolution script for one image, factor 1:1.
41-
python3 enhance.py --zoom=1 example.png
42+
# Run the super-resolution script to repair JPEG artefacts, zoom factor 1:1.
43+
python3 enhance.py --type=photo --model=repair --zoom=1 broken.jpg
4244
43-
# Also process multiple files with a single run, factor 2:1.
44-
python3 enhance.py --zoom=2 file1.jpg file2.jpg
45+
# Process multiple good quality images with a single run, zoom factor 2:1.
46+
python3 enhance.py --type=photo --zoom=2 file1.jpg file2.jpg
4547
4648
# Display output images that were given `_ne?x.png` suffix.
4749
open *_ne?x.png
4850
51+
Here's a list of currently supported models, image types, and zoom levels in one table.
52+
53+
================== ===================== ==================== ===================== ====================
54+
FEATURES ``--model=default`` ``--model=repair`` ``--model=denoise`` ``--model=deblur``
55+
================== ===================== ==================== ===================== ====================
56+
``--type=photo`` 2x 1x … …
57+
================== ===================== ==================== ===================== ====================
58+
4959

5060
1.b) Training Super-Resolution
5161
------------------------------
@@ -55,7 +65,7 @@ Pre-trained models are provided in the GitHub releases. Training your own is a
5565
.. code:: bash
5666
5767
# Remove the model file as don't want to reload the data to fine-tune it.
58-
rm -f ne4x*.pkl.bz2
68+
rm -f ne?x*.pkl.bz2
5969
6070
# Pre-train the model using perceptual loss from paper [1] below.
6171
python3.4 enhance.py --train "data/*.jpg" --model custom --scales=2 --epochs=50 \
@@ -69,7 +79,7 @@ Pre-trained models are provided in the GitHub releases. Training your own is a
6979
--discriminator-size=64
7080
7181
# The newly trained model is output into this file...
72-
ls ne4x-custom-*.pkl.bz2
82+
ls ne?x-custom-*.pkl.bz2
7383
7484
7585
.. image:: docs/BankLobby_example.gif
@@ -84,22 +94,29 @@ Pre-trained models are provided in the GitHub releases. Training your own is a
8494

8595
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.
8696

87-
**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:
97+
Here's the simplest way you can call the script using ``docker``, assuming you're familiar with using ``-v` to mount folders you can use this directly to specify files to enhance:
98+
99+
.. code:: bash
100+
101+
# Download the Docker image and show the help text to make sure it works.
102+
docker run --rm -v `pwd`:/ne/input -it alexjc/neural-enhance --help
103+
104+
**Single Image** — In practice, 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:
88105

89106
.. code:: bash
90107
91108
# Setup the alias. Put this in your .bashrc or .zshrc file so it's available at startup.
92-
alias enhance='function ne() { docker run --rm -v "$(pwd)/`dirname ${@:$#}`":/ne/input -it alexjc/neural-enhance ${@:1:-1} "input/`basename ${@:$#}`"; }; ne'
109+
alias enhance='function ne() { docker run --rm -v "$(pwd)/`dirname ${@:$#}`":/ne/input -it alexjc/neural-enhance ${@:1:$#-1} "input/`basename ${@:$#}`"; }; ne'
93110
94111
# Now run any of the examples above using this alias, without the `.py` extension.
95-
enhance --zoom=1 --model=small images/example.jpg
112+
enhance --zoom=1 --model=repair images/broken.jpg
96113
97114
**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:
98115

99116
.. code:: bash
100117
101118
# Process multiple images, make sure to quote the argument!
102-
enhance --zoom=2 --model=small "images/*.jpg"
119+
enhance --zoom=2 "images/*.jpg"
103120
104121
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!
105122

docker-cpu.df

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ RUN /opt/conda/bin/python3.5 -m pip install -q -r "requirements.txt"
2626
COPY enhance.py .
2727

2828
# Get a pre-trained neural networks, non-commercial & attribution.
29-
RUN wget -q "https://github.com/alexjc/neural-enhance/releases/download/v0.2/ne1x-small-0.2.pkl.bz2"
30-
RUN wget -q "https://github.com/alexjc/neural-enhance/releases/download/v0.2/ne2x-small-0.2.pkl.bz2"
29+
RUN wget -q "https://github.com/alexjc/neural-enhance/releases/download/v0.3/ne1x-photo-repair-0.3.pkl.bz2"
30+
RUN wget -q "https://github.com/alexjc/neural-enhance/releases/download/v0.3/ne2x-photo-default-0.3.pkl.bz2"
3131

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

docker-gpu.df

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ RUN /opt/conda/bin/python3.5 -m pip install -q -r "requirements.txt"
2424
COPY enhance.py .
2525

2626
# Get a pre-trained neural networks, non-commercial & attribution.
27-
RUN wget -q "https://github.com/alexjc/neural-enhance/releases/download/v0.2/ne1x-small-0.2.pkl.bz2"
28-
RUN wget -q "https://github.com/alexjc/neural-enhance/releases/download/v0.2/ne2x-small-0.2.pkl.bz2"
27+
RUN wget -q "https://github.com/alexjc/neural-enhance/releases/download/v0.3/ne1x-photo-repair-0.3.pkl.bz2"
28+
RUN wget -q "https://github.com/alexjc/neural-enhance/releases/download/v0.3/ne2x-photo-default-0.3.pkl.bz2"
2929

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

0 commit comments

Comments
 (0)