Logo elodees  elodees

Une IA bien-veillante pour un monde meilleur













Seuls les caractères alphabétiques accentués ou non ainsi que l'espace sont acceptés

Logo IA




Couche d'augmentation d'image





Pas encore de compte ?

Inscrivez-vous pour accéder à tous les contenus




Image gratuite et libre de droits fournie par pexel.com


Retournement d'image



Image gratuite et libre de droits fournie par pexel.com
Image gratuite et libre de droits fournie par pexel.com


Rotation d'image aléatoire



Image gratuite et libre de droits fournie par pexel.com
Image gratuite et libre de droits fournie par pexel.com


Zoom d'image aléatoire



Image gratuite et libre de droits fournie par pexel.com
Image gratuite et libre de droits fournie par pexel.com
Image gratuite et libre de droits fournie par pexel.com
Image gratuite et libre de droits fournie par pexel.com


Décalage aléatoire de la hauteur et de la largeur



Image gratuite et libre de droits fournie par pexel.com
Image gratuite et libre de droits fournie par pexel.com
Image gratuite et libre de droits fournie par pexel.com
Image gratuite et libre de droits fournie par pexel.com
Image gratuite et libre de droits fournie par pexel.com
Image gratuite et libre de droits fournie par pexel.com


Inclinaison et perspective (cisaillement)



Image gratuite et libre de droits fournie par pexel.com
Image gratuite et libre de droits fournie par pexel.com
Image gratuite et libre de droits fournie par pexel.com
Image gratuite et libre de droits fournie par pexel.com


Transformations d'éclairage



Image gratuite et libre de droits fournie par pexel.com
Image gratuite et libre de droits fournie par pexel.com
Image gratuite et libre de droits fournie par pexel.com
Image gratuite et libre de droits fournie par pexel.com


Testé sous Anaconda et Python 3.7

#importing libraries
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from matplotlib import pyplot
import numpy as np
import tensorflow as tf
 
# downloading and saving the image
import requests
DownURL = "https://images.pexels.com/photos/1056251/pexels-photo-1056251.jpeg?crop=entropy&cs=srgb&dl=pexels-ihsan-aditya-1056251.jpg&fit=crop&fm=jpg&h=426&w=640"
img_data = requests.get(DownURL).content
with open('/tmp/impath/cat/cat-small.jpg', 'wb') as handler:
    handler.write(img_data)
 
# setting up data pipeline to read image from disk
image_augmentor = ImageDataGenerator()
data = image_augmentor.flow_from_directory(
    "/tmp/impath",
    target_size=(213, 320),
    batch_size=1,
)
 
# plotting an original image
pyplot.imshow(data.next()[0][0].astype('int'))
pyplot.title("Without Augmentation")
 
# set up horizontal flip
image_augmentor = ImageDataGenerator(horizontal_flip=True)
data = image_augmentor.flow_from_directory(
    "/tmp/impath",
    target_size=(213, 320),
    batch_size=1,
)
pyplot.imshow(data.next()[0][0].astype('int'))
pyplot.title("Augmentation: Horizontal flip")
 
# set up vertical flip
image_augmentor = ImageDataGenerator(vertical_flip=True)
data = image_augmentor.flow_from_directory(
    "/tmp/impath",
    target_size=(213, 320),
    batch_size=1,
)
pyplot.imshow(data.next()[0][0].astype('int'))
pyplot.title("Augmentation: Vertical flip")
 
# random rotation
image_augmentor = ImageDataGenerator(rotation_range=45)
data = image_augmentor.flow_from_directory(
    "/tmp/impath",
    target_size=(213, 320),
    batch_size=1,
)
pyplot.imshow(data.next()[0][0].astype('int'))
pyplot.title("Augmentation: Random rotation")
 
# random zoom
# zooms an image to between 80% to 125%
image_augmentor = ImageDataGenerator(zoom_range=[0.8, 1.25])
data = image_augmentor.flow_from_directory(
    "/tmp/impath",
    target_size=(213, 320),
    batch_size=1,
)
pyplot.imshow(data.next()[0][0].astype('int'))
pyplot.title("Augmentation: Random zoom")
 
#Random Height Shift
image_augmentor = ImageDataGenerator(height_shift_range=0.30)
data = image_augmentor.flow_from_directory(
    "/tmp/impath",
    target_size=(213, 320),
    batch_size=1,
)
pyplot.imshow(data.next()[0][0].astype('int'))
pyplot.title("Augmentation: Height shift")
 
#Random Width Shift
image_augmentor = ImageDataGenerator(width_shift_range=0.30)
data = image_augmentor.flow_from_directory(
    "/tmp/impath",
    target_size=(213, 320),
    batch_size=1,
)
pyplot.imshow(data.next()[0][0].astype('int'))
pyplot.title("Augmentation: Width shift")
 
#Random Height & Width Shift
image_augmentor = ImageDataGenerator(width_shift_range=0.30, height_shift_range=0.30)
data = image_augmentor.flow_from_directory(
    "/tmp/impath",
    target_size=(213, 320),
    batch_size=1,
)
pyplot.imshow(data.next()[0][0].astype('int'))
pyplot.title("Augmentation: Height & width shift")
 
#Tilt and Perspective (Shear)
image_augmentor = ImageDataGenerator(shear_range=45)
data = image_augmentor.flow_from_directory(
    "/tmp/impath",
    target_size=(213, 320),
    batch_size=1,
)
pyplot.imshow(data.next()[0][0].astype('int'))
pyplot.title("Augmentation: Tilt & perspective")
 
#Lighting Transformations
image_augmentor = ImageDataGenerator(brightness_range=(0.3, 1))
data = image_augmentor.flow_from_directory(
    "/tmp/impath",
    target_size=(213, 320),
    batch_size=1,
)
pyplot.imshow(data.next()[0][0].astype('int'))
pyplot.title("Augmentation: Brightness")
 


Source : https://datamonje.com/image-data-augmentation/





Couches des réseaux neuronaux


Apprentissage automatique

Apprentissage profond














Bienvenu, je m’appelle Eric Soupet et je suis l'administrateur du site elodees.com. elodees.com est un état de l'art de l'Intelligence Artificielle et se veut collaboratif, vous pouvez dès à présent proposer du contenu tels que des articles, des événements, des tutoriels, ... alors n'hésitez pas !

Crédit des images de la plate-forme : Pixabay - Pixabay License | Pexels - Pexels License