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](https://medium.com/lsc-psd/ai%E3%81%8C%E4%BA%BA%E3%82%92%E3 % 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.
python 3.7.9 tensorflow 1.13.1 Keras 2.2.3 imageio 2.9.0 scipy 1.2.0
For methods such as git clone [Bugs that appeared before moving the style conversion](https://medium.com/lsc-psd/ai%E3%81%8C%E4%BA%BA%E3%82%92%E3%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 )Please Confirm. In my article, I will write only the minimum code corrections.
VGG16.py
#Before correction
from keras.applications.imagenet_utils import decode_predictions, preprocess_input, _obtain_input_shape
#Revised
from keras_applications.imagenet_utils import decode_predictions, preprocess_input, _obtain_input_shape
#Line 87
#Before correction
include_top=include_top
#Revised
require_flatten=include_top
transform.py
#import added
import imageio
#Line 107
#Before correction
imsave('%s_output.png' % output_file, y)
#Revised
imageio.imwrite(output_file+'/'+style+'img_saved.jpg', y.astype(np.uint8))
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 transform.py -i images/test.jpg -s wave_crop -b 0.1 -o output
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