Crowd Prediction Analysis using Image AI
Ahan Makanur
Unknown
Analysis of crowd in a particular situation helps in handling the situation better and also is particularly used in Traffic analysis or to find out if the place is crowded and is densely populated by people by using simple Machine learning algorithms over object recognition and improve the accuracy rates. ...learn more
Project status: Under Development
RealSense™, Artificial Intelligence
Groups
Student Developers for AI
Intel Technologies
Intel Opt ML/DL Framework
Overview / Usage
It is important to note that- Computer Vision is composed of various aspects such as image recognition, object detection, image generation and various other factors. Today I will show you how to analyse the crowd and predict the class of object along with probabilities of the object.
We need to install the following dependencies before starting off to write the code and the following libraries are important to run the code:
Tensorflow , Numpy, Scipy, Pillow, h5py, OpenCV, Matplotlib, Keras, Neon
It is important to note that, for the model to run, we need to install a particular API called imageAI, and here is the link, as this functions as a backend to the object detection from the images.
Detecting objects in images and videos accurately has been highly successful in the second decade of the 21st century due to the rise of machine learning and deep learning algorithms. Specialized algorithms have been developed that can detect, locate, and recognize objects in images and videos, some of which include RCNNs, SSD, RetinaNet, YOLO, and others.
Using these algorithms to detect and recognize objects in videos requires an understanding of applied mathematics and solid technical knowledge of the algorithms as well as thousands of lines of code. This is a highly technical and time-consuming process, and for those who desire to implement object detection can find the process very inconvenient.
In this article, we we’ll be using a Python library called ImageAI that has made it possible for anyone with basic knowledge of Python to build applications and systems that can detect objects in videos using only a few lines of programming code. ImageAI supports YOLOv3, which is the object detection algorithm we’ll use in this article.
To get started, you will install a number of Python libraries and ImageAI. If you have any of the dependencies mentioned below already installed on your computer, you can jump straight to the installation of ImageAI. Also ensure the Python version you have installed on your computer is Python 3.
Now that you have installed the dependencies, you are ready to write your first object detection code. Create a Python file and give it a name (like, CrowdDetection.py), and then write the code below into it. Copy the RetinaNet model file as shown above, and move it from Downloads>Crowd_Analysis and the image you want to detect to the folder that contains the python file and call it image.jpg
Build a folder called Crowd_Analysis, and following should be its contents:
1.resnet50_coco_best_v2.0.1.h5
2.CrowdDetection.py , as shown below
3.image.jpg (any image you want to analyze)
Once the result is printed to the console, go to the folder in which your CrowdDetection.py is and you will find a new image saved. Take a look at a 2 image samples below and the new images saved after detection.
Methodology / Approach
We imported the ImageAI object detection class in the first line, imported the python os class in the second line and defined a variable to hold the path to the folder where our python file, RetinaNet model file and images are in the third line.
In the 5 lines of code above, we defined our object detection class in the first line, set the model type to RetinaNet in the second line, set the model path to the path of our RetinaNet model in the third line, load the model into the object detection class in the fourth line, then we called the detection function and parsed in the input image path and the output image path in the fifth line.
-
Adjusting Minimum Probability: By default, objects detected with a probability percentage of less than 50 will not be shown or reported. You can increase this value for high certainty cases or reduce the value for cases where all possible objects are needed to be detected.
-
Custom Objects Detection: Using a provided CustomObject class, you can tell the detection class to report detections on one or a few number of unique objects.
-
Detection Speeds: You can reduce the time it takes to detect an image by setting the speed of detection speed to “fast”, “faster” and “fastest”.
-
Input Types: You can specify and parse in file path to an image, Numpy array or file stream of an image as the input image
-
Output Types: You can specify that the detectObjectsFromImage function should return the image in the form of a file or Numpy array
Technologies Used
Tensorflow , Numpy, Scipy, Pillow, h5py, OpenCV, Matplotlib, Keras, Neon
Repository
Collaborators
There are no people to show.