GithubHelp home page GithubHelp logo

paul-pias / social-distance-monitoring Goto Github PK

View Code? Open in Web Editor NEW
18.0 5.0 4.0 11.77 MB

Used Yolact++ to implement social distance monitoring.

Python 97.55% Shell 1.17% HTML 1.28%
social-distancing-detection social-distance-monitoring yolact

social-distance-monitoring's Introduction

Social-Distance-Monitoring

Introduction

This repository holds the implementation of monitoring social distancing implied for COVID-19 using YOLACT: Real-time Instance Segmentation) for object detection.

User Guideline

System Requirement

  • For better performance you will cuda version 10 or 10.1
  • Python3

Installation

    $ pip install -r requirements.txt

For the installation of torch using "pip" kindly follow the instructions from Pytorch

First, you need to clone the repository using gitbash (if gitbash is already installed) or you can download the zip file.

    $ git clone https://github.com/paul-pias/Social-Distance-Monitoring.git

If want to see your output in your browser execute the "server.py" script or else run "inference.py" to execute it locally.

If you want to run the inference on a ip camera need to use WebcamVideoStream with the following command.

    "rtsp://assigned_name_of_the_camera:assigned_password@camer_ip/"

If you want to use YOLACT++, compile deformable convolutional layers (from DCNv2). Make sure you have the latest CUDA toolkit installed from NVidia's Website.

    cd external/DCNv2
    python setup.py build develop

In the official Yolact repository there are several pre-trained model available.

Image Size Model File (-m) Config (-c)
550 yolact_resnet50_54_800000.pth yolact_resnet50
550 yolact_darknet53_54_800000.pth yolact_darknet53
550 yolact_base_54_800000.pth yolact_base
700 yolact_im700_54_800000.pth yolact_im700
550 yolact_plus_resnet50_54_800000.pth yolact_plus_resnet50
550 yolact_plus_base_54_800000.pth yolact_plus_base

Things to consider

Download the pre-trained weights and save in the folder weights, then from your terminal run the following command based on your preference.

    python inference.py -m=weights/yolact_base_54_800000.pth -c=yolact_base -i 0

Here 0 as id passed if you want to run the inference on webcam feed. If you don't parse any argument it will run with the default values. You can tweak the following values according to your preference.

Input Value Description
width, height 1280 x 720
display_lincomb `False
crop True For better segmentation use this flag as True
score_threshold 0.15 Higher the value better the performace
top_k 30 At max how many objects will the model consider to detect in a given frame
display_masks True Draw segmentation
display_fps False
display_text True
display_bboxes `True
display_scores False
fast_nms True
cross_class_nms True
display_text True

The Purpose!

Social Distancing is a way of protecting yourself and others around you by knowing the facts and taking appropriate precautions. To prevent the spread of COVID-19 few guidelines were provided by World Health Organzation (WHO) and other public health agency. Maintaining at least 1 metre (3 feet) distance between yourself and anyone who is coughing or sneezing or for the time being everyone was one of them.

To measure distance between two person eucledian distance was used in this work. Euclidean distance or Euclidean metric is the "ordinary" straight-line distance between two points in Euclidean space.

The Euclidean distance between two points p and q is the length of the line segment connecting them \overline{\mathbf{p}\mathbf{q}}. In the Euclidean plane, if p = (p1, p2) and q = (q1, q2) then the distance is given by

{\displaystyle d(\mathbf {p} ,\mathbf {q} )={\sqrt {(q_{1}-p_{1})^{2}+(q_{2}-p_{2})^{2}}}.}

This formula was applied in the draw_distance(boxes) function where we got all the bounding boxes of person class in a given frame from the model where each bounding is a regression value consisting (x,y,w,h) . Where x and y represent 2 co-ordinates of the person and w & h represent widh and height correspondingly. All combinations of boxes were found to calculate the distance between them.

Acknowlegement

Thanks to Daniel Bolya et. el for introducing Single Shot detection (SSD) implementation for segmentation in YOLACT & YOLACT++ as it becomes less memory hungry.

However, for more details on Object detection and Image understanding you can also visit this repo .

social-distance-monitoring's People

Contributors

paul-pias avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

social-distance-monitoring's Issues

How is the distance threshold determined?

Hello,

In the code, I noticed that 250 is used as a threshold to classify people as being too close ("red"). However, this is a distance in pixels, not meters. How was it determined then?

Also, isn't that ignoring the problem of perspective? (if two people are close to the camera then their pixel distance will be large, but if they are far away from the camera than their pixel distance will be small).

Thanks,
David

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.