0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

■How to execute "TensorFlow CNN for fast style transfer" which comes from GitHub by using Google Colaboratry

Last updated at Posted at 2020-05-01

Introduction

GitHub:TensorFlow CNN for fast style transfer instructs how to use Tensorflow, and shows example of picture style change below.

Before
image.png

After applied wave.ckpt
image.png

Setup of Google Colaboratory Environment

First, we need to mount on Google Drive, and upload files you want to use.

  • evaluate.py
  • optimize.py <- this file is located under src folder of fast-style-transfer-master.
  • transform.py <- this file is located under src folder of fast-style-transfer-master.
  • utils.py <- this file is located under src folder of fast-style-transfer-master.
  • vgg.py <- this file is located under src folder of fast-style-transfer-master.
  • stata.jpg <- picture file you want to transform. Any picture is OK.
  • wave.ckpt <- checkpoint file you wan to use as style.

image.png

Setup Libraries

Since some files are programed by its previous version, you need to uninstall new one, and install previous version so that these files can run.

!pip uninstall scipy # Uninstalling scipy-1.4.1:
!pip install scipy==1.1.0
!pip uninstall tensorflow # Uninstalling tensorflow-2.2.0rc3:
!pip install tensorflow==1.1.0

Execution command

According to GitHub page, it's shown how to execute these files below.
image.png

!python evaluate.py --checkpoint ./wave.ckpt \  # The style file you want to use.
  --in-path ./stata.jpg \  # The original picture you want to transform.
  --out-path ./out.jpg     # name of output file

After execution this command, "out.jpg" is generated below.
image.png

Result of Another Sample

image.png

References

LINK
-> GitHub:TensorFlow CNN for fast style transfer
-> Pythonチートシート(for C++経験者)
-> Neural Style Transfer: Prismaの背景技術を解説する
-> Pythonでの数値計算ライブラリNumPy徹底入門
-> Python Basic - Pandas, Numpy

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?