<jupyter_start><jupyter_text>**0. Import Dependencies and Pretrained Model**<jupyter_code>import tensorflow_hub as hub
import tensorflow as tf
from matplotlib import pyplot as plt
import numpy as np
import cv2
model = hub.load('https://tfhub.dev/google/magenta/arbitrary-image-stylization-v1-256/2')<jupyter_output><empty_output><jupyter_text>**1. Preprocess Image and Load**<jupyter_code>from google.colab import drive
drive.mount('/content/gdrive')
def load_image(img_path):
 
    img = tf.io.read_file(img_path)
    img = tf.image.decode_image(img, channels=3)
    img = tf.image.convert_image_dtype(img, tf.float32)
    img = img[tf.newaxis, :]
    return img
content_image = load_image('/idrees.jpg')
style_image = load_image('/monalisa.jpg')<jupyter_output><empty_output><jupyter_text>**2. Visualize Output**<jupyter_code>content_image.shape
plt.imshow(np.squeeze(style_image))
plt.show()<jupyter_output><empty_output><jupyter_text>**3. Stylize Image**<jupyter_code>stylized_image = model(tf.constant(content_image), tf.constant(style_image))[0]
plt.imshow(np.squeeze(stylized_image))
plt.show()
cv2.imwrite('generated_img.jpg', cv2.cvtColor(np.squeeze(stylized_image)*255, cv2.COLOR_BGR2RGB))<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup