One of the important fields of Artificial Intelligence is Computer Vision. Computer Vision is the science of computers and software systems that can recognize and understand images and scenes. Computer Vision is also composed of various aspects such as image recognition, object detection, image generation, image super-resolution and more. Object detection is probably the most profound aspect of computer vision due the number practical use cases. In this tutorial, I will briefly introduce the concept of modern object detection, challenges faced by software developers, the solution my team has provided as well as code tutorials to perform high performance object detection.
Object detection refers to the capability of computer and software systems to locate objects in an image/scene and identify each object. Object detection has been widely used for face detection, vehicle detection, pedestrian counting, web images, security systems and driverless cars. There are many ways object detection can be used as well in many fields of practice. Like every other computer technology, a wide range of creative and amazing uses of object detection will definitely come from the efforts of computer programmers and software developers.
Getting to use modern object detection methods in applications and systems, as well as building new applications based on these methods is not a straight forward task. Early implementations of object detection involved the use of classical algorithms, like the ones supported in OpenCV, the popular computer vision library. However, these classical algorithms could not achieve enough performance to work under different conditions.
The breakthrough and rapid adoption of deep learning in 2012 brought into existence modern and highly accurate object detection algorithms and methods such as R-CNN, Fast-RCNN, Faster-RCNN, RetinaNet and fast yet highly accurate ones like SSD and YOLO. Using these methods and algorithms, based on deep learning which is also based on machine learning require lots of mathematical and deep learning frameworks understanding. There are millions of expert computer programmers and software developers that want to integrate and create new products that uses object detection. But this technology is kept out of their reach due to the extra and complicated path to understanding and making practical use of it.
ImageAI is a python library that lets programmers and software developers easily integrate state-of-the-art computer vision technologies into their existing and new applications, using just few lines of code.
An AI Commons project https://commons.specpal.science Developed and Maintained by Moses Olafenwa and John Olafenwa, brothers, creators of TorchFusion and Authors of Introduction to Deep Computer Vision
Built with simplicity in mind, ImageAI
supports a list of state-of-the-art Machine Learning algorithms for image prediction, custom image prediction, object detection, video detection, video object tracking
and image predictions trainings. ImageAI currently supports image prediction and training using 4 different Machine Learning algorithms
trained on the ImageNet-1000 dataset. ImageAI also supports object detection, video detection and object tracking using RetinaNet, YOLOv3 and TinyYOLOv3 trained on COCO dataset.
Eventually, ImageAI will provide support for a wider
and more specialized aspects of Computer Vision including and not limited to image
recognition in special environments and special fields.
New Release : ImageAI 2.0.2
What's new:
- Option to state image size during custom image prediction model trainings
- Object Detection and Video Object detection now returns bounding box coordinates ('box points') (x1,y1,x2, y2) for each object detected in addition to object's 'name' and 'percentage probability'
- Options to hide 'percentage probability' and/or object 'name' from being shown in detected image or video
- Support for video object detection on video live stream from device camera, connected camera and IP camera
- Support for YOLOv3 and TinyYOLOv3 for all object detection and video object detection tasks.
- Video object detection for all input types (video file and camera) now allows defining custom functions to execute after each frame, each second and each minute of the video is detected and processed. Also include option to specify custom function at once video is fully detected and processed
- For each custom function specified, ImageAI returns the frame/seconds/minute/full video analysis of the detections that include the objects' details ( name , percentage probability, box_points), number of instance of each unique object detected (counts) and overall average count of the number of instance of each unique object detected in the case of second / minute / full video analysis
- Options to return detected frame at every frame, second or minute processed as a Numpy array.
▣ Dependencies
▣ Installation
▣ Image Prediction
▣ Object Detection
▣ Video Object Detection, Tracking & Analysis
▣ Custom Model Training
▣ Custom Image Prediction
▣ Documentation
▣ Projects Built on ImageAI
▣ AI Practice Recommendations
▣ Support the ImageAI Project
▣ Contact Developers
▣ Contributors
▣ References
- Python 3.5.1 (and later versions) Download (Support for Python 2.7 coming soon)
- pip3 Install
- Tensorflow 1.4.0 (and later versions) Install or install via pip
pip3 install --upgrade tensorflow- Numpy 1.13.1 (and later versions) Install or install via pip
pip3 install numpy- SciPy 0.19.1 (and later versions) Install or install via pip
pip3 install scipy- OpenCV Install or install via pip
pip3 install opencv-python- Pillow Install or install via pip
pip3 install pillow- Matplotlib Install or install via pip
pip3 install matplotlib- h5py Install or install via pip
pip3 install h5py- Keras 2.x Install or install via pip
pip3 install kerasTo install ImageAI, run the python installation instruction below in the command line:
pip3 install https://github.com/OlafenwaMoses/ImageAI/releases/download/2.0.2/imageai-2.0.2-py3-none-any.whl
or download the Python Wheel
imageai-2.0.2-py3-none-any.whl and run the python installation instruction in the command line
to the path of the file like the one below:
pip3 install C:\User\MyUser\Downloads\imageai-2.0.2-py3-none-any.whl
convertible : 52.459555864334106 sports_car : 37.61284649372101 pickup : 3.1751200556755066 car_wheel : 1.817505806684494 minivan : 1.7487050965428352
ImageAI provides 4 different algorithms and model types to perform image prediction, trained on the ImageNet-1000 dataset. The 4 algorithms provided for image prediction include SqueezeNet, ResNet, InceptionV3 and DenseNet.
Click the link below to see the full sample codes, explanations and best practices guide.
ImageAI provides very convenient and powerful methods to perform object detection on images and extract each object from the image. The object detection class provides support for RetinaNet, YOLOv3 and TinyYOLOv3, with options to adjust for state of the art performance or real time processing.
Click the link below to see the full sample codes, explanations and best practices guide.
Video Object Detection & Analysis
Below is a snapshot of a video with objects detected.
Video Custom Object Detection (Object Tracking)
Below is a snapshot of a video with only person, bicycle and motorcyle detected.
Video Analysis Visualization
Below is a visualization of video analysis returned by **ImageAI** into a 'per_second' function.
ImageAI provides very convenient and powerful methods to perform object detection in videos and track specific object(s). The video object detection class provided only supports the current state-of-the-art RetinaNet, but with options to adjust for state of the art performance or real time processing. Click the link to see the full videos, sample codes, explanations and best practices guide.
ImageAI provides classes and methods for you to train a new model that can be used to perform prediction on your own custom objects.
You can train your custom models using SqueezeNet, ResNet50, InceptionV3 and DenseNet in 5 lines of code.
Click the link below to see the guide to preparing training images, sample training codes, explanations and best practices.
Prediction from a sample model trained on IdenProf, for predicting professionals
mechanic : 76.82620286941528 chef : 10.106072574853897 waiter : 4.036874696612358 police : 2.6663416996598244 pilot : 2.239348366856575
ImageAI provides classes and methods for you to run image prediction your own custom objects using your own model trained with ImageAI Model Training class.
You can use your custom models trained with SqueezeNet, ResNet50, InceptionV3 and DenseNet and the JSON file containing the mapping of the custom object names.
Click the link below to see the guide to sample training codes, explanations, and best practices guide.
We have provided full documentation for all ImageAI classes and functions in 2 major languages. Find links below:
>> Documentation - English Version https://imageai.readthedocs.io
>> Documentation - Chinese Version https://imageai-cn.readthedocs.io
ImageAI uses the Tensorflow backbone for it's Computer Vision operations. Tensorflow supports both CPUs and GPUs ( Specifically NVIDIA GPUs. You can get one for your PC or get a PC that has one) for machine learning and artificial intelligence algorithms' implementations. To use Tensorflow that supports the use of GPUs, follow the link below :
FOR WINDOWS
https://www.tensorflow.org/install/install_windows
FOR macOS
https://www.tensorflow.org/install/install_mac
FOR UBUNTU
https://www.tensorflow.org/install/install_linux
We also welcome submissions of applications and systems built by you and powered by ImageAI for listings here. Should you want your ImageAI powered developments listed here, you can reach to us via our Contacts below.
For anyone interested in building AI systems and using them for business, economic, social and research purposes, it is critical that the person knows the likely positive, negative and unprecedented impacts the use of such technologies will have. They must also be aware of approaches and practices recommended by experienced industry experts to ensure every use of AI brings overall benefit to mankind. We therefore recommend to everyone that wishes to use ImageAI and other AI tools and resources to read Microsoft's January 2018 publication on AI titled "The Future Computed : Artificial Intelligence and its role in society ".
Kindly follow the link below to download the publication.
https://blogs.microsoft.com/blog/2018/01/17/future-computed-artificial-intelligence-role-society/
With your contributions, we will be adding more features including the ones requested by users of ImageAI that has contacted us. Some of the features are :
1) Custom training of Object Detection Models using RetinaNet, YOLOv3 and TinyYOLOv3
2) Image Segmentation
3) Face, Gender and Age Detection
4) Vehicle Number Plate Detection Recognition
5) ImageAI and all its features for Android (For integrating all ImageAI features into Android Applications)
6) ImageAI and all its features for iOS (For integrating all ImageAI features into iOS Applications)
7) ImageAI and all its features for .NET (ImageAI and all its features for .NET developers)
Moses Olafenwa
Email: guymodscientist@gmail.com
Website: https://moses.specpal.science
Twitter: @OlafenwaMoses
Medium : @guymodscientist
Facebook : moses.olafenwa
John Olafenwa
Email: johnolafenwa@gmail.com
Website: https://john.specpal.science
Twitter: @johnolafenwa
Medium : @johnolafenwa
Facebook : olafenwajohn
We give special thanks to Kang vcar for his incredible and excellent work in translating ImageAI's documentation to the Chinese language. Find below the contact details of those who have contributed immensely to the ImageAI project.
Kang vcar
Email: kangvcar@mail.com
Website: http://www.kangvcar.com
Twitter: @kangvcar
-
Somshubra Majumdar, DenseNet Implementation of the paper, Densely Connected Convolutional Networks in Keras
https://github.com/titu1994/DenseNet/ -
Broad Institute of MIT and Harvard, Keras package for deep residual networks
https://github.com/broadinstitute/keras-resnet -
Fizyr, Keras implementation of RetinaNet object detection
https://github.com/fizyr/keras-retinanet -
Francois Chollet, Keras code and weights files for popular deeplearning models
https://github.com/fchollet/deep-learning-models -
Forrest N. et al, SqueezeNet: AlexNet-level accuracy with 50x fewer parameters and <0.5MB model size
https://arxiv.org/abs/1602.07360 -
Kaiming H. et al, Deep Residual Learning for Image Recognition
https://arxiv.org/abs/1512.03385 -
Szegedy. et al, Rethinking the Inception Architecture for Computer Vision
https://arxiv.org/abs/1512.00567 -
Gao. et al, Densely Connected Convolutional Networks
https://arxiv.org/abs/1608.06993 -
Tsung-Yi. et al, Focal Loss for Dense Object Detection
https://arxiv.org/abs/1708.02002 -
O Russakovsky et al, ImageNet Large Scale Visual Recognition Challenge
https://arxiv.org/abs/1409.0575 -
TY Lin et al, Microsoft COCO: Common Objects in Context
https://arxiv.org/abs/1405.0312 -
Moses & John Olafenwa, A collection of images of identifiable professionals.
https://github.com/OlafenwaMoses/IdenProf