Style conversion with python Easy memorandum with git clone [For intermediate users]

There is a style conversion that learns the style of painting with AI and converts the photo actually taken. Recently, it has become an application, but this time we will actually execute python and perform conversion. However, I can't make it myself, so I will get the source from the git of my predecessors.

This time, we will perform the style conversion of fast-neural-style-keras. You can use fast-neural-style-keras here by executing the command described in how to use, but currently (2020) it does not work well due to the version update of the library. This code was posted to git in 2017! The progress of the times and the library is fast, isn't it?

When I investigated, [Bugs that appeared before moving the style conversion]( % 82% A4% E3% 82% B1% E3% 83% A1% E3% 83% B3% E3% 81% AB% E3% 81% 99% E3% 82% 8B% E6% 99% 82% E4% BB % A3-3313e033af83) has summarized the corrections, so I made the corrections according to this article, but it seems that some libraries have been updated further, so I made a note of the code corrections and the version of the library used. It is summarized below.

Execution environment

python 3.7.9 tensorflow 1.13.1 Keras 2.2.3 imageio 2.9.0 scipy 1.2.0

Code fix

For methods such as git clone [Bugs that appeared before moving the style conversion]( % E3% 82% B1% E3% 83% A1% E3% 83% B3% E3% 81% AB% E3% 81% 99% E3% 82% 8B% E6% 99% 82% E4% BB% A3-3313e033af83 )Please Confirm. In my article, I will write only the minimum code corrections.

#Before correction
from keras.applications.imagenet_utils import decode_predictions, preprocess_input, _obtain_input_shape
from keras_applications.imagenet_utils import decode_predictions, preprocess_input, _obtain_input_shape

#Line 87
#Before correction

#import added
import imageio

#Line 107
#Before correction
imsave('%s_output.png' % output_file, y)
imageio.imwrite(output_file+'/'+style+'img_saved.jpg', y.astype(np.uint8))

It's time to convert

Place the image file [test.jpg] you want to convert directly under the fast-neural-style-keras \ images folder. Create a result output folder [output] directly under fast-neural-style-keras . Execute the following command. This time, I have selected Thirty-six Views of Tomitake (stayle wave_crop).

python -i images/test.jpg -s wave_crop -b 0.1 -o output

Input image


Style conversion result


I converted the image of a cat of free material. Please give it a try. Please ask if there is a problem such as not working. We will do our best to accommodate you. If you can convert it safely, please LGTM lol

Recommended Posts

Style conversion with python Easy memorandum with git clone [For intermediate users]
Modern Python for intermediate users
Easy keyword extraction with TermExtract for Python
[Co-occurrence analysis] Easy co-occurrence analysis with Python! [Python]
BigQuery integration for Python users
Easy folder synchronization with Python
Easy Python compilation with NUITKA-Utilities
Easy HTTP server with Python
[Python] Easy parallel processing with Joblib
Getting Started with Python for PHPer-Classes
MP3 to WAV conversion with Python
Easy Python + OpenCV programming with Canopy
Git & Github & python & VScode Personal memorandum
Easy email sending with haste python3
Bayesian optimization very easy with Python
Easy data visualization with Python seaborn.
Easy parallel execution with python subprocess
Easy modeling with Blender and Python
Getting Started with Python for PHPer-Functions