deep learning: the third wave the neural networks

22
Redes convolucionales para procesamiento de imágenes Mariano Rivera Meraz Alan G. Reyes Figueroa M. Rivera – A. G. Reyes, PI 2018 Taller Keras

Upload: others

Post on 04-Jul-2022

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Deep Learning: The Third Wave the Neural Networks

Redes convolucionales para procesamiento de imágenes

Mariano Rivera Meraz Alan G. Reyes Figueroa

M. Rivera – A. G. Reyes, PI 2018

Taller Keras

Page 2: Deep Learning: The Third Wave the Neural Networks

Convolución

Procesamiento de imágenes

•El procesamiento espacial consiste de estimar el valor de un píxel en función de sus vecinos.

• La idea: mover una máscara: un rectángulo (con lados de tamaño impar) u otra forma. Los valores de los píxeles se calculan usando los valores de los píxeles en la máscara.

• La combinación de una máscara y una función se llama un filtro.

Page 3: Deep Learning: The Third Wave the Neural Networks

Convolución

Page 4: Deep Learning: The Third Wave the Neural Networks

Convolución •A la máscara se

asignan pesos 𝑚𝑖𝑗 = 𝑚(𝑖, 𝑗).

• Los píxeles de la imagens tienen valores 𝑝𝑘𝑙 = 𝑝(𝑘, 𝑙).

•El nuevo valor 𝑝𝑖𝑗 se calcula como una función de los 𝑚𝑘𝑙 y los 𝑝𝑘𝑙.

Page 5: Deep Learning: The Third Wave the Neural Networks

Filtros y convolución

(correlación)

Page 6: Deep Learning: The Third Wave the Neural Networks

Filtros y convolución

Page 7: Deep Learning: The Third Wave the Neural Networks

Filtros y convolución

Page 8: Deep Learning: The Third Wave the Neural Networks

Ejemplos

1 1 1

1 1 1

1 1 1

𝐻 =1

9 Filtro de medias.

Imagen original

Imagen filtrada

19 1

9 19

19 1

9 19

19 1

9 19

=

Page 9: Deep Learning: The Third Wave the Neural Networks

Ejemplos

𝐻 =1

𝑘2 Filtro de medias.

1 1 … 1

1 1 … 1

… … …

1 1 … 1 𝑘 × 𝑘

Imagen original

Imagen filtrada (25 x 25)

Page 10: Deep Learning: The Third Wave the Neural Networks

Ejemplos

1 0 -1

1 0 -1

1 0 -1

𝐻𝑥 =

Filtros de gradiente.

1 1 1

0 0 0

-1 -1 -1

𝐻𝑦 =

Imagen original

Imagen filtrada 𝐻𝑥

Imagen filtrada 𝐻𝑦

Page 11: Deep Learning: The Third Wave the Neural Networks

Ejemplos

0 -1 0

-1 8 -1

0 -1 0

𝐻𝑥 =1

4 Filtro de sharpening.

Imagen original

Imagen filtrada

Page 12: Deep Learning: The Third Wave the Neural Networks

Imagen original

Imagen filtrada

0 -1 0

-1 4 -1

0 -1 0

𝐻 = Filtro laplaciano.

(detección de bordes)

Ejemplos

Page 13: Deep Learning: The Third Wave the Neural Networks

Padding

Page 14: Deep Learning: The Third Wave the Neural Networks

Padding

En Keras, hay dos valores para el parámetro padding: 𝐻 filtro de tamaño (2𝑘 + 1) × (2𝑘 + 1).

𝐼 imagen de tamaño 𝑚 × 𝑛.

• padding = ‘valid’. Sólo recorre el filtro en las posiciones válidas, donde no se sale del dominio de la imagen. La imagen de salida es más reducida 𝒎− 𝟐𝒌 × (𝒏 − 𝟐𝒌).

•padding = ‘same’. Crea una región que extiende la imagen, para recorrer la máscara sobre todos los píxeles. La imagen de salida es del mismo tamaño 𝒎× 𝒏.

Page 15: Deep Learning: The Third Wave the Neural Networks

Padding

padding = ‘same’

padding = ‘valid’

Page 16: Deep Learning: The Third Wave the Neural Networks

Stride

Tamaño de salto en la convolución. En Keras, el default es (1,1).

Page 17: Deep Learning: The Third Wave the Neural Networks

Pooling (sub-muestreo)

Las capas de Pooling, hacen un muestreo sistemático de los píxeles en la imagen.

En Keras, usa el parámetro Pool_size = 2,2 .

La imagen de salida se reduce en un factor de Pool_size.

También parámetro stride. En Keras, stride = pool_size.

Page 18: Deep Learning: The Third Wave the Neural Networks

Redes neuronales convolucionales

•Neurona = filtro.

•Pesos = pesos de

cada filtro.

Page 19: Deep Learning: The Third Wave the Neural Networks

Redes neuronales convolucionales

Una red convolucional integra dos partes

•Capas convolucionales + Capas Pooling: extractor de rasgos.

•Capas densas: clasificador.

Page 20: Deep Learning: The Third Wave the Neural Networks

Redes neuronales convolucionales

Page 21: Deep Learning: The Third Wave the Neural Networks

Aplicaciones:

Object Detection

Segmentation

Filtering

Super-resolution

Style transfer

Todas usan redes convolucionales !

Page 22: Deep Learning: The Third Wave the Neural Networks

Objetivo de hoy

Base de datos MNIST: 70,000 imágenes (de tamaño 28 x 28). (de ellos, 60,000 son de entrenamiento y 10,000 son de prueba).

Vamos a implementar una red convolucional que aprendan a clasificar los dígitos de MNIST.