Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
bethanystate authored Jul 15, 2020
1 parent da1af4e commit 80f51f6
Show file tree
Hide file tree
Showing 5 changed files with 354 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Implementation/Discriminator_Images.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import matplotlib.pyplot as plt
import os
import glob

INPUT_DIR = "Results/Discriminator"


def main():
folders = ["Input", "PixelGAN", "PatchGAN1", "PatchGAN2", "PatchGAN3"]

plt.figure(figsize=(20, 15))
type = 0
fsize = 35
for file in folders:
test_images = sorted(glob.glob(os.path.join(INPUT_DIR, file, '*.jpg')))
type += 1
counter = 0
for img_path in test_images[0:5]:
img = plt.imread(img_path)
idx = 5 * counter + type
plt.subplot(5, 5, idx)
plt.imshow(img)
if idx == 1:
plt.title("Input", fontsize=fsize)
elif idx == 2:
plt.title("1x1", fontsize=fsize)
elif idx == 3:
plt.title("16x16", fontsize=fsize)
elif idx == 4:
plt.title("70x70", fontsize=fsize)
elif idx == 5:
plt.title("256x256", fontsize=fsize)
plt.axis('off')
counter += 1
# plt.savefig(fname="Artistic_Style3.png", bbox_inches='tight')
plt.show()
print('Saved Images')


if __name__ == '__main__':
main()
102 changes: 102 additions & 0 deletions Implementation/Literature Comparison.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import matplotlib.pyplot as plt
import tensorflow as tf

INPUT_DIR = "Results/Literature Comparison/"


def preprocess_image(image_path):
image = plt.imread(image_path)

# resize to 286x286
Ht = tf.shape(image)[0]
Wt = tf.cast(tf.math.multiply(1.5, tf.cast(Ht, tf.float16)), tf.int32)
image = tf.image.resize(image, [Ht, Wt], method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)

return image


def main():

plt.figure(figsize=(45, 15))
fsize =45
img_path = INPUT_DIR

# Chicago
img = preprocess_image(img_path + "chicago.jpg")
plt.subplot(2, 5, 1)
plt.imshow(img)
plt.title("Input", fontsize=fsize)
plt.axis('off')

# Style Image
img = preprocess_image(img_path + "Starry_night.jpg")
plt.subplot(2, 5, 2)
plt.imshow(img)
plt.title("Starry Night", fontsize=fsize)
plt.axis('off')


# Gatys Starry
img = preprocess_image(img_path + "Gatys_Starry.jpg")
plt.subplot(2, 5, 3)
plt.imshow(img)
plt.title("Gatys et al.", fontsize=fsize)
plt.axis('off')


# Justin Starry
img = preprocess_image(img_path + "Justin_Starry.jpg")
plt.subplot(2, 5, 4)
plt.imshow(img)
plt.title("Johnson et al.", fontsize=fsize)
plt.axis('off')

# CycleGAN Starry
img = preprocess_image(img_path + "CycleGAN_Starry.jpg")
plt.subplot(2, 5, 5)
plt.imshow(img)
plt.title("CycleGAN", fontsize=fsize)
plt.axis('off')

# Chicago
img = preprocess_image(img_path + "chicago.jpg")
plt.subplot(2, 5, 6)
plt.imshow(img)
plt.title("Input", fontsize=fsize)
plt.axis('off')

# Style Image
img = preprocess_image(img_path + "Wave.jpg")
plt.subplot(2, 5, 7)
plt.imshow(img)
plt.title("Gatys et al.", fontsize=fsize)
plt.axis('off')

# Gatys Starry
img = preprocess_image(img_path + "Gatys_Wave.jpg")
plt.subplot(2, 5, 8)
plt.imshow(img)
plt.title("Gatys et al.", fontsize=fsize)
plt.axis('off')

# Justin Starry
img = preprocess_image(img_path + "Justin_Wave.jpg")
plt.subplot(2, 5, 9)
plt.imshow(img)
plt.title("Johnson et al.", fontsize=fsize)
plt.axis('off')

# CycleGAN Starry
img = preprocess_image(img_path + "CycleGAN_Wave.jpg")
plt.subplot(2, 5, 10)
plt.imshow(img)
plt.title("CycleGAN", fontsize=fsize)
plt.axis('off')

# plt.savefig(fname="Artistic_Style3.png", bbox_inches='tight')
plt.show()
print('Saved Images')


if __name__ == '__main__':
main()
41 changes: 41 additions & 0 deletions Implementation/generate_figures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import matplotlib.pyplot as plt
import os
import glob

OUTPUT_DIR = "Results/"
INPUT_DIR = "Results/"

def main():
folders = ["Input", "MonetPaintings", "CezannePaintings", "Ukiyo_ePaintings", "VanGoghPaintings"]

plt.figure(figsize=(20, 31))
type = 0
fsize = 40
for file in folders:
test_images = sorted(glob.glob(os.path.join(INPUT_DIR, file, '*.jpg')))
type += 1
counter = 0
for img_path in test_images[20:30]:
img = plt.imread(img_path)
idx = 5*counter + type
plt.subplot(10, 5, idx)
plt.imshow(img)
if idx == 1:
plt.title("Input", fontsize=fsize)
elif idx == 2:
plt.title("Monet", fontsize=fsize)
elif idx == 3:
plt.title("Cezanne", fontsize=fsize)
elif idx == 4:
plt.title("Ukiyo-e", fontsize=fsize)
elif idx == 5:
plt.title("Van Gogh", fontsize=fsize)
plt.axis('off')
counter += 1
plt.savefig(fname="Artistic_Style3.png", bbox_inches='tight')
plt.show()
print('Saved Images')


if __name__ == '__main__':
main()
71 changes: 71 additions & 0 deletions Implementation/generate_real_pictures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import matplotlib.pyplot as plt
import os
import glob

INPUT_DIR = "Results/"

def main():
folders = ["MonetToLandscapeInput", "MonetToLandscape"]

# plt.figure(figsize=(13, 25))
# type = 0
# fsize = 30
# for file in folders:
# test_images = sorted(glob.glob(os.path.join(INPUT_DIR, file, '*.jpg')))
# type += 1
# counter = 0
# for img_path in test_images[:6]:
# img = plt.imread(img_path)
# idx = 2 * counter + type
# plt.subplot(6, 2, idx)
# plt.imshow(img)
# if idx == 1:
# plt.title("Input", fontsize=fsize)
# elif idx == 2:
# plt.title("Output", fontsize=fsize)
# plt.axis('off')
# counter += 1
#
# plt.savefig(fname="MonetToLandscape1.png", bbox_inches='tight')
# plt.show()
# print('Saved Images 1')
#
# plt.figure(figsize=(13, 25))
# type = 0
# for file in folders:
# test_images = sorted(glob.glob(os.path.join(INPUT_DIR, file, '*.jpg')))
# type += 1
# counter = 0
# for img_path in test_images[6:12]:
# img = plt.imread(img_path)
# idx = 2 * counter + type
# plt.subplot(6, 2, idx)
# plt.imshow(img)
# if idx == 1:
# plt.title("Input", fontsize=fsize)
# elif idx == 2:
# plt.title("Output", fontsize=fsize)
# plt.axis('off')
# counter += 1
#
# plt.savefig(fname="MonetToLandscape2.png", bbox_inches='tight')
# plt.show()
# print('Saved Images 2')

plt.figure(figsize=(27, 25))
counter = 0
folders = ["MonetToLandscape1.png", "MonetToLandscape2.png"]
for img_path in folders:
img = plt.imread(img_path)
counter += 1
plt.subplot(1, 2, counter)
plt.imshow(img)
plt.axis('off')

plt.savefig(fname="MonetToLandscape.png", bbox_inches='tight')
plt.show()
print('Saved Images')


if __name__ == '__main__':
main()
99 changes: 99 additions & 0 deletions Implementation/loss_function_images.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import matplotlib.pyplot as plt
import tensorflow as tf

INPUT_DIR = "Results/Literature Comparison/"


def preprocess_image(image_path):
image = plt.imread(image_path)

# resize to 286x286
Ht = tf.shape(image)[0]
Wt = tf.cast(tf.math.multiply(1.5, tf.cast(Ht, tf.float16)), tf.int32)
image = tf.image.resize(image, [Ht, Wt], method=tf.image.ResizeMethod.NEAREST_NEIGHBOR)

return image


def main():
plt.figure(figsize=(45, 15))
fsize = 45
img_path = INPUT_DIR

# Chicago
img = preprocess_image(img_path + "chicago.jpg")
plt.subplot(2, 5, 1)
plt.imshow(img)
plt.title("Input", fontsize=fsize)
plt.axis('off')

# Style Image
img = preprocess_image(img_path + "Starry_night.jpg")
plt.subplot(2, 5, 2)
plt.imshow(img)
plt.title("Starry Night", fontsize=fsize)
plt.axis('off')

# Gatys Starry
img = preprocess_image(img_path + "Gatys_Starry.jpg")
plt.subplot(2, 5, 3)
plt.imshow(img)
plt.title("Gatys et al.", fontsize=fsize)
plt.axis('off')

# Justin Starry
img = preprocess_image(img_path + "Justin_Starry.jpg")
plt.subplot(2, 5, 4)
plt.imshow(img)
plt.title("Johnson et al.", fontsize=fsize)
plt.axis('off')

# CycleGAN Starry
img = preprocess_image(img_path + "CycleGAN_Starry.jpg")
plt.subplot(2, 5, 5)
plt.imshow(img)
plt.title("CycleGAN", fontsize=fsize)
plt.axis('off')

# Chicago
img = preprocess_image(img_path + "chicago.jpg")
plt.subplot(2, 5, 6)
plt.imshow(img)
plt.title("Input", fontsize=fsize)
plt.axis('off')

# Style Image
img = preprocess_image(img_path + "Wave.jpg")
plt.subplot(2, 5, 7)
plt.imshow(img)
plt.title("Gatys et al.", fontsize=fsize)
plt.axis('off')

# Gatys Starry
img = preprocess_image(img_path + "Gatys_Wave.jpg")
plt.subplot(2, 5, 8)
plt.imshow(img)
plt.title("Gatys et al.", fontsize=fsize)
plt.axis('off')

# Justin Starry
img = preprocess_image(img_path + "Justin_Wave.jpg")
plt.subplot(2, 5, 9)
plt.imshow(img)
plt.title("Johnson et al.", fontsize=fsize)
plt.axis('off')

# CycleGAN Starry
img = preprocess_image(img_path + "CycleGAN_Wave.jpg")
plt.subplot(2, 5, 10)
plt.imshow(img)
plt.title("CycleGAN", fontsize=fsize)
plt.axis('off')

# plt.savefig(fname="Artistic_Style3.png", bbox_inches='tight')
plt.show()
print('Saved Images')


if __name__ == '__main__':
main()

0 comments on commit 80f51f6

Please sign in to comment.