reference:

GAN 讲解

 

https://blog.csdn.net/u010900574/article/details/53427544 

命令行解析

https://blog.csdn.net/qq_24193303/article/details/80810892

命令行解析的坑

https://blog.csdn.net/qq_25964837/article/details/79077504

注意其内部参数

from __future__ import print_function
from keras.preprocessing.image import load_img, save_img, img_to_array
import numpy as np
from scipy.optimize import fmin_l_bfgs_b
import time
import argparse

from keras.applications import vgg19
from keras import backend as K

parser = argparse.ArgumentParser(description='Neural style transfer with Keras.')
parser.add_argument('base_image_path', metavar='base', type=str,
                    help='Path to the image to transform.')
parser.add_argument('style_reference_image_path', metavar='ref', type=str,
                    help='Path to the style reference image.')
parser.add_argument('result_prefix', metavar='res_prefix', type=str,
                    help='Prefix for the saved results.')
parser.add_argument('--iter', type=int, default=10, required=False,
                    help='Number of iterations to run.')
parser.add_argument('--content_weight', type=float, default=0.025, required=False,
                    help='Content weight.')
parser.add_argument('--style_weight', type=float, default=1.0, required=False,
                    help='Style weight.')
parser.add_argument('--tv_weight', type=float, default=1.0, required=False,
                    help='Total Variation weight.')

 

(base) C:Userslenovo>activate tf

(tf) C:Userslenovo>d
'd' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

(tf) C:Userslenovo>d:

(tf) D:>D:adevelopkerasGANkeras-masterexamples
'D:adevelopkerasGANkeras-masterexamples' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

(tf) D:>cd D:adevelopkerasGANkeras-masterexamples

(tf) D:adevelopkerasGANkeras-masterexamples>python neural_style_transfer.py "D:\adevelop\keras\img\tanm.jpg" "D:\adevelop\keras\img\vonga.jpg" "D:\adevelop\keras\img\tiananmen_fangao"
Using TensorFlow backend.
Downloading data from https://github.com/fchollet/deep-learning-models/releases/download/v0.1/vgg19_weights_tf_dim_ordering_tf_kernels_notop.h5
forrtl: error (200): program aborting due to control-C event
Image              PC                Routine            Line        Source
libifcoremd.dll    00007FFBBCFB94C4  Unknown               Unknown  Unknown
KERNELBASE.dll     00007FFC07A656FD  Unknown               Unknown  Unknown
KERNEL32.DLL       00007FFC089C3034  Unknown               Unknown  Unknown
ntdll.dll          00007FFC0AF93691  Unknown               Unknown  Unknown

(tf) D:adevelopkerasGANkeras-masterexamples>python neural_style_transfer.py "D:\adevelop\keras\img\tanm.jpg" "D:\adevelop\keras\img\vonga.jpg" "D:\adevelop\keras\img\tiananmen_fangao"
Using TensorFlow backend.
Downloading data from https://github.com/fchollet/deep-learning-models/releases/download/v0.1/vgg19_weights_tf_dim_ordering_tf_kernels_notop.h5
80142336/80134624 [==============================] - 27s 0us/step
2018-12-21 00:00:22.912925: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
2018-12-21 00:00:23.111711: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1432] Found device 0 with properties:
name: GeForce GTX 1060 6GB major: 6 minor: 1 memoryClockRate(GHz): 1.7845
pciBusID: 0000:01:00.0
totalMemory: 6.00GiB freeMemory: 4.97GiB
2018-12-21 00:00:23.115455: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1511] Adding visible gpu devices: 0
2018-12-21 00:00:23.474086: I tensorflow/core/common_runtime/gpu/gpu_device.cc:982] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-12-21 00:00:23.476305: I tensorflow/core/common_runtime/gpu/gpu_device.cc:988]      0
2018-12-21 00:00:23.477352: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1001] 0:   N
2018-12-21 00:00:23.479132: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4720 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:01:00.0, compute capability: 6.1)
Model loaded.
WARNING:tensorflow:Variable += will be deprecated. Use variable.assign_add if you want assignment to the variable value or 'x = x + y' if you want a new python Tensor object.
Start of iteration 0
Current loss value: 4708729000.0
Image saved as D:\adevelop\keras\img\tiananmen_fangao_at_iteration_0.png
Iteration 0 completed in 12s
Start of iteration 1
Current loss value: 2911683000.0
Image saved as D:\adevelop\keras\img\tiananmen_fangao_at_iteration_1.png
Iteration 1 completed in 9s
Start of iteration 2
Current loss value: 2555891200.0
Image saved as D:\adevelop\keras\img\tiananmen_fangao_at_iteration_2.png
Iteration 2 completed in 9s
Start of iteration 3
Current loss value: 2370041300.0
Image saved as D:\adevelop\keras\img\tiananmen_fangao_at_iteration_3.png
Iteration 3 completed in 9s
Start of iteration 4
Current loss value: 2268962800.0
Image saved as D:\adevelop\keras\img\tiananmen_fangao_at_iteration_4.png
Iteration 4 completed in 9s
Start of iteration 5
Current loss value: 2198608600.0
Image saved as D:\adevelop\keras\img\tiananmen_fangao_at_iteration_5.png
Iteration 5 completed in 9s
Start of iteration 6
Current loss value: 2155104300.0
Image saved as D:\adevelop\keras\img\tiananmen_fangao_at_iteration_6.png
Iteration 6 completed in 9s
Start of iteration 7
Current loss value: 2122974200.0
Image saved as D:\adevelop\keras\img\tiananmen_fangao_at_iteration_7.png
Iteration 7 completed in 9s
Start of iteration 8
Current loss value: 2096054800.0
Image saved as D:\adevelop\keras\img\tiananmen_fangao_at_iteration_8.png
Iteration 8 completed in 9s
Start of iteration 9
Current loss value: 2074734200.0
Image saved as D:\adevelop\keras\img\tiananmen_fangao_at_iteration_9.png
Iteration 9 completed in 9s

(tf) D:adevelopkerasGANkeras-masterexamples>

 keras04  GAN simple