Code Monkey home page Code Monkey logo

face-mask-detector's Introduction


Detection of face mask in real time thought for safety against COVID-19.

Demo

Development

Training

Build the Convolutional Network consists on two pairs of Conv and MaxPool layers to extract features from Dataset.
Followed by a Flatten and Dropout layers to convert the data in 1D and ensure overfitting.
Two Dense layer for classification.

model = Sequential([
    Conv2D(100, (3, 3), activation = 'relu', input_shape = (150, 150, 3)),
    MaxPooling2D(2, 2),
    
    Conv2D(100, (3, 3), activation = 'relu'),
    MaxPooling2D(2, 2),
    
    Flatten(),
    Dropout(0.5),
    Dense(50, activation = 'relu'),
    Dense(2, activation = 'softmax')
])
model.compile(optimizer = 'adam', loss = 'binary_crossentropy', metrics = ['acc'])


Training the model and save it after each epoch.

checkpoint = ModelCheckpoint('model-{epoch:03d}.h5', monitor='val_loss', verbose = 0, save_best_only = True, mode = 'auto')
history = model.fit_generator(train_generator,
                              epochs = 30,
                              validation_data = validation_generator,
                              callbacks = [checkpoint])

Testing

Load the xml file

classifier = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')


Resize the image to speed up detection

mini = cv2.resize(im, (im.shape[1] // size, im.shape[0] // size))


Detect faces

faces = classifier.detectMultiScale(mini)

face-mask-detector's People

Contributors

chiara2804 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.