1. Products
  2.   Image
  3.   Python
  4.   ImageAI
 
  

Create Advanced AI Products via Free Python API

Open Source Python APIs to Develop Applications and Systems with self-contained deep learning and computer vision capabilities.

ImageAI is a simple yet very powerful & advanced open source Python library that gives software developers the power to develop applications and software utilities with self-contained deep learning and computer vision capabilities. The library has included several advanced features related to image recognition, object detection, object detection in Videos, training Custom Recognition models, video and camera feed analysis, and recognizing objects with the models.

The library is easy to use and empowers software programmers to easily integrate advanced Artificial Intelligence capabilities into their applications and systems with just a couple of lines of python code. There are other libraries that can also provide you with AI-related features like Tensor Flow, OpenCV, and Keras, but that will need you to write a large amount of code. On the other hand with ImageAI a couple of lines of code will be required to achieve it.

The free open source ImageAI library is very popular and has been liked by students, researchers, developers, and experts around the world to effortlessly produce advanced artificial intelligence products and solutions with ease

Previous Next

Getting Started with ImageAI

It is recommended to install ImageAI via pip, please run the following python installation commands.

Install ImageAI via pip

pip3 install imageai --upgrade

Image Prediction via Python APIs

The open source ImageAI library enables software developers to add Image Prediction capabilities into their own python applications with just a couple of lines of code. The library has included 4 different algorithms and model types to perform image prediction, such as SqueezeNet, ResNet, InceptionV3, and DenseNet. Please do remember that each of these algorithms has separate model files that users need to use depending on the choice of the algorithm. The library also offers prediction speeds for all image prediction tasks such as normal by default, fast, faster, and fastest.

Perform Image Prediction via Python

from imageai.Classification import ImageClassification
import os

execution_path = os.getcwd()

prediction = ImageClassification()
prediction.setModelTypeAsResNet50()
prediction.setModelPath(os.path.join(execution_path, "resnet50_imagenet_tf.2.0.h5"))
prediction.loadModel()

predictions, probabilities = prediction.classifyImage(os.path.join(execution_path, "1.jpg"), result_count=5 )
for eachPrediction, eachProbability in zip(predictions, probabilities):
    print(eachPrediction , " : " , eachProbability)

Image Object Detection in Python Apps

Object detection is an amazing computer vision technique that gives software developers the ability to identify and locate objects in an image or inside a video. The ImageAI library has included very useful methods to accomplish object detection on images and extract each object from the image. It has provided support for RetinaNet, YOLOv3, and TinyYOLOv3, with options to achieve high performance and real-time processing.

Video Object Detection via Python

Same like Object Detection inside images the ImageAI library has provided a very powerful and easy method for detecting and tracking objects inside videos using python commands. For smooth video object detection, you need to download the RetinaNet, YOLOv3, or TinyYOLOv3 object detection model. After successful downloading of the object detection model file, please copy the model file to the project folder where .py files will be saved. As video object detection is a very exhaustive task, it is advised to use a computer with an NVIDIA GPU and the GPU version of Tensorflow.

Video Object Detection via Python

from imageai.Detection.Custom import CustomVideoObjectDetection
import os
import cv2

execution_path = os.getcwd()
camera = cv2.VideoCapture(0)

video_detector = CustomVideoObjectDetection()
video_detector.setModelTypeAsYOLOv3()
video_detector.setModelPath("hololens-ex-60--loss-2.76.h5")
video_detector.setJsonPath("detection_config.json")
video_detector.loadModel()

video_detector.detectObjectsFromVideo(camera_input=camera,
                                          output_file_path=os.path.join(execution_path, "holo1-detected3"),
                                          frames_per_second=20,
                                          minimum_percentage_probability=40,
                                          log_progress=True)

Use Custom Model Training Facility

The open source ImageAI library enables software developers to train custom image prediction models with ease. It allows developers to train their own model on any set of images that corresponds to any type of object. A JSON file will be created by the training procedures which will map the object types in the image dataset and create lots of models. After that the job is easy you need to pick the model with the highest accuracy and perform a custom image prediction.

Apply Custom Model Training

from imageai.Classification.Custom import ClassificationModelTrainer
model_trainer = ClassificationModelTrainer()
model_trainer.setModelTypeAsResNet50()
model_trainer.setDataDirectory("pets")
model_trainer.trainModel(num_objects=4, num_experiments=100, enhance_data=True, batch_size=32, show_network_summary=True)
 English