Winter 2020 CSC 594 Topics in AI: Advanced Deep Learning

Winter 2020

CSC 594 Topics in AI: Advanced Deep Learning

3. Deep Learning for Computer Vision (1)

(Some figures adapted from Chollet DL book)

Noriko Tomuro

1

More Topics on Deep Learning for Computer Vision

1. Review of basic CNN 2. Load your own data 3. Data Augmentation 4. Transfer learning

? Pre-trained models ? Fine-tuning

5. Visualization of learned filters and feature maps

Noriko Tomuro

2

1 Review of basic CNN

? Convolutional Neural Networks (CNNs) are a variation of a multilayer neural network, typically used for recognizing/classifying 2D images.

? A CNN consists of an input and an output layer, as well as multiple hidden layers. The hidden layers of a CNN typically consist of convolutional layers, pooling layers, and fully connected layers.

Noriko Tomuro

3

? CNN applies a convolution operation through a kernel/filter.

? Pooling operation is to downsample (i.e., reduce) the image (feature map) size.

Noriko Tomuro

4

? Each filter extracts features from the image. ? Filters closer to the input layer learn low-level features such as lines,

while filters in the middle of the model learn complex abstract features that combine the lower level features.

? CNN learning is to learn the (values in the) filters.

Noriko Tomuro

5

from tensorflow.keras import datasets, layers, models

model = models.Sequential() model.add(layers.Conv2D(32, (3, 3), activation='relu',

input_shape=(32, 32, 3))) model.add(layers.MaxPooling2D((2, 2))) model.add(layers.Conv2D(64, (3, 3), activation='relu')) model.add(layers.MaxPooling2D((2, 2))) model.add(layers.Conv2D(64, (3, 3), activation='relu'))

model.add(layers.Flatten()) model.add(layers.Dense(64, activation='relu')) model.add(layers.Dense(10, activation='softmax'))

pile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])

history = model.fit(train_images, train_labels, epochs=10, validation_data=(test_images, test_labels))

Noriko Tomuro

6

Deep Networks for Computer Vision

Noriko Tomuro

7

2 Load your own image data

? If you want to work with your own image datasets rather than those builtin Keras such as MNIST and CIFAR-10 or on Kaggle, you have to look up how to do.

? Here is an example when (color) images are on your local machine, under two subfolders corresponding to the categories (dog/cat). Also OpenCV (cv2) and Numpy are used for image processing.

import numpy as np import matplotlib.pyplot as plt import os import cv2

DATADIR = "../data/animals1000" # image data folder CATEGORIES = ["dog", "cat"] # dogs/cats in separate subfolders

IMG_SIZE = 100 # resize all images to this size

training_data = [] # training data to be created

Noriko Tomuro

8

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download