1. Products
  2.   Image
  3.   Python
  4.   Neural Enhance
 
  

Open-Source Python API for Images

Super Resolution for Images using Deep Learning

What is Neural Enhance?

Neural Enhance is an open-source Python API for image enhancement. The API enhances the image using deep learning, using the API it is possible to train the neural network and zoom 2x or even 4x into your images. You can enhance the images by increasing the number of neurons in the image, with a dataset similar to your low-resolution image.

You can enhance your images using both CPU & GPU rendering HQ. Generating 1080p output on GPU should take around 5s or 2s per image and CPU rendering HQ should take around 20-60s for 1080 output.

Previous Next

Getting Started with Neural Enhance

The recommended way to install Neural Enhance is via Docker. Please use the following command to install Neural Enhance.

Install Neural Enhance via Docker

docker run --rm -v `pwd`:/ne/input -it alexjc/neural-enhance --help

Enhance Images via Free Python API

Neural-Enhance API allows enhancing images programmatically. The API provides a list of commands that you can use with the pre-trained model available in the API. Using the API, you can run the super-resolution script to repair JPEG artifacts, zoom factors, process multiple quality images with a single run, and display the output images. You can easily enhance your images by using this one line of code

Enhance Images via Python

  1. Open Command Prompt
  2. Goto the enhance.py directory
  3. Run the following command and pass file type, repair, zoom option, and image path to be enhanced

Enhance Images via Python

# Run the super-resolution script to repair JPEG artefacts, zoom factor 1:1.
python3 enhance.py --type=photo --model=repair --zoom=1 broken.jpg

# Process multiple good quality images with a single run, zoom factor 2:1.
python3 enhance.py --type=photo --zoom=2 file1.jpg file2.jpg

# Display output images that were given `_ne?x.png` suffix.
open *_ne?x.png
                                
  

Training Super-Resolution Images via Python

The Open Source image library Neural Enhance training your images using your own way. The API comes with default pre-trained models, you can train your own process by using parameters based on your image dataset. You can train your model by using perceptual loss from paper, train your model using an adversarial setup, and more.

Use Pre-trained Models & Training Super-Resolution via Python API

# Pre-train the model using perceptual loss from paper [1] below.
python3.4 enhance.py --train "data/*.jpg" --model custom --scales=2 --epochs=50 \
    --perceptual-layer=conv2_2 --smoothness-weight=1e7 --adversary-weight=0.0 \
    --generator-blocks=4 --generator-filters=64

# 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=1e3 \
         --generator-start=5 --discriminator-start=0 --adversarial-start=5 \
         --discriminator-size=64

# The newly trained model is output into this file...
ls ne?x-custom-*.pkl.bz2
 English