Computer Vision With Python
By: Dogan Technologies
Tags: Machine Learning, Deep Learning, Data Science, Data, Data Visualization

Computer vision is a scientific field that deals with how computers can be made to gain a high-level understanding from digital images or videos. New advancements in Deep Learning have made it possible to train models much more efficiently. We can detect objects in an image while simultaneously generating a high-quality segmentation mask for each instance. The method, called Mask R-CNN, extends Faster R-CNN by adding a branch for predicting an object mask in parallel with the existing branch for bounding box recognition.

It is a convolutional neural network that shares properties with the RCNN, in that it saves time by dividing an image into regions and searching those for what it believes may be relevant objects. We can mark those objects by drawing a bounding box around any detected objects. The Mask RCNN takes this one step further by drawing what is called a mask over the object. This mask is a semi-transparent silhouette that the network draws within the bounding box to highlight the detected object. Users must first install the repository below and install the required packages with pip.

GitHub: https://github.com/matterport/Mask_RCNN

Requirements: Python 3.4, TensorFlow 1.3, Keras 2.0.8 and other common packages listed in requirements.txt .

For this project, we used the Home Objects dataset from Caltech. This and other vast datasets for computer vision can be found in their archives here. Once you have collected your dataset, it must be annotated so that it can be used for training. The University of Oxford has a handy web tool for annotating images for computer vision tasks such as this and it can be found here. The VIA tool saves the annotations in a JSON file, and each mask is a set of polygon points. Also provided is a downloadable version and tutorials on how to use the annotator for images, video, and audio. Once your model is trained, do not forget to check its accuracy. The GitHub has Jupyter notebook examples that will show you how to display your model’s detections.

Validation with Tensorboard

In summary, to train the model on your own dataset you’ll need to extend two classes:

Config This class contains the default configuration. Subclass it and modify the attributes you need to change.

Dataset This class provides a consistent way to work with any dataset. It allows you to use new datasets for training without having to change the code of the model. It also supports loading multiple datasets at the same time, which is useful if the objects you want to detect are not all available in one dataset.

See examples in samples/shapes/train_shapes.ipynb , samples/coco/coco.py , samples/balloon/balloon.py , and samples/nucleus/nucleus.py .

After you validate the accuracy of your model, then you can move on to testing the model with live and/or recorded footage. Using the OpenCV library, you can utilize your trained model and test it with your webcam or a video file on your computer.

Dogan AI provides Computer Vision Consulting to clients all around the world. If you are interested in implementing AI please do not hesitate to contact us.

E-Mail: john@dogan.ai

Website: www.dogan.ai

Written By Matthew Lopez