02 - Object Detection
02 - Object Detection
Object detection lets you count, locate, and identify selected objects within any image. You can use this
model in PowerApps to extract information from pictures you take with the camera, or load into an app.
In this lab, we will build and train a detection model and build an app that uses the detection model to
identify objects from available images.
Note: If you are building the first model in an environment, click on Explore Templates to get started.
Exercise 1
In this exercise we will build and train the Object Detection model for three varieties of tea.
1. In PowerApps maker, expand AI Builder and select Build. Select Object Detection.
2. Name your model Green Tea Product Detection and because you are working in a shared
environment also make sure to include your name as part of the model name. This will make it
easier to find later. Click create.
3. Your screen should now look like the image here.
4. Notice the progress indicator on the left. Those are the steps we will follow now to build and
train our model.
5. We are now going to define the objects we are tracking. Click on the Select object names.
9. Notice the progress indicator has moved forward to the Add images step.
10. Click add images.
11. Select images from the set provided. You will need enough images to provide 15 samples for
each type of tea we are tracking.
12. Approve the upload of images. Click Upload images. After the upload completes, click Close.
13. Click next to begin tagging the images.
16. Click on the item and select the matching object name.
17. If the pre-defined selector is not accurate, as in the below example, you can drag the container
to draw it to accurately tag the item.
18. Do this for each item in the image and for each image in your set. When you have tagged all of
the images you uploaded click Done Tagging in the top right of the screen.
19. Once you have completed tagging, you will get a summary of the tags. If you haven’t tagged
enough for analysis, you will need to load and tag more examples.
20. Once you have defined enough tags for training the model, you will be allowed to initiate the
training. Click Next.
21. Click Train.
27. You will see the analysis and level of confidence for the match.
28. Upload an image you know will not match. You will see the analysis and level of confidence for
the match.
Exercise 2
We will now create a canvas app you can use for detecting the items that have been trained in our
model. The product will be detected from the image and you will be able to adjust on-hand inventory
for the item.
1. Navigate to Apps, and select Create an app, then select Canvas. If asked, grant permission for the
app to use your active CDS credentials.
1. We will now select our data source. Select View from the ribbon and select Data Sources.
7. Rename the Gallery productGallery. You are re-naming the gallery so you can reference it from your
formulas.
8. Resize and move the gallery control to fit the available space on the screen, leaving some space at
the bottom for using later.
9. Select the edit icon from the gallery.
12. Rename the Text Input inventoryInput. You are renaming this control so you can reference it from
your formulas.
13. With focus on the Screen1 in the Tree view, click in the ribbon on Insert and select Button.
14. Drag and move the button to the bottom of the screen, double click on it to edit the text. Rename it
to Update.
15. We will now add the user message to give the user confirmation their submission was accepted; we
will define this logic later. With focus on Screen1, insert a label, drag it to the bottom of the screen.
16. We will now add logic to the controls we’ve placed on the screen. Select the Gallery and replace
the Items formula with the following.
'Object Detection Products'
17. Select the label in your gallery. Replace the Text formula with the following:
ThisItem.Name
18. Select inventoryInput and replace the formula for Default with the following:
LookUp('Object Detection Products',Name = ThisItem.Name).'Inventory Total'
19. Select the other label (the one that shows at the bottom of the screen) and replace its text with the
following:
usermessage
20. You’ll notice that area now looks blank. We will configure that message in our next step.
21. Select the button control and replace the OnSelect with the following:
ForAll(productGallery.AllItems,Patch('Object Detection Products',LookUp('Object
Detection Products',Name=DisplayName),{'Inventory
Total':Value(inventoryInput.Text)}));Set(usermessage,"Updated " &
CountRows(productGallery.AllItems) & " items")
25. Update the quantity for the correct product and click Update.
26. The bottom should show a message now.