FaCeMaskDetection | Face mask detection ” software using Python | Machine Learning library

 by   Pankajtokas Python Version: Current License: BSL-1.0

kandi X-RAY | FaCeMaskDetection Summary

kandi X-RAY | FaCeMaskDetection Summary

FaCeMaskDetection is a Python library typically used in Artificial Intelligence, Machine Learning applications. FaCeMaskDetection has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has low support. You can download it from GitHub.

To develop a “Face mask detection” software using Python Programming Language & DataScience, to facilitate easy mask detection from real time video stream as well as from image. The corona virus COVID-19 pandemic is causing a global health crisis so the effective protection methods is wearing a face mask in public areas according to the World Health Organization (WHO). The COVID-19 pandemic forced governments across the world to impose lockdowns to prevent virus transmissions. Reports indicate that wearing facemasks while at work clearly reduces the risk of transmission. An efficient and economic approach of using AI to create a safe environment in a manufacturing setup. A hybrid model using deep and classical machine learning for face mask detection will be presented. A face mask detection dataset consists of with mask and without mask images, we are going to use OpenCV to do real-time face detection from a live stream via our webcam. We will use the dataset to build a COVID-19 face mask detector with computer vision using Python, OpenCV, and Tensor Flow and Keras. Our goal is to identify whether the person on image/video stream is wearing a face mask or not with the help of computer vision, data science and deep learning. The trend of wearing face masks in public is rising due to the COVID- 19 corona virus epidemic all over the world. Before Covid-19, People used to wear masks to protect their health from air pollution. While other people are self-conscious about their looks, they hide their emotions from the public by hiding their faces. Scientists proofed that wearing face masks works on impeding COVID-19 transmission. COVID19 (known as corona virus) is the latest epidemic virus that hit the human health in the last century. In 2020, the rapid spreading of COVID-19 has forced the World Health Organization to declare COVID- 19 as a global pandemic. More than five million cases were infected by COVID-19 in less than 6 months across 188 countries. The virus spreads through close contact and in crowded and overcrowded areas. The corona virus epidemic has given rise to an extraordinary degree of worldwide scientific cooperation. Artificial Intelligence (AI) based on Machine learning and Deep Learning can help to fight Covid-19 in many ways. Machine learning allows researchers and clinicians evaluate vast quantities of data to forecast the distribution of COVID-19,to serve as an early warning mechanism for potential pandemics, and to classify vulnerable populations.The provision of healthcare needs funding for emerging technology such as artificial intelligence, IoT, big data and machine learning to tackle and predict new diseases. In order to better understand infection rates and to trace and quickly detect infections, the AI’s power is being exploited to address the Covid-19 pandemic. People are forced by laws to wear face masks in public in many countries.These rules and laws were developed as an action to the exponential growth in cases and deaths in many areas. However, the process of monitoring large groups of people is becoming more difficult. The monitoring process involves the detection of anyone who is not wearing a face mask. Here we introduce a mask face detection model thatis based on computer vision and deep learning. The proposed model can be integrated with surveillance cameras to impede the COVID-19 transmission by allowing the detection of people who are wearing masks not wearing face masks. The model is integration between deep learning and classical machine learning techniques with opencv, tensor flow and keras. We have used deep transfer leering for feature extractions and combined it with three classical machine learning algorithms. We introduced a comparison between them to find the most suitable algorithm that achieved the highest accuracy and consumed the least time in the process of training and detection. Machine learning (ML)is the study of computer algorithms thatimprove automatically through experience. Itis seen as a subset of artificial intelligence. Machine learning algorithms build a mathematical model based on sample data, known as "training data", in order to make predictions or decisions without being explicitly programmed to do so. Machine learning algorithms are used in a wide variety of applications, such as email filtering and computer vision, where it is difficult or infeasible to develop conventional algorithms to perform the needed tasks. Machine learning is closely related to computational statistics, which focuses on making predictions using computers. The study of mathematical optimization delivers methods, theory and application domains to the field of machine learning. Data mining is a related field of study, focusing on exploratory data analysis through unsupervised learning. In its application across business problems, machine learning is also referred to as predictive analytics. Machine learning approaches are traditionally divided into three broad categories, depending on the nature of the "signal" or "feedback" available to the learning system: • Supervised learning: The computer is presented with example inputs and their desired outputs, given by a "teacher", and the goal is to learn a general rule that maps inputs to outputs. • Unsupervised learning: No labels are given to the learning algorithm, leaving it on its own to find structure in its input. Unsupervised learning can be a goal in itself (discovering hidden patterns in data) or a means towards an end (feature learning). • Reinforcement learning: A computer program interacts with a dynamic environment in which it must perform a certain goal (such as driving a vehicle or playing a game against an opponent). As it navigates its problem space, the program is provided feedback that's analogous to rewards, which it tries to maximize. Other approaches have been developed which don't fit neatly into this three-fold categorization, and sometimes more than one is used by the same machine learning system. Computer vision is an interdisciplinary scientific field that deals with how computers can gain high-level understanding from digital images or videos. From the perspective of engineering, it seeks to understand and automate tasks that the human visual system can do, Computer vision tasks include methods for acquiring, processing, analyzing and understanding digital images, and extraction of high- dimensional data from the real world in order to produce decisions, Understanding in this context means the transformation of visual images (the input of the retina) into descriptions of the world that make sense to thought processes and can elicit appropriate action. This image understanding can be seen as the disentangling of symbolic information from image data using models constructed with the aid of geometry, physics, statistics, and learning theory. The scientific discipline of computer vision is concerned with the theory behind artificial systems that extract information from images. The image data can take many forms, such as video sequences, views from multiple cameras, multi- dimensional data from a 3D scanner or medical scanning device. The technological discipline of computer vision seeks to apply its theories and models to the construction of computer vision systems. Computer vision is an interdisciplinary field that deals with how computers can be made to gain high-level understanding from digital images or videos. From the perspective of engineering, it seeks to automate tasks that the human visual system can do. Computer vision is concerned with the automatic extraction, analysis and understanding of useful information from a single image or a sequence of images. It involves the development of a theoretical and algorithmic basis to achieve automatic visual understanding. As a scientific discipline, computer vision is concerned with the theory behind artificial systems that extract information from images. The image data can take many forms, such as video sequences, views from multiple cameras, or multi- dimensional data from a medical scanner. As a technological discipline, computer vision seeks to apply its theories and models for the construction of computer vision systems. Early experiments in computer vision took place in the 1950s, using some of the first neural networks to detect the edges of an object and to sort simple objects into categories like circles and squares. In the 1970s, the first commercial use of computer vision interpreted typed or handwritten text using optical character recognition. This advancement was used to interpret written text for the blind. As the internet matured in the 1990s, making large sets of images available online for analysis, facial recognition programs flourished. These growing data sets helped make it possible for machines to identify specific people in photos, videos. Today’s AI systems can go a step further and take actions based on an understanding of the image. There are many types of computer vision that are used in different ways: • Image segmentation partitions an image into multiple regions or pieces to be examined separately. • Object detection identifies a specific object in an image. Advanced object detection recognizes many objects in a single image: a football field, an offensive player, a defensive player, a ball and so on. These models use an X,Y coordinate to create a bounding box and identify everything inside the box. • Facial recognition is an advanced type of object detection that not only recognizes a human face in an image, but identifies a specific individual. • Edge detection is a technique used to identify the outside edge of an object or landscape to better identify what is in the image. • Pattern detection is a process of recognizing repeated shapes, colors and other visual indicators in images. • Image classification groups images into different categories. • Feature matching is a type of pattern detection that matches similarities in images to help classify them. Deep learning methods aim at learning feature hierarchies with features from higher levels of the hierarchy formed by the composition of lower level features. Automatically learning features at multiple levels of abstraction allow a system to learn complex functions mapping the input to the output directly from data, without depending completely on human-crafted features. Deep learning algorithms seek to exploit the unknown structure in the input distribution in order to discover good representations, often at multiple levels, with higher-level learned features defined in terms of lower-level features. The hierarchy of concepts allows the computer to learn complicated concepts by building them out of simpler ones. If we draw a graph showing how these concepts are built on top of each other, the graph is deep, with many layers. For this reason, we call this approach to AI deep learning. Deep learning excels on problem domains where the inputs (and even output) are analog. Meaning, they are not a few quantities in a tabular format but instead are images of pixel data, documents of text data or files of audio data. Deep learning allows computational models that are composed of multiple processing layers to learn representations of data with multiple levels of abstraction. The first general, working learning algorithm for supervised, deep, feedforward, multilayer perceptrons was published by Alexey Ivakhnenko and Lapa in 1967.[27] A 1971 paper described a deep network with eight layers trained by the group method of data handling.[28] Other deep learning working architectures, specifically those built for computer vision, began with the Neocognitron introduced by Kunihiko Fukushima in 1980. The term Deep Learning was introduced to the machine learning community by Rina Dechter in 1986,[30][16] and to artificial neural networks by Igor Aizenberg and colleagues in 2000, in the context of Boolean threshold neurons. In 1989, Yann LeCun et al. applied the standard backpropagation algorithm, which had been around as the reverse mode of automatic differentiation since 1970,[33][34][35][36] to a deep neural network with the purpose of recognizing handwritten ZIP codes on mail. While the algorithm worked, training required 3 days.[37] By 1991 such systems were used for recognizing isolated 2-D hand-written digits, while recognizing 3-D objects was done by matching 2-D images with a handcrafted 3-D object model. Weng et al. suggested that a human brain does not use a monolithic 3-D object model and in 1992 they published Cresceptron, a method for performing 3-D object recognition in cluttered scenes. Because it directly used natural images, Cresceptron started the beginning of general-purpose visual learning for natural 3D worlds. Cresceptron is a cascade of layers similar to Neocognitron. But while Neocognitron required a human programmer to hand-merge features, Cresceptron learned an open number of features in each layer without supervision, where each feature is represented by a convolution kernel. Cresceptron segmented each learned object from a cluttered scene through back-analysis through the network. Max pooling, now often adopted by deep neural networks (e.g. ImageNet tests), was first used in Cresceptron to reduce the position resolution by a factor of (2x2) to 1 through the cascade for better generalization. OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in the commercial products. Being a BSD-licensed product, OpenCV makes it easy for businesses to utilize and modify the code. The library has more than 2500 optimized algorithms, which includes a comprehensive set of both classic and state-of- the-art computer vision and machine learning algorithms. These algorithms can be used to detect and recognize faces, identify objects, classify human actions in videos, track camera movements, track moving objects, extract 3D models of objects, produce 3D point clouds from stereo cameras, stitch images together to produce a high resolution image of an entire scene, find similar images from an image database, remove red eyes from images taken using flash, follow eye movements, recognize scenery and establish markers to overlay it with augmented reality, etc. OpenCV has more than 47 thousand people of user community and estimated used extensively in companies, research groups and by governmental bodies.Along with well-established companies like Google, Yahoo, Microsoft, Intel, IBM, Sony, Honda, Toyota that employ the library, there are many startups such as Applied Minds, Video Surf, and Zeitera, that make extensive use of OpenCV. OpenCV’s deployed uses span the range from stitching street view images together, detecting intrusions in surveillance video in Israel, monitoring mine equipment in China, helping robots navigate and pick up objects at Willow Garage, detection of swimming pool drowning accidents in Europe, running interactive art in Spain and New York, checking runways for debris in Turkey, inspecting labels on products in factories around the world on to rapid face detection in Japan. It has C++, Python, Java and MATLAB interfaces and supports Windows, Linux, Android and Mac OS. OpenCV leans mostly towards real-time vision applications and takes advantage of MMX and SSE instructions when available. A full-featured CUDA and OpenCL interfaces are being actively developed right now. There are over 500 algorithms and about 10 times as many functions that compose or support those algorithms. OpenCV is written natively in C++ and has a template interface that works seamlessly with STL containers.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              FaCeMaskDetection has a low active ecosystem.
              It has 1 star(s) with 0 fork(s). There are 1 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              FaCeMaskDetection has no issues reported. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of FaCeMaskDetection is current.

            kandi-Quality Quality

              FaCeMaskDetection has 0 bugs and 6 code smells.

            kandi-Security Security

              FaCeMaskDetection has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              FaCeMaskDetection code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              FaCeMaskDetection is licensed under the BSL-1.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              FaCeMaskDetection releases are not available. You will need to build from source code and install.
              Build file is available. You can build the component from source.
              Installation instructions are not available. Examples and code snippets are available.
              It has 155 lines of code, 1 functions and 2 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed FaCeMaskDetection and discovered the below as its top functions. This is intended to give you an instant insight into FaCeMaskDetection implemented functionality, and help decide if they suit your requirements.
            • Detects and returns a list of faces using a face mask .
            Get all kandi verified functions for this library.

            FaCeMaskDetection Key Features

            No Key Features are available at this moment for FaCeMaskDetection.

            FaCeMaskDetection Examples and Code Snippets

            No Code Snippets are available at this moment for FaCeMaskDetection.

            Community Discussions

            QUESTION

            Using RNN Trained Model without pytorch installed
            Asked 2022-Feb-28 at 20:17

            I have trained an RNN model with pytorch. I need to use the model for prediction in an environment where I'm unable to install pytorch because of some strange dependency issue with glibc. However, I can install numpy and scipy and other libraries. So, I want to use the trained model, with the network definition, without pytorch.

            I have the weights of the model as I save the model with its state dict and weights in the standard way, but I can also save it using just json/pickle files or similar.

            I also have the network definition, which depends on pytorch in a number of ways. This is my RNN network definition.

            ...

            ANSWER

            Answered 2022-Feb-17 at 10:47

            You should try to export the model using torch.onnx. The page gives you an example that you can start with.

            An alternative is to use TorchScript, but that requires torch libraries.

            Both of these can be run without python. You can load torchscript in a C++ application https://pytorch.org/tutorials/advanced/cpp_export.html

            ONNX is much more portable and you can use in languages such as C#, Java, or Javascript https://onnxruntime.ai/ (even on the browser)

            A running example

            Just modifying a little your example to go over the errors I found

            Notice that via tracing any if/elif/else, for, while will be unrolled

            Source https://stackoverflow.com/questions/71146140

            QUESTION

            Flux.jl : Customizing optimizer
            Asked 2022-Jan-25 at 07:58

            I'm trying to implement a gradient-free optimizer function to train convolutional neural networks with Julia using Flux.jl. The reference paper is this: https://arxiv.org/abs/2005.05955. This paper proposes RSO, a gradient-free optimization algorithm updates single weight at a time on a sampling bases. The pseudocode of this algorithm is depicted in the picture below.

            optimizer_pseudocode

            I'm using MNIST dataset.

            ...

            ANSWER

            Answered 2022-Jan-14 at 23:47

            Based on the paper you shared, it looks like you need to change the weight arrays per each output neuron per each layer. Unfortunately, this means that the implementation of your optimization routine is going to depend on the layer type, since an "output neuron" for a convolution layer is quite different than a fully-connected layer. In other words, just looping over Flux.params(model) is not going to be sufficient, since this is just a set of all the weight arrays in the model and each weight array is treated differently depending on which layer it comes from.

            Fortunately, Julia's multiple dispatch does make this easier to write if you use separate functions instead of a giant loop. I'll summarize the algorithm using the pseudo-code below:

            Source https://stackoverflow.com/questions/70641453

            QUESTION

            How can I check a confusion_matrix after fine-tuning with custom datasets?
            Asked 2021-Nov-24 at 13:26

            This question is the same with How can I check a confusion_matrix after fine-tuning with custom datasets?, on Data Science Stack Exchange.

            Background

            I would like to check a confusion_matrix, including precision, recall, and f1-score like below after fine-tuning with custom datasets.

            Fine tuning process and the task are Sequence Classification with IMDb Reviews on the Fine-tuning with custom datasets tutorial on Hugging face.

            After finishing the fine-tune with Trainer, how can I check a confusion_matrix in this case?

            An image of confusion_matrix, including precision, recall, and f1-score original site: just for example output image

            ...

            ANSWER

            Answered 2021-Nov-24 at 13:26

            What you could do in this situation is to iterate on the validation set(or on the test set for that matter) and manually create a list of y_true and y_pred.

            Source https://stackoverflow.com/questions/68691450

            QUESTION

            CUDA OOM - But the numbers don't add upp?
            Asked 2021-Nov-23 at 06:13

            I am trying to train a model using PyTorch. When beginning model training I get the following error message:

            RuntimeError: CUDA out of memory. Tried to allocate 5.37 GiB (GPU 0; 7.79 GiB total capacity; 742.54 MiB already allocated; 5.13 GiB free; 792.00 MiB reserved in total by PyTorch)

            I am wondering why this error is occurring. From the way I see it, I have 7.79 GiB total capacity. The numbers it is stating (742 MiB + 5.13 GiB + 792 MiB) do not add up to be greater than 7.79 GiB. When I check nvidia-smi I see these processes running

            ...

            ANSWER

            Answered 2021-Nov-23 at 06:13

            This is more of a comment, but worth pointing out.

            The reason in general is indeed what talonmies commented, but you are summing up the numbers incorrectly. Let's see what happens when tensors are moved to GPU (I tried this on my PC with RTX2060 with 5.8G usable GPU memory in total):

            Let's run the following python commands interactively:

            Source https://stackoverflow.com/questions/70074789

            QUESTION

            How to compare baseline and GridSearchCV results fair?
            Asked 2021-Nov-04 at 21:17

            I am a bit confusing with comparing best GridSearchCV model and baseline.
            For example, we have classification problem.
            As a baseline, we'll fit a model with default settings (let it be logistic regression):

            ...

            ANSWER

            Answered 2021-Nov-04 at 21:17

            No, they aren't comparable.

            Your baseline model used X_train to fit the model. Then you're using the fitted model to score the X_train sample. This is like cheating because the model is going to already perform the best since you're evaluating it based on data that it has already seen.

            The grid searched model is at a disadvantage because:

            1. It's working with less data since you have split the X_train sample.
            2. Compound that with the fact that it's getting trained with even less data due to the 5 folds (it's training with only 4/5 of X_val per fold).

            So your score for the grid search is going to be worse than your baseline.

            Now you might ask, "so what's the point of best_model.best_score_? Well, that score is used to compare all the models used when searching for the optimal hyperparameters in your search space, but in no way should be used to compare against a model that was trained outside of the grid search context.

            So how should one go about conducting a fair comparison?

            1. Split your training data for both models.

            Source https://stackoverflow.com/questions/69844028

            QUESTION

            Getting Error 524 while running jupyter lab in google cloud platform
            Asked 2021-Oct-15 at 02:14

            I am not able to access jupyter lab created on google cloud

            I created one notebook using Google AI platform. I was able to start it and work but suddenly it stopped and I am not able to start it now. I tried building and restarting the jupyterlab, but of no use. I have checked my disk usages as well, which is only 12%.

            I tried the diagnostic tool, which gave the following result:

            but didn't fix it.

            Thanks in advance.

            ...

            ANSWER

            Answered 2021-Aug-20 at 14:00

            QUESTION

            TypeError: brain.NeuralNetwork is not a constructor
            Asked 2021-Sep-29 at 22:47

            I am new to Machine Learning.

            Having followed the steps in this simple Maching Learning using the Brain.js library, it beats my understanding why I keep getting the error message below:

            I have double-checked my code multiple times. This is particularly frustrating as this is the very first exercise!

            Kindly point out what I am missing here!

            Find below my code:

            ...

            ANSWER

            Answered 2021-Sep-29 at 22:47

            Turns out its just documented incorrectly.

            In reality the export from brain.js is this:

            Source https://stackoverflow.com/questions/69348213

            QUESTION

            Ordinal Encoding or One-Hot-Encoding
            Asked 2021-Sep-04 at 06:43

            IF we are not sure about the nature of categorical features like whether they are nominal or ordinal, which encoding should we use? Ordinal-Encoding or One-Hot-Encoding? Is there a clearly defined rule on this topic?

            I see a lot of people using Ordinal-Encoding on Categorical Data that doesn't have a Direction. Suppose a frequency table:

            ...

            ANSWER

            Answered 2021-Sep-04 at 06:43

            You're right. Just one thing to consider for choosing OrdinalEncoder or OneHotEncoder is that does the order of data matter?

            Most ML algorithms will assume that two nearby values are more similar than two distant values. This may be fine in some cases e.g., for ordered categories such as:

            • quality = ["bad", "average", "good", "excellent"] or
            • shirt_size = ["large", "medium", "small"]

            but it is obviously not the case for the:

            • color = ["white","orange","black","green"]

            column (except for the cases you need to consider a spectrum, say from white to black. Note that in this case, white category should be encoded as 0 and black should be encoded as the highest number in your categories), or if you have some cases for example, say, categories 0 and 4 may be more similar than categories 0 and 1. To fix this issue, a common solution is to create one binary attribute per category (One-Hot encoding)

            Source https://stackoverflow.com/questions/69052776

            QUESTION

            How to increase dimension-vector size of BERT sentence-transformers embedding
            Asked 2021-Aug-15 at 13:35

            I am using sentence-transformers for semantic search but sometimes it does not understand the contextual meaning and returns wrong result eg. BERT problem with context/semantic search in italian language

            by default the vector side of embedding of the sentence is 78 columns, so how do I increase that dimension so that it can understand the contextual meaning in deep.

            code:

            ...

            ANSWER

            Answered 2021-Aug-10 at 07:39

            Increasing the dimension of a trained model is not possible (without many difficulties and re-training the model). The model you are using was pre-trained with dimension 768, i.e., all weight matrices of the model have a corresponding number of trained parameters. Increasing the dimensionality would mean adding parameters which however need to be learned.

            Also, the dimension of the model does not reflect the amount of semantic or context information in the sentence representation. The choice of the model dimension reflects more a trade-off between model capacity, the amount of training data, and reasonable inference speed.

            If the model that you are using does not provide representation that is semantically rich enough, you might want to search for better models, such as RoBERTa or T5.

            Source https://stackoverflow.com/questions/68686272

            QUESTION

            How to identify what features affect predictions result?
            Asked 2021-Aug-11 at 15:55

            I have a table with features that were used to build some model to predict whether user will buy a new insurance or not. In the same table I have probability of belonging to the class 1 (will buy) and class 0 (will not buy) predicted by this model. I don't know what kind of algorithm was used to build this model. I only have its predicted probabilities.

            Question: how to identify what features affect these prediction results? Do I need to build correlation matrix or conduct any tests?

            Table example:

            ...

            ANSWER

            Answered 2021-Aug-11 at 15:55

            You could build a model like this.

            x = features you have. y = true_lable

            from that you can extract features importance. also, if you want to go the extra mile,you can do Bootstrapping, so that the features importance would be more stable (statistical).

            Source https://stackoverflow.com/questions/68744565

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install FaCeMaskDetection

            You can download it from GitHub.
            You can use FaCeMaskDetection like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/Pankajtokas/FaCeMaskDetection.git

          • CLI

            gh repo clone Pankajtokas/FaCeMaskDetection

          • sshUrl

            git@github.com:Pankajtokas/FaCeMaskDetection.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link