Custom object detection with Customvision.ai and using trained model on Android device

Computer Vision from the Cognitive service is the way to find meaning in the image, but what to do when we have to find our own custom object?
How to create our own model to find our custom object?

If you are looking for a simplest way, then Microsoft customvision.ai is the one to look for.
Just head over to below link & register yourself.

https://customvision.ai/




The Custom Vision Service is an Azure Cognitive Service that lets you build custom image classifiers. It makes it easy and fast to build, deploy, and improve an image classifier.

Once you are registered with custom vision, you can create 2 projects for free.
Create a new project. Use "Classification" as Project Type, "MultiClass (Single tag per image)" as Classification type (I am using images with only single object in it) and "General (Compact)" as Domain for leaner model for Mobile device use.
Refer below image for reference.


Now upload the images & provide a tag like "londonBusCoffeeMug".


Next step is to train our model for the images.
Just hit the Train button on the top.
Here is the training performance. (impressive to see 100% Precision & 100% Recall 😏)
We can do a quick prediction using the Predictions tab, or export the model to see in action in a mobile app. I will do the later here.
Customvision give option to export the trained model in CoreML, TensorFlow or ONNX format.



I will export to TensorFlow to use in the Android App. The exported tensorflow model contains model.pb & labels.txt, the Model & Labels respectively.

Now we have our model ready, so lets test it on Android device. (I expect you have android studio configured on your machine)
Here is a sample app from Microsoft where we can put our model & test.

https://github.com/Azure-Samples/cognitive-services-android-customvision-sample

Or do a git clone from https://github.com/Azure-Samples/cognitive-services-android-customvision-sample.git

Once you have got the sample application cloned, just replace the model.pb & labels.txt from the apps assets folder.
Now just build & run the application on a device.

If you give some image which resembles to the object we trained our model on, then it should give proper object name in the pink box as below.


Hope this help in creating your custom object detection & testing on device.


Happy Coding,
Parshuram

Comments

Unknown said…
Great walkthrough!!!
Parshuram said…
Thanks Pankaj.

Popular posts from this blog

6000 KM Road Trip

Export MS Access report to Excel..Font Problem

Testing AWS Rekognition from POSTMAN