Applying Deep Learning And Computer Vision on the Edge Gateway
Learn how to combine deep learning and image recognition so you can more efficiently categorize incoming data from your edge hardware.
Join the DZone community and get the full member experience.Join For Free
the edge gateway is about providing real-time decision-making at the edge. in this article, i will talk about how to apply computer vision at the edge for various security and surveillance activities. for instance, you would like to detect suspicious activities at the atm, simple cases like people wearing helmets and entering the atm to unusual movements or would like to capture and identify objects in remote areas using drones — involving anything from crops to mining activities. in such a scenario, you would need real-time decision-making at the edge, as it might not make sense to transfer the data over the cloud for processing, be it for latency issues, bandwidth, cost issues, or there might be no or very limited connectivity. in this case, you employ intelligence at the edge of the devices.
in order to build out the solution, you need to employ computer vision algorithms on the edge. you can build this using commercial available apis or using various open source deep learning frameworks like theano, tensorflow, café, etc. deep learning is a branch of machine learning for learning multiple levels of representation through neural networks. neural networks, in image processing, automatically infer rules for recognizing images instead of you extracting thousands of features to detect images.
various deep learning architectures are available, like convolutional neural networks (cnns), recurring neural networks to solve specific problems like computer vision, natural language processing, speech recognition, and others, which all help achieve state-of-the-art results.
for computer vision, we specifically use a cnn to identify images or the use of the pre-trained instance (like the inception model released by google, which is a 22 layers’ deep network that achieves state-of-the-art results for classification and detection for images). for a computer, images are nothing but a vector or set of numbers/pixels. convolutional neural networks learn features automatically using small frames of equal-sized images. each network gets the same input, and interesting pieces are extracted (for more details, please refer to how cnn works). the extraction of interesting pieces (which are again vectors of numbers) is the heart of how cnn works. for instance, in the case of a helmet, some network would learn a round edge, some may learn a glass pane in the front, and so on. the idea is that, irrespective of where the object is in the frame, you should be able to identify the image.
prior to cnn for image detection, you would need to crop the images and provide areas of interest. for instance, if you are detecting various categories of birds, you would usually crop the bird image and remove any surrounding context, like trees, bushes, sea, sky, etc., and provide only the bird image. with cnn, the idea is to train with those images and let the network figure this out (though cropping may help in some cases for increased accuracy). based on my experiments, the cnn is able to predict object most of the time, while having a surrounding context, but with lower accuracy. as mentioned, the idea is to identify objects irrespective of where they are found in the image, and i am sure lot of research is going on to improve cnns. having the right training data (images and label) is a must for training networks with such variations.
above is the stack view of employing a deep learning api on the edge gateway. it consists of the api, the learning model, and the classification service which is used for classification of objects. there are a lot of innovations happening to optimize the use of deep learning libraries on the edge.
so how do you go about implementing this? i will talk about one approach of building this out:
- build your own cnn or start with a pre-trained cnn network (like an inception model).
- get the training and test data (images and labels).
- train or retrain (i.e transfer learning) the network.
- optimize with learning rates, batch size, etc., for the desired accuracy. get the trained model.
- use the trained model for classification.
- deploy the tensorflow api and trained model on the edge (you can package this in docker).
- use the classification code on the edge gateway to detect objects.
Published at DZone with permission of Navveen Balani, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.