How to Change Computer Vision Models in the alwaysAI Platform
In this tutorial, we will show you the steps needed to change the computer vision model in the alwaysAI application. First, set up your development computer and edge device (if you're using one). You should also have an app running like this object detector starter app. You can see more about setting up projects and the alwaysAI workflow here. Finally, you should have a Terminal window open.
If you don't have an alwaysAI account yet, you can sign-up here.
You learned how to run a real-time object detector app on a Raspberry Pi previously in this article. That app uses the MobileNet SSD Caffe model trained on the Pascal VOC dataset which can detect 20 unique objects. We saw that we were able to detect a potted plant in our office. Now, we want a model to detect a potted plant and a vase independently of each other, so we’ll need a different model. To change the computer vision model in your application, head over to the alwaysAI dashboard.
1. Browse the model catalog
From your alwaysAI dashboard, click on your 'projects' tab and navigate to the project of the application you want to change the model for. Select that project and click the '+ New Model' button and then click the option to browse the model catalog.
There you will see the full list of available models.
2. Choose a model to deploy
Next, find the model set you wish to deploy.
Since we're running the real-time object detector app, we can swap in any object detection model regardless of the framework on which it was trained and see how it performs.
Search for 'ssd_mobilenet_v1_coco_2018_01_28', which is the TensorFlow version of MobileNet SSD trained on the Coco dataset. This model can detect 100 unique objects. Let's swap in this model and see how it performs.
To add the model to the app using the CLI:
- Click on the model name in the catalog to open up the model details page. You will see a panel with the CLI and app.py specifications, as in the image below.
- Select the desired project from the dashboard and click 'add to project' .
- Copy the text in the second text box and proceed to the next step.
3. Update the model and re-deploy
To use the new model, update your source code to use the new model and re-deploy the app on the device using the text you copied in the previous step. Replace this line with the copied Model ID:
Then type aai app configure to update your local project with the changes you made on the dashboard. Then, re-deploy the application to install the update:
4. Run the start command
Now that the updated app is deployed, run the start command alwaysai app start
Visit the Streamer link http://localhost:5000 in a browser to see how the updated model performs.
We can see that this model detects the plant and the vase independently.
That's how easy it is to swap out computer vision models in your alwaysAI application.
Try it yourself with our realtime_object_detector starter app.