Neural-Style Automator
Given that I make constant use of it, I decided to create a wrapper around the neural-style-tf main routine. This would allow me to run an image through a sweep of styles without supervision over long periods of time.
Development
After installing and testing the neural-style-tf package, we are going to create a simple wrapper that allows us to go through styles that we want to apply onto an image of our chosing. The first thing we need, is to load the libraries we will need and setup some parameters such as our working directories:
After doing this, we setup the required variables to read from the terminal: the path to the image to stylize, the path to the folder in which the styles are stored, and the path to which we want our results exported.
The easiest way to run the neural-style-tf package automatically with different inputs without diving into the underlying programming structure, was to make iterated terminal calls from within python. To do this, we repeatedly call the neural_style.py script (of which I am not an author, so follow the link for the original reference) from our main routine. To do this, we first get the paths to the style images, and count the number of styles (for counting purposes):
Now, for the automation part, we iterate through the styles and generate the bash calls for the neural_style.py script according to its protocol:
And we’re done! We can now iterate through images without any supervision!
Documentation and Code
- Repository: Github repo
- Dependencies: neural-style-tf, open-cv, tensorflow, VGG-19 model weights