This project is applying the style of drawing from one art piece to another by a deep learning algorithm in Python.
In 2019, I was in the final year of university and wanted to write a program to have a visually taste of the power of deep leanring.
- Generating an image by blending two different images
Project is completed
Input
Content Image
Style Image
Output
Built with
- TensorFlow
- Clone or download this repo.
- Choose two .jpg as input, one as a content image, and the other one as a style image.
Style image is the image whose style would be transferred to the content image. - Open main.ipynb in the folder
- Write the following code in main.ipynb.
content_path = '{path of content image}'
style_path = '{path of style image}'
target_path = '{path of output image}'
best_{output image name}, best_loss = run_style_transfer(content_path, style_path, num_iterations = 300)
Image.fromarray(best_{output image name}).save(target_path)
Image.fromarray(best_{output image name})
show_results(best_{output image name}, '{path of content image}', '{path of style image}')
Remarks: It is a Jupyter Notebook. You can also read the code I wrote in blocks 76 to 78 as a demonstration.
Thanks for providing art pieces, Tsz Wai, my friend in Hong Kong.