Learn practical skills, build real-world projects, and advance your career
Updated 4 years ago
# Import libraries
from imutils.video import VideoStream
import os
import numpy as np
import imutils
import cv2
import tensorflow.keras
from PIL import Image, ImageOps
import numpy as np
import jovian
import keras
import matplotlib.pyplot as plt
import time
Using TensorFlow backend.
Note:
- You can download Face Mask dataset from here https://github.com/prajnasb/face_detector/tree/master/dataset
Traing Keras Model
from keras.preprocessing.image import ImageDataGenerator
Using TensorFlow backend.
image_gen = ImageDataGenerator(rotation_range=30, # rotate the image 30 degrees
width_shift_range=0.1, # Shift the pic width by a max of 10%
height_shift_range=0.1, # Shift the pic height by a max of 10%
rescale=1/255, # Rescale the image by normalzing it.
shear_range=0.2, # Shear means cutting away part of the image (max 20%)
zoom_range=0.2, # Zoom in by 20% max
horizontal_flip=True, # Allo horizontal flipping
fill_mode='nearest' # Fill in missing pixels with the nearest filled value
)