Skip to content

Instantly share code, notes, and snippets.

View ogyalcin's full-sized avatar

Orhan Yalcin ogyalcin

View GitHub Profile
import matplotlib.pyplot as plt
plt.figure(figsize=(12, 12))
plt.subplot(1, 2, 1)
plt.imshow(content_image[0])
plt.title('Content Image')
plt.subplot(1, 2, 2)
plt.imshow(style_image[0])
plt.title('Style Image')
content_image = load_img(content_path)
style_image = load_img(style_path)
def load_img(path_to_img):
# Reads and outputs the entire contents of the input filename.
img = tf.io.read_file(path_to_img)
# Detect whether an image is a BMP, GIF, JPEG, or PNG, and
# performs the appropriate operation to convert the input
# bytes string into a Tensor of type dtype
img = tf.image.decode_image(img, channels=3)
# Convert image to dtype, scaling (MinMax Normalization) its values if needed.
img = tf.image.convert_image_dtype(img, tf.float32)
# Scale the image using the custom function we created
def img_scaler(image, max_dim = 256):
# Casts a tensor to a new type.
original_shape = tf.cast(tf.shape(image)[:-1], tf.float32)
# Creates a scale constant for the image
scale_ratio = 4 * max_dim / max(original_shape)
# Casts a tensor to a new type.
new_shape = tf.cast(original_shape * scale_ratio, tf.int32)
# Resizes the image based on the scaling constant generated above
return tf.image.resize(image, new_shape)
import tensorflow as tf
content_path = tf.keras.utils.get_file('photo-1563306406-e66174fa3787',
'https://images.unsplash.com/photo-1563306406-e66174fa3787')
style_path = tf.keras.utils.get_file('Andy-Warhol--Marilyn-Monroe-Hot-Pink-1967-Andy-Warhol-Poster.jpg',
'https://product-image.juniqe-production.juniqe.com/media/catalog/product/seo-cache/x800/7/7/776-8-101P-13x18-1/Andy-Warhol--Marilyn-Monroe-Hot-Pink-1967-Andy-Warhol-Poster.jpg')
Name Main Approach
Feedforward Neural Network Supervised Learning
Convolutional Neural Network Supervised Learning
Recurrent Neural Network Supervised Learning
Transformer Networks Supervised Learning
Autoencoders Unsupervised Learning
Generative Adversarial Networks Unsupervised Learning
Deep Recommender Systems Unsupervised Learning
Self Organizing Maps (SOMs) Unsupervised Learning
Deep Belief Networks Supervised and Unsupervised Learning
!apt-get install --no-install-recommends openmpi-bin libopenmpi-dev libopencv-dev python3-opencv python-opencv
!ln -sf /usr/lib/x86_64-linux-gnu/libmpi_cxx.so /usr/lib/x86_64-linux-gnu/libmpi_cxx.so.1
!ln -sf /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so.12
!ln -sf /usr/lib/x86_64-linux-gnu/libmpi.so /usr/lib/x86_64-linux-gnu/libmpi.so.12
!pip install cntk
import cntk as C
!pip install mxnet
import mxnet as mx
!pip install torch torchvision
import torch
!pip install Keras
import keras