In this tutorial, you will build a detection model capable of recognizing dog breeds in video frames.
You will learn how to:
add images and annotations separately,
train your model using the Darknet,
test your detector in real time.
To create the model, use the publicly available Stanford Dogs Dataset, which contains 20,580 images of 120 dog breeds. The dataset consists of images and annotations collected in separate folders.
![Detection result](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_1.jpg)
#Unziping the dataset
The Stanford Dogs Dataset has been saved in two separate archives i.e. Dogs_Images and Dogs_Annotation using the .tar file extension. Although our portal supports such extensions, they cannot be uploaded at the same time, which means that the photos in the dataset will not have annotations. You need to unzip them and upload them as a data directory. To do this, you can use programs such as 7-Zip or WinRAR.
![Unziping directories](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_2.jpg)
If you are using 7-Zip to unzip the file, expand the context menu by right-clicking on the file and select the Extract Here
option located under the 7-Zip menu.
Keep in mind: This tutorial shows only one of the ways to deal with this problem. Depending on your system and the program you are using, the options may be different.
#Adding the dataset
In the Owned datasets
section, click Add new dataset
and create a new collection named my_dogs
.
![Create dataset](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_3.jpg)
Click Add directory
to load the directory containing the images and annotations.
![Upload view](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_4.jpg)
Wait for the site to validate the uploaded directory.
![Validation process](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_5.jpg)
In the thumbnails, you will see the images with the added annotations. Once the directory is loaded, click Upload
.
![Upload directory](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_6.jpg)
You can add object annotations for detection in Pascal VOC format (.xml extension files). The image and the annotation file must have the same name - only then you can link the annotation information in the image to the image itself.
Keep in mind: You can merge the two directories for the selected dog breed into one directory yourself, or add the images and annotation directories in two steps during the upload phase. The order in which you upload is not important.
To add directories separately, click Add directory
and select the subdirectory Images
.
![Directory tree](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_7.jpg)
Click Upload
to load the Images
subdirectory.
![Images added](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_8.jpg)
To add annotations, use Add directory
again. Select the Annotations
subdirectory.
![Validation process](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_9.jpg)
Wait for the site to validate the uploaded annotations and pair them with the already-owned images. You will see the images with the added annotations in the thumbnails.
![Annotations added](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_10.jpg)
Once the subdirectories are loaded, click Upload
.
#Creating the model
To create the model, go to the Models section
and click Add new model
. Select Detection.
![Add new model](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_11.jpg)
Select the my_dogs
dataset to use to train the model.
![Choose datasets and categories](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_12.jpg)
The next step is to merge the categories. You can manage the categories of images within the dataset. This option is described in much more detail in the Creating and training models article. In this tutorial it is not necessary to change anything, so continue by clicking Next
.
![Merge categories](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_13.jpg)
Now you need to parameterize the model. Enter the name Dog Breed Detector
and select the Darknet
framework.
![Set model parameters](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_14.jpg)
Accept the default settings or change them to your liking in Basic
and/or Advanced
mode tab. Click Start training
.
![Set model parameters](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_15.jpg)
You can view the training process in the Dashboard
view, in the Notifications
tab, or in the Models
section.
![Dashboard view](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_16.jpg)
When the training is complete, convert the model so that it is compatible with NVIDIA Jetson Nano. To do this, go to the Models
section, hover over the gear icon, and select Details
.
![Select details](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_17.jpg)
In the Conversion
section select the NVIDIA MAXWELL architecture.
![Select hardware](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_18.jpg)
#Testing your idea
Once the conversion is complete, go to the Live Testing
tab and select Jetson Nano
.
![Select Jetson Nano](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_19.jpg)
This will open a new browser tab with a test web app (Artificial Intelligence Device Web Service) that will run on your device. Your model will be available for download to the device.
![Model list in web app](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_20.jpg)
Click on the model tile to download and run the model. Now you can upload the input data that we will use to test your model. To do this, click the Upload file
button.
![Upload file](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_21.jpg)
Select the files you want to upload.
![Select file](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_22.jpg)
If you input the data as a video, the web app will open a built-in video player. There you will see notifications about the progress of the second stage of model conversion - this only happens on the first run.
![Create engine](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_23.jpg)
In the video you will watch in the player, you will see the breed tags assigned to the dogs that the model managed to find.
#Results
This is what a frame of the model's work looks like in the test application's media player:
![Video result](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_24.jpg)
The results in uploaded photos are similar:
![Image result](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_25.jpg)
![Image result](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_26.jpg)
![Image result](https://docs.onestepai.com/static/tutorials/advanced/dog_breed_detector/dog_breed_detector_27.jpg)