Face Mask Detection with Tensorflow(Flutter)Face Mask Detection with Tensorflow(Flutter)

Overview

Face Mask Detection with Tensorflow(Flutter)

Face Mask Detection With TFlite

Info

An app made with flutter and tensor flow lite for face mask detection.

⭐ Features

  • Delect mask on the live camera

  • Detect mask from a photo

  • MVVM architecture


πŸš€   Installation

  1. Install Packages
camera: get the streaming image buffers
https://pub.dev/packages/camera
tflite: run our trained model
https://pub.dev/packages/tflite
image_picker: pick image from gallery
https://pub.dev/packages/image_picker

2. Configure Project
  • Android
android/app/build.gradle

android {
    ...
    aaptOptions {
        noCompress 'tflite'
        noCompress 'lite'
    }
    ...
}


minSdkVersion 21

3. Train our model
* Download the dataset for training
    https://www.kaggle.com/prasoonkottarathil/face-mask-lite-dataset

* Training
    - go to https://teachablemachine.withgoogle.com to train our model
    - Get Started
    - Image Project
    - Edit `Class 1` for any Label(example `WithMask`)
    - Edit `Class 2` for any Label(example `WithoutMask`)
    - Update image from dataset download above
    - Click `Train Model`(using default config) and waiting...
    - Click `Export Model` and select `Tensorflow Lite`
    - Download (include: *.tflite, labels.txt)

4. Load model
loadModel() async {
    Tflite.close();
    await Tflite.loadModel(
        model: "assets/model.tflite", 
        labels: "assets/labels.txt",
        //numThreads: 1, // defaults to 1
        //isAsset: true, // defaults: true, set to false to load resources outside assets
        //useGpuDelegate: false // defaults: false, use GPU delegate
    );
  }

5. Run model
  Future<List<dynamic>?> runModelOnFrame(CameraImage image) async {
    var recognitions = await Tflite.runModelOnFrame(
        bytesList: image.planes.map((plane) {
          return plane.bytes;
        }).toList(),
        imageHeight: image.height,
        imageWidth: image.width,
        imageMean: 127.5,   //defaults to 127.5
        imageStd: 127.5,    //defaults to 127.5
        rotation: 90,       // defaults to 90, Android only
        numResults: 2,      // defaults to 5
        threshold: 0.5,     // defaults to 0.1
        asynch: true,       // defaults to true
    );      
    return recognitions;
  }
  Future<List<dynamic>?> runModelOnImage(File image) async {
    var recognitions = await Tflite.runModelOnImage(
      path: image.path,
      numResults: 2,
      threshold: 0.5,
      imageMean: 127.5,
      imageStd: 127.5,
    );
    return recognitions;
  }
Output format:
  [{
    index: 0,
    label: "WithMask",
    confidence: 0.989
  },...]

6. Issue
* IOS
1.'vector' file not found
Open ios/Runner.xcworkspace in Xcode, click Runner > Tagets > Runner >Build Settings, 
search Compile Sources As, change the value to Objective-C++

2. 'tensorflow/lite/kernels/register.h' file not found
The plugin assumes the tensorflow header files are located in path "tensorflow/lite/kernels".
However, for early versions of tensorflow the header path is "tensorflow/contrib/lite/kernels".

7. Source code
please checkout repo github
https://github.com/hiennguyen92/face_mask_detection_tflite

πŸ’‘ Demo

  1. Demo Illustration: https://www.youtube.com/watch?v=2er_XZb_oi4&ab_channel=HienNguyen
  2. Image
You might also like...

Flutter plugin that secures your secrets in keychain using biometric authentication (Fingerprint, Touch ID, Face ID...).

Flutter plugin that secures your secrets in keychain using biometric authentication (Fingerprint, Touch ID, Face ID...).

Flutter Locker πŸ”’ Flutter plugin that secures your secrets in keychain using biometric authentication (Fingerprint, Touch ID, Face ID...). It uses: Lo

Nov 21, 2022

A Flutter clock face with moving bars

A Flutter clock face with moving bars

BarBar Clock | Web demo πŸ† Listed in Honorable Mentions at flutter.dev/clock πŸ† Clock face for the Flutter Clock Challenge. This clock face shows time

Jun 29, 2022

This is my entry for the Flutter Clock Face Contest.

This is my entry for the Flutter Clock Face Contest.

Star Clock This is my entry for the Flutter Clock Face Contest. Build instructions below. TLRD: Clone with --recurse-submodules Here's a small demo vi

Oct 22, 2022

A simple project demonstrating how to build a face filter app using Flutter and Deep AR

A simple project demonstrating how to build a face filter app using Flutter and Deep AR

flutter_deepar This is a simple project that will help you learn how to build a simple face filter app with Flutter and Deep AR You can read an articl

Jan 1, 2023

SimplyTimeClock - Clock face with a minimalistic interface made with Flutter.

SimplyTimeClock - Clock face with a minimalistic interface made with Flutter.

Simply Time Clock Overview Description Simply Time Clock is a Clockface for the Lenovo Smart Clock using Flutter. Made during the Flutter Clock Challe

Dec 30, 2019

Gradi clock - Gradi Clock face for Flutter Clock challenge

Gradi clock - Gradi Clock face for Flutter Clock challenge

Gradi Clock Clock face made for Flutter Clock challenge. About There is an abundant body of research that suggests that people are sensory creatures w

Sep 29, 2021

Simple alarm app - An alarm with analog clock face and digital indicator in the center for flutter

Simple alarm app - An alarm with analog clock face and digital indicator in the center for flutter

simple_alarm_app A new Flutter project. Getting Started It's an alarm with analo

Mar 14, 2022

Random-Face-Generator - A Cross-Platform(Web, Android, iOS) app to Generate Faces of People (These people don't actually exist) made using Flutter

Random-Face-Generator - A Cross-Platform(Web, Android, iOS) app to Generate Faces of People (These people don't actually exist) made using Flutter

πŸ‘¨ πŸ‘© Flutter Random Face Generator A flutter app to generate random faces. The

Dec 25, 2022

A simple project that will help you learn how to build a simple face filter app with Flutter and Deep AR

A simple project that will help you learn how to build a simple face filter app with Flutter and Deep AR

flutter_deepar This is a simple project that will help you learn how to build a simple face filter app with Flutter and Deep AR You can read an articl

Mar 11, 2022
Owner
Mohsen Mirdar
Mohsen Mirdar
Flutterbodydetection - A flutter plugin that uses MLKit on iOS/Android platforms to enable body pose and mask detection using Pose Detection and Selfie Segmentation APIs for both static images and live camera stream.

body_detection A flutter plugin that uses MLKit on iOS/Android platforms to enable body pose and mask detection using Pose Detection and Selfie Segmen

null 18 Dec 5, 2022
Mask Aware Face Attendance App built using Flutter

Face Attendance An App Made with Face SDK record.mp4 Before we get started ?? For now, Our app does support only Android platform (arm64). ?? You will

FaceOnLive 113 Dec 30, 2022
Simple face recognition authentication (Sign up + Sign in) written in Flutter using Tensorflow Lite and Firebase ML vision library.

FaceNetAuthentication Simple face recognition authentication (Sign up + Sign in) written in Flutter using Tensorflow Lite and Google ML Kit library. S

Marcos Carlomagno 279 Jan 9, 2023
Flutter realtime object detection with Tensorflow Lite

Flutter realtime object detection with Tensorflow Lite Flutter realtime object d

null 0 Dec 25, 2021
A group of overlapping round avatars are called face piles, a face pile is a series of overlapping avatar images that come and go as users join and leave a given group.

Flutter Face Pile A group of overlapping round avatars are called face piles. A face pile is a series of overlapping avatar images that come and go as

Amine Chamkh 3 Sep 22, 2022
Face detection app built with Flutter and Firebase ML Kit

Flutter Face Detection Flutter Face Detection with Firebase ML Kit and CustomPainter. Read the article on Medium Made with ?? by Akora-IngDKB. Follow

Akora Ing. Debrah Kwesi Buabeng 44 Sep 29, 2022
My flutter (android, ios) UI design examples 🎈 - user profile UIs, food order ui, splashscreen, mask widget usage, settings page ui

Flutter UI Design Examples ?? This repository contains the flutter ui designs I designed while learning. Doctor Appointment App UI Packages in use: fl

Aleyna Eser 23 Nov 14, 2022
Learn how to build a tensorflow model on Techable Machine and then run it on flutter app.

Ml With Flutter Learn how to build a tensorflow model on Techable Machine and then run it on flutter app. Youtube Tutorial Show Support Recommend Me O

Sanskar Tiwari 133 Jan 3, 2023
A Flutter plugin to access TensorFlow Lite apis.

tensorflow_lite A Flutter plugin to access TensorFlow Lite apis. TensorFlow Lite is TensorFlow’s lightweight solution for mobile and embedded devices.

Kashif Minhaj 74 Nov 22, 2022
TensorFlow Lite Flutter Plugin

Overview TensorFlow Lite Flutter plugin provides a flexible and fast solution for accessing TensorFlow Lite interpreter and performing inference. The

Amish Garg 383 Jan 5, 2023