<jupyter_start><jupyter_text>"Mashing" two images by generating images from weighted z vectors<jupyter_code>from src.data_handling import CIFAR10_data
from src.encoder import VAE
from src.net import build_cifar10_vae as net
import matplotlib.pyplot as plt
import numpy as np

data = CIFAR10_data()
data.load_data('data/cifar10/', keep_classes=[3,5]) # Only the dogs and cats part of the data
autoencoder = AE(net)
autoencoder.restore_model_from_last_checkpoint('./saved_models/vanila_cifar10_dogs_cats/model')
imgs = data.X
def plot_z_steps(autoencoder, img1, img2):
    z1 = autoencoder.get_z(img1)
    z2 = autoencoder.get_z(img2)
    f = plt.figure(figsize=(10,3))
    plt.subplot(1,9,1)
    plt.imshow(img1.reshape((32,32,3)))
    plt.axis('off')
    for i, alpha in enumerate([0.1,0.25,0.4,0.6,0.75,0.8,1.0]):    
        z3 = z1 * (1-alpha) + z2 * alpha 
        mashed = autoencoder.get_img_from_z(z3)
        plt.subplot(1,9,i+2)
        plt.imshow(np.clip(mashed.reshape((32,32,3)), 0, 1))
        plt.axis('off')
    plt.subplot(1,9,9)
    plt.imshow(img2.reshape((32,32,3)))
    plt.axis('off')
    plt.show()<jupyter_output><empty_output><jupyter_text>Some hand picked samples<jupyter_code>plot_z_steps(autoencoder, imgs[4796], imgs[8259])
plot_z_steps(autoencoder, imgs[7646], imgs[6526])<jupyter_output><empty_output><jupyter_text>Some randomally selected samples<jupyter_code>idx1, idx2 = np.random.randint(len(data.X), size=2)
plot_z_steps(autoencoder, imgs[idx1], imgs[idx2])
idx1, idx2 = np.random.randint(len(data.X), size=2)
plot_z_steps(autoencoder, imgs[idx1], imgs[idx2])
idx1, idx2 = np.random.randint(len(data.X), size=2)
plot_z_steps(autoencoder, imgs[idx1], imgs[idx2])
idx1, idx2 = np.random.randint(len(data.X), size=2)
plot_z_steps(autoencoder, imgs[idx1], imgs[idx2])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14989059080962802, 'fraction_numerical': 0.05798687089715536, 'mean_word_length': 5.579136690647482, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '403448', 'license': 'MIT', 'n_tokens_mistral': 787, 'n_tokens_neox': 753, 'n_words': 121, 'path': 'cifar10_examples.ipynb', 'repo_name': 'nirmorgo/deep-photo-masher', 'size': '1828'}