aboutsummaryrefslogtreecommitdiff
path: root/losses.py
diff options
context:
space:
mode:
authorDavid Doan <daviddoan@davids-mbp-3.devices.brown.edu>2022-05-07 17:41:40 -0400
committerDavid Doan <daviddoan@davids-mbp-3.devices.brown.edu>2022-05-07 17:41:40 -0400
commit423c72c1eb93ea7fc6aaeba29e1c9f5e376b9fe6 (patch)
treef3994f63e3c2a476ed3cd31bbec168d2a6520557 /losses.py
parent228d83a47b6c6eb1d0c01b85761a8f6e1db48c1d (diff)
testing
Diffstat (limited to 'losses.py')
-rw-r--r--losses.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/losses.py b/losses.py
index 51f387a4..99b1eded 100644
--- a/losses.py
+++ b/losses.py
@@ -11,16 +11,16 @@ class YourModel(tf.keras.Model):
def __init__(self, content_image, style_image): #normalize these images to float values
super(YourModel, self).__init__()
- self.content_image = transform.resize(content_image, tf.shape(style_image), anti_aliasing=True, preserve_range=True).astype('uint8')
+ self.content_image = transform.resize(content_image, tf.shape(style_image), anti_aliasing=True)
self.content_image = tf.expand_dims(self.content_image, axis=0)
print(self.content_image)
#perhaps consider cropping to avoid distortion
- self.style_image = transform.resize(style_image, tf.shape(style_image), anti_aliasing=True, preserve_range=True).astype('uint8')
+ self.style_image = transform.resize(style_image, tf.shape(style_image), anti_aliasing=True)
self.style_image = tf.expand_dims(self.style_image, axis=0)
#self.x = tf.Variable(initial_value = self.content_image.numpy().astype(np.float32), trainable=True)
self.x = tf.Variable(initial_value = np.random.rand(self.content_image.shape[0],
- self.content_image.shape[1], self.content_image.shape[2], self.content_image.shape[3]).astype('uint8'), trainable=True)
+ self.content_image.shape[1], self.content_image.shape[2], self.content_image.shape[3]).astype(np.float32), trainable=True)
self.alpha = hp.alpha
self.beta = hp.beta
@@ -117,7 +117,7 @@ class YourModel(tf.keras.Model):
return (self.alpha * content_l) + (self.beta * style_l)
def content_loss(self, photo_layers, input_layers):
- L_content = tf.constant(0.0).astype('uint8')
+ L_content = tf.constant(0.0)
for i in range(len(photo_layers)):
pl = photo_layers[i]
il = input_layers[i]