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

Commit 965bd55

Browse files
committed
Add new model selection (by image type and 'enhance' operation) and parameters and documentation in README.
1 parent e612087 commit 965bd55

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

README.rst

Lines changed: 14 additions & 4 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+
``--model=default`` ``--model=repair`` ``--model=denoise`` ``--model=deblur``
55+
================== ===================== ==================== ===================== ====================
56+
``--type=photo`` 2x 1x … …
57+
================== ===================== ==================== ===================== ====================
58+
4959

5060
1.b) Training Super-Resolution
5161
------------------------------

enhance.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
add_arg('--zoom', default=1, type=int, help='Resolution increase factor for inference.')
4040
add_arg('--rendering-tile', default=128, type=int, help='Size of tiles used for rendering images.')
4141
add_arg('--rendering-overlap', default=32, type=int, help='Number of pixels padding around each tile.')
42-
add_arg('--model', default='small', type=str, help='Name of the neural network to load/save.')
42+
add_arg('--type', default='photo', type=str, help='Name of the neural network to load/save.')
43+
add_arg('--model', default='default', type=str, help='Specific trained version of the model.')
4344
add_arg('--train', default=False, type=str, help='File pattern to load for training.')
4445
add_arg('--train-scales', default=0, type=int, help='Randomly resize images this many times.')
4546
add_arg('--train-blur', default=None, type=int, help='Sigma value for gaussian blur preprocess.')
@@ -371,12 +372,12 @@ def cast(p): return p.get_value().astype(np.float16)
371372
params = {k: [cast(p) for p in l.get_params()] for (k, l) in self.list_generator_layers()}
372373
config = {k: getattr(args, k) for k in ['generator_blocks', 'generator_residual', 'generator_filters'] + \
373374
['generator_upscale', 'generator_downscale']}
374-
filename = 'ne%ix-%s-%s.pkl.bz2' % (args.zoom, args.model, __version__)
375+
filename = 'ne%ix-%s-%s-%s.pkl.bz2' % (args.zoom, args.type, args.model, __version__)
375376
pickle.dump((config, params), bz2.open(filename, 'wb'))
376377
print(' - Saved model as `{}` after training.'.format(filename))
377378

378379
def load_model(self):
379-
filename = 'ne%ix-%s-%s.pkl.bz2' % (args.zoom, args.model, __version__)
380+
filename = 'ne%ix-%s-%s-%s.pkl.bz2' % (args.zoom, args.type, args.model, __version__)
380381
if not os.path.exists(filename):
381382
if args.train: return {}, {}
382383
error("Model file with pre-trained convolution layers not found. Download it here...",

0 commit comments

Comments
 (0)