Smoking Recognition by Halip26
This project aims to detect smoking in real-time using a webcam feed. It uses a pre-trained face detector model to identify faces in the video stream and a custom-trained smoking recognition model to determine whether the detected face is of a person who is smoking.
- Real-time face detection using OpenCV's deep learning-based face detector.
- Real-time smoking recognition using a custom-trained Keras model.
- Live video feed processing and display.
- Option to save the processed video frames with recognition results.
- Python 3.x
- OpenCV
- imutils
- numpy
- argparse
- pickle
- keras
- tensorflow
-
Clone the repository:
git clone https://github.com/halip26/smoking-recognition.git cd smoking-recognition
-
Install the required packages:
pip install -r requirements.txt
-
Download the face detection model files and place them in the
weights
directory: -
Ensure you have the trained smoking recognition model (
smoking.model
) and the label encoder (le.pickle
) in theweights
directory.
Run the script using the command:
python live-smoking-recognition.py --face_confidence 0.5
Arguments:
--face_confidence
: Minimum probability to filter weak detections. Default is 0.5.
live-smoking-recognition.py
: Main script to run the smoking recognition system.weights/
: Directory containing the model weights and configuration files.deploy.prototxt
: Face detector model configuration.res10_300x300_ssd_iter_140000.caffemodel
: Face detector model weights.smoking.model
: Trained smoking recognition model.le.pickle
: Label encoder for the smoking recognition model.
images/output/
: Directory to save output images.
The system processes each frame of the video stream, detects faces, and determines if the person is smoking. The results are displayed on the video feed with labels and bounding boxes.
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenCV for providing the face detection model and tools.
- Keras and TensorFlow for the deep learning framework.
- Imutils for simplifying video stream handling and image processing tasks.
Feel free to contribute to this project by submitting issues or pull requests.