https://github.com/alihassanml/smoking-detection-yolo11
This project uses a YOLO11 model to detect if a person is smoking in real-time video feeds. Built with cv2 and ultralytics, this setup captures frames from a webcam, runs them through a trained YOLO11 model, and displays the detected results in real-time.
https://github.com/alihassanml/smoking-detection-yolo11
detecting smoking yolov8
Last synced: about 1 month ago
JSON representation
This project uses a YOLO11 model to detect if a person is smoking in real-time video feeds. Built with cv2 and ultralytics, this setup captures frames from a webcam, runs them through a trained YOLO11 model, and displays the detected results in real-time.
- Host: GitHub
- URL: https://github.com/alihassanml/smoking-detection-yolo11
- Owner: alihassanml
- License: mit
- Created: 2024-11-06T13:52:17.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-11-06T15:05:10.000Z (6 months ago)
- Last Synced: 2025-03-26T18:57:23.735Z (about 2 months ago)
- Topics: detecting, smoking, yolov8
- Language: Jupyter Notebook
- Homepage:
- Size: 10.4 MB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Smoking Detection with YOLO11
This project uses a YOLO11 model to detect if a person is smoking in real-time video feeds. Built with `cv2` and `ultralytics`, this setup captures frames from a webcam, runs them through a trained YOLO11 model, and displays the detected results in real-time.
## Features
- **Real-time Detection**: Detects smoking activity in real-time through a webcam.
- **YOLO11 Model**: Utilizes a custom-trained YOLO11 model for smoking detection.
- **Annotation**: Frames are annotated with bounding boxes around detected smoking activity.## Installation
1. **Clone the repository**:
```bash
git clone https://github.com/alihassanml/Smoking-detection-yolo11.git
cd Smoking-detection-yolo11
```2. **Install Dependencies**:
Make sure Python is installed and then install the required packages.
```bash
pip install ultralytics opencv-python
```3. **Download the Model**:
Ensure you have the `best.onnx` model file in the project directory. If not, download or place your trained model in this folder.## Usage
Run the following script to start real-time smoking detection:
```python
from ultralytics import YOLO
import cv2# Load the model
model = YOLO('best.onnx')
cap = cv2.VideoCapture(0)while True:
ret, frame = cap.read()
if not ret:
print("Failed to grab frame.")
break# Perform detection
results = model(frame)
result = results[0]# Annotate and display the frame
annotated_frame = result.plot()
cv2.imshow('YOLO Inference', annotated_frame)
if cv2.waitKey(1) == 27: # Press 'ESC' to exit
breakcap.release()
cv2.destroyAllWindows()
```## Model Training (Optional)
This project assumes you have already trained a YOLO11 model for smoking detection. For training instructions, refer to the [Ultralytics YOLO Documentation](https://github.com/ultralytics/ultralytics).## License
This project is licensed under the MIT License.