aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--__pycache__/hyperparameters.cpython-38.pycbin369 -> 0 bytes
-rw-r--r--__pycache__/losses.cpython-38.pycbin4646 -> 0 bytes
-rw-r--r--__pycache__/preprocess.cpython-38.pycbin5074 -> 0 bytes
-rw-r--r--content.jpgbin0 -> 45172 bytes
-rw-r--r--hyperparameters.py8
-rw-r--r--losses.py2
-rw-r--r--main.py6
-rw-r--r--save.jpgbin13084 -> 19949 bytes
-rw-r--r--style.jpgbin0 -> 43386 bytes
9 files changed, 8 insertions, 8 deletions
diff --git a/__pycache__/hyperparameters.cpython-38.pyc b/__pycache__/hyperparameters.cpython-38.pyc
deleted file mode 100644
index 5fc87730..00000000
--- a/__pycache__/hyperparameters.cpython-38.pyc
+++ /dev/null
Binary files differ
diff --git a/__pycache__/losses.cpython-38.pyc b/__pycache__/losses.cpython-38.pyc
deleted file mode 100644
index 703088c9..00000000
--- a/__pycache__/losses.cpython-38.pyc
+++ /dev/null
Binary files differ
diff --git a/__pycache__/preprocess.cpython-38.pyc b/__pycache__/preprocess.cpython-38.pyc
deleted file mode 100644
index c0441c30..00000000
--- a/__pycache__/preprocess.cpython-38.pyc
+++ /dev/null
Binary files differ
diff --git a/content.jpg b/content.jpg
new file mode 100644
index 00000000..163629cd
--- /dev/null
+++ b/content.jpg
Binary files differ
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
diff --git a/losses.py b/losses.py
index f08a734c..99b1eded 100644
--- a/losses.py
+++ b/losses.py
@@ -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
diff --git a/main.py b/main.py
index 9fceccf1..4497cce0 100644
--- a/main.py
+++ b/main.py
@@ -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/save.jpg b/save.jpg
index 9155df97..e35f2cbf 100644
--- a/save.jpg
+++ b/save.jpg
Binary files differ
diff --git a/style.jpg b/style.jpg
new file mode 100644
index 00000000..105ac2d1
--- /dev/null
+++ b/style.jpg
Binary files differ