Detect any custom object with DeepStack
This tutorial details how to create APIs for detecting and recognizing any custom object using DeepStack AI Server
Computer vision has made it possible to develop applications and automation systems that have the ability to detect, identify and locate objects in images, videos and live camera feeds. With profound impact on many areas of socio-economic activity such security, manufacturing, quality assurance, IoT, autonomous vehicles e.t.c , today’s computer vision powered by deep learning models provide limitless opportunity to develop highly intelligent visual systems.
For most developers, researchers and IT engineers, the primary sources for state-of-the-art computer vision integrations are:
- DNN models
- Vision APIs from cloud services
Most computer vision APIs and machine learning models are built to recognize and detect commons objects like persons, electronics, animals, etc. While these does suffice for a lot of computer vision applications, majority of visual tasks involve detection and recognition of custom objects.
E.g detecting defects in a new products, identifying and counting different products in a supermarket store, detecting plant diseases, etc.
In this article, we are going to show you how you can create a computer vision API to detect any object or set of objects for your research, industrial and automation needs using DeepStack.
What is DeepStack?
DeepStack is an open-source AI API server that empowers every developer in the world to easily build state-of-the-art AI systems both on premise and in the cloud. DeepStack is device and programming language agnostic. You can run it on Windows, Mac OS, Linux, Raspberry PI and NVIDIA Jetson devices. The following are features in-built into DeepStack
- Face detection, matching and recognition APIs
- Common objects detection and recognition APIs
- Scene recognition APIs
- Custom objects detection APIs
- API security
DeepStack AI Server
DeepStack is an Open-Source AI API engine that serves pre-built models and custom models on multiple edge devices…
For the purpose of this tutorial, we will be using a custom DeepStack model that has been trained to detect and recognize all the 352 commons logos in the OpenLogo dataset. Follow the steps detailed below:
- Prepare your dataset
- Train your custom DeepStack Model
- Deploy model to create your API
Step 1 — Prepare your dataset
The first step is to collect a minimum of 350 images of the object you are want to detect ( 300 for train and 50 for validation/testing). You can also use an existing public image dataset as far as it has the object you intend to detect and recognize. For the purpose of this tutorial, we have collected and prepared the OpenLogo dataset and ready for you to use. You can download this dataset via the link below
To prepare your own dataset, use the guide in the DeepStack documentation link provided below
Preparing Your Dataset
To train your object detection model, you need to prepare your dataset in the YOLO format ( Click here to learn more on…
Step 2— Train your custom DeepStack Model
The next step is to train a DeepStack model on your custom dataset. DeepStack currently uses the YOLOv5 deep neural network architecture for deploying custom models. For the purpose of this tutorial, we have provided a pre-trained DeepStack model for detecting all the 352 commons logos in the Open Logo dataset. You can download the model file openlogo.pt in the link below
Release DeepStack Model: Pre-trained · OlafenwaMoses/DeepStack_OpenLogo
You can't perform that action at this time. You signed in with another tab or window. You signed out in another tab or…
To train your custom model, use the guide in the DeepStack documentation link below. This guide provides
- end-to-end code and guide for training and generating your custom model
- link to a free Nvidia GPU on the cloud to train your model
Training Your Custom Model
The [DeepStack Trainer]( https://github.com/johnolafenwa/deepstack-trainer) provides all of the functions needed to…
Step 3— Deploy model to create your API
Once you have your model file ( .pt file ), take the following steps to create your detection API to detect your custom object(s). In the case of this tutorial, we will create an API to detect logos. Follow the steps below:
- Install DeepStack on your machine: Install DeepStack AI Server with instructions on DeepStack’s documentation via https://docs.deepstack.cc
- Keep model in a folder: Create a folder on your machine and put the .pt model file into it ( e.g openlogo.pt )
- Run DeepStack to create API: To run DeepStack AI Server with the custom model, run the command that applies to your machine as detailed below as detailed in this DeepStack documentation link here
For Windows 10
deepstack — MODELSTORE-DETECTION 'C\Users\MyUser\Documents\DeepStack-Models' — PORT 80
For Docker on Linux
sudo docker run -v /home/MyUser/Documents/DeepStack-Models:/modelstore/detection -p 80:5000 deepquestai/deepstack
- Once you run the DeepStack start command, you will see a terminal/console log like the one below
- Now your custom logo detection API is active via the endpoint enpoint
- You can now send a
POSTrequest to the endpoint from any application using any programming language with the parameter
imageset to your image data/file. For this article, we have provided a sample image and python code that uses the DeepStack Python SDK to detect logo in an image.
- Install DeepStack Python SDK via the command below
pip install deepstack-sdk --upgrade
- Then run the code below
- Once you run the code and send request to the openlogo endpoints, you will get the results below from DeepStack.
And a new image with name fedex_new.jpg will be saved with the detected logo visualized as seen below.
- DeepStack Python SDK makes it easier for you to detect objects in images and video using DeepStack from in your Python code and applications. Visit the DeepStack Python SDK repository linked below for more code examples.
Official Python SDK for DeepStack Permalink Failed to load latest commit information. Official Python SDK for DeepStack…
- Now that you have created your custom AI API, you make as many API request and process as many images as you need for your use case and in your applications.
- For the list of all the 352 logos the custom model can detect, visit the link below
To Learn more about DeepStack AI Server and it’s APIs, visit the links below.
DeepStack GitHub Repository
The World's Leading Cross Platform AI Engine for Edge Devices, with over 3.2 million installs on Docker Hub. Website…
DeepStack is an AI server that empowers every developer in the world to easily build state-of-the-art AI systems both…
DeepStack Dev Center