diff options
-rw-r--r-- | __pycache__/hyperparameters.cpython-38.pyc | bin | 369 -> 0 bytes | |||
-rw-r--r-- | __pycache__/losses.cpython-38.pyc | bin | 4646 -> 0 bytes | |||
-rw-r--r-- | __pycache__/preprocess.cpython-38.pyc | bin | 5074 -> 0 bytes | |||
-rw-r--r-- | content.jpg | bin | 0 -> 45172 bytes | |||
-rw-r--r-- | hyperparameters.py | 8 | ||||
-rw-r--r-- | losses.py | 2 | ||||
-rw-r--r-- | main.py | 6 | ||||
-rw-r--r-- | save.jpg | bin | 13084 -> 19949 bytes | |||
-rw-r--r-- | style.jpg | bin | 0 -> 43386 bytes |
9 files changed, 8 insertions, 8 deletions
diff --git a/__pycache__/hyperparameters.cpython-38.pyc b/__pycache__/hyperparameters.cpython-38.pyc Binary files differdeleted file mode 100644 index 5fc87730..00000000 --- a/__pycache__/hyperparameters.cpython-38.pyc +++ /dev/null diff --git a/__pycache__/losses.cpython-38.pyc b/__pycache__/losses.cpython-38.pyc Binary files differdeleted file mode 100644 index 703088c9..00000000 --- a/__pycache__/losses.cpython-38.pyc +++ /dev/null diff --git a/__pycache__/preprocess.cpython-38.pyc b/__pycache__/preprocess.cpython-38.pyc Binary files differdeleted file mode 100644 index c0441c30..00000000 --- a/__pycache__/preprocess.cpython-38.pyc +++ /dev/null diff --git a/content.jpg b/content.jpg Binary files differnew file mode 100644 index 00000000..163629cd --- /dev/null +++ b/content.jpg diff --git a/hyperparameters.py b/hyperparameters.py index a15d04ac..75528742 100644 --- a/hyperparameters.py +++ b/hyperparameters.py @@ -9,17 +9,17 @@ Number of epochs. If you experiment with more complex networks you might need to increase this. Likewise if you add regularization that slows training. """ -num_epochs = 10000 +num_epochs = 500 """ A critical parameter that can dramatically affect whether training succeeds or fails. The value for this depends significantly on which optimizer is used. Refer to the default learning rate parameter """ -learning_rate = .002 +learning_rate = 1e2 momentum = 0.01 -alpha = 1e-2 +alpha = 1 -beta = 5e1 +beta = 100 @@ -166,7 +166,7 @@ class YourModel(tf.keras.Model): for i in range(len(art_layers)): art_layer = art_layers[i] input_layer = input_layers[i] - L_style = tf.math.add(L_style, self.layer_loss(art_layer, input_layer)*(1/5)) + L_style = tf.math.add(L_style, (1/5)*self.layer_loss(art_layer, input_layer)) #print('style loss', L_style) return L_style @@ -13,6 +13,7 @@ from losses import YourModel from skimage.io import imread, imsave from matplotlib import pyplot as plt import numpy as np +from skimage import transform def parse_args(): @@ -61,8 +62,7 @@ def main(): content_image = imread(ARGS.content) style_image = imread(ARGS.style) - style_image = transform.resize(style_image, content_image.shape, anti_aliasing=True) - + style_image = transform.resize(style_image, content_image.shape) my_model = YourModel(content_image=content_image, style_image=style_image) my_model.vgg16.build([1, 255, 255, 3]) my_model.vgg16.load_weights('vgg16_imagenet.h5', by_name=True) @@ -70,7 +70,7 @@ def main(): final_image = tf.squeeze(my_model.x) - plt.imshow(final_image) + plt.imshow(final_image).astype('uint8') imsave(ARGS.savefile, final_image) diff --git a/style.jpg b/style.jpg Binary files differnew file mode 100644 index 00000000..105ac2d1 --- /dev/null +++ b/style.jpg |