In this guide, we’ll be focusing on bird classification. What is image classification? It is a technique used in computer vision to identify and categorize the main content in a photo or video.
We provide a set of open-source pre-trained models in our Model Catalog. The following example uses one of our starter models with a simple algorithm to achieve its goal.
Image classification app
To get a sense of how image classification works, we’ll create a simple example application in which uploaded photos of birds are analyzed and the app automatically identifies the type of bird in the photo. We can create this bird classification app by building upon the alwaysAI image_classifier starter app, which already has a lot of the functionality that we need.
First, install alwaysAI onto your development computer and download all of the starter apps:
$ aai get-starter-apps
Now let’s try running the image classifier app to see what it produces. You can run the app right on your computer, or you can run it on a supported edge device. We’re using Linux for this example, and we’ll choose “Your local computer” for the deployment option, and the default settings for the rest. Run the following commands and then click on the http://localhost:5000 link that appears in your terminal (after successfully starting the app) to open the Streamer window:
$ cd alwaysai-starter-apps/image_classifier
$ aai app install
$ aai app start
As you can see, the classifier is performing inferencing on pictures of various items and animals, and the classification is then written onto the photo.
Choosing a model
Next, we’ll need to search for a computer vision image classification model in the alwaysAI model catalog that has been trained to recognize many different kinds of birds classification.
To do this, we can simply visit the catalog and enter various things that we want our model to recognize in the search box. Let’s type in “finch,” “bald eagle,” and “owl” to see what we get.
The model that appears first is the shufflenet_1x_g3 model, and when I click “See more,” I can see that the labels match our use case since it can detect quite a large variety of birds classification.
The model catalog orders models by inference time, and since this model has an inference time of 38 milliseconds, which is about 25 frames per second (FPS), we can expect that our application will be relatively performant.
Adding images and the new model
Next, we’ll add some photos of birds that we want to identify to our images directory, and switch the model that we’re using in our app. To add the new model, run this command in the terminal:
$ aai app models add <model name>
Where <model name> in this case will be alwaysai/shufflenet_1x_g3.
And to remove the old model, run:
$ aai app models remove <model name>
The second part of changing the model is to open the app.py file in the image_classifier starter app and paste the new model in the code at the beginning of the function.
Code before change:
classifier = edgeiq.Classification("alwaysai/googlenet")
Code after change:
classifier = edgeiq.Classification("alwaysai/shufflenet_1x_g3")
After replacing the current images with images of birds, we can run the app again to see what we get.
$ aai app install
$ aai app start
As you can see, our updated app is correctly identifying birds, including this great grey owl:
We’ve walked through a simple example of building upon our image classification starter app by changing the model and the images used by the application. You can expand this process to many different computer vision use cases that involve identifying, filtering, and sorting.
Creating a working application that incorporates computer vision is easier than ever before with the software we provide. We give developers access to pre-trained computer vision models along with basic starter applications for various tasks, including object detection, image classification, pose estimation and more — simplifying what was previously an arduous and lengthy process for developers. We can’t wait to see what you build with alwaysAI!