diff --git a/Implementation/Discriminator_Images.py b/Implementation/Discriminator_Images.py new file mode 100644 index 0000000..7f7bd48 --- /dev/null +++ b/Implementation/Discriminator_Images.py @@ -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() diff --git a/Implementation/Literature Comparison.py b/Implementation/Literature Comparison.py new file mode 100644 index 0000000..65bd446 --- /dev/null +++ b/Implementation/Literature Comparison.py @@ -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() diff --git a/Implementation/generate_figures.py b/Implementation/generate_figures.py new file mode 100644 index 0000000..156aba6 --- /dev/null +++ b/Implementation/generate_figures.py @@ -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() diff --git a/Implementation/generate_real_pictures.py b/Implementation/generate_real_pictures.py new file mode 100644 index 0000000..3d3799c --- /dev/null +++ b/Implementation/generate_real_pictures.py @@ -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() diff --git a/Implementation/loss_function_images.py b/Implementation/loss_function_images.py new file mode 100644 index 0000000..96e3f4e --- /dev/null +++ b/Implementation/loss_function_images.py @@ -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()