Due to the Corona crisis, several governments have decided to implement restrictions for social distance.
The overall goal of this project is to identify people who are following social distancing guidelines and those who are not. This is accomplished by way of the following:
- Identifying people in images
- Calculate real world distances between them, directly from the image
- Detect those that do not follow social distancing guidelines
- Visualize the results on the camera image
To build and test your YOLO object detection model and monitor social distancing follow the below steps:
- Image Annotation
- Annotate images
- Training
- Download pre-trained weights
- Train your custom YOLO model on annotated images
- Inference
- Detect people in new images and videos and
- Monitor the distance between them
- Evaluation
- Evaluate the accuracy of the model for human detection
1_Image_Annotation
: Scripts and instructions on annotating images2_Training
: Scripts and instructions on training your YOLOv3 model3_Inference
: Scripts and instructions on testing your trained YOLO model on new images and videos4_Evaluation
: Scripts and instructions on evaluating the results of the trained modelData
: Input Data, Output Data, Model Weights and ResultsUtils
: Utility scripts used by main scripts
The only hard requirement is a running version of python 3.6 or 3.7. To install python 3.7 go to python.org/downloads.
and follow the installation instructions. Note that this repo has only been tested with python 3.6 and python 3.7 thus it is recommened to use either python3.6
or python3.7
.
To speed up training, it is recommended to use a GPU with CUDA support. For example on AWS you can use a p2.xlarge
instance (Tesla K80 GPU with 12GB memory). Inference is very fast even on a CPU with approximately ~2 images per second. If you want to use your own machine, follow the instructions at tensorflow.org/install/gpu to install CUDA drivers. Make sure to install the correct version of CUDA and cuDNN.
Install required packages via:
pip install -r requirements.txt
To train a YOLO object detector and monitor social distancing follow the instructions detailed in the three numbered subfolders of this repo:
Each *.py
script has various command line options that help tweak performance and change things such as input and output directories. All scripts are initialized with good default values that help accomplish all tasks as long as the original folder structure is preserved. To learn more about available command line options of a python script <script_name.py>
run:
python <script_name.py> -h
If you want to run multiple streams in parallel, head over to github.com/bertelschmitt/multistreamYOLO.
- Constantinos Demetriou
- George Hadjiantonis
- Mikhail Konstantinou
This work is licensed under a [Creative Commons Attribution 4.0 International License][cc-by].