Object detection can be used to expedite or automate business processes in multiple industries. In the retail industry, it can be used to expedite the inventory management, allowing retail leaders to focus on on-site customer relationship building. In the manufacturing industry, technicians can use it to speed up the repair process to quickly pull out the manual of a piece of machinery for which the UPC/serial number isn't standing out.
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.
Object detection maps objects to a Common Data Service Entity. To get started we need to create this entity.
Step 1. Log in to Power Apps.
Step 2. Navigate to "Data" and Select Entities and New Entity
Step 3. Create a new Entity.
Step 4. Add a field for inventory total named: aib_inventorytotal as type whole number
Step 5. Navigate to Data to add our products
Step 6. Add our Three Products
Green Tea Rose
Green Tea Cinnamon
Green Tea Mint
Step 7. Verify the data was entered into the entity
In this exercise we will build and train the Object Detection model for three varieties of tea.
In PowerApps maker, expand AI Builder and select Build. Select Object Detection.
Name your model Green Tea Product Detection _Your name and Click create.
Your screen should now look like the image here.
Notice the progress indicator on the left. Those are the steps we will follow now to build and train our model.
We are now going to define the objects we are tracking. Click on the Select object names.
From the entity list, select Object Detection Product.
Select the Name field and click Select field.
Select the tea items and click Next.
Notice the progress indicator has moved forward to the Add images step.
Select images from the set provided. You will need enough images to provide 15 samples for each type of tea we are tracking.
Approve the upload of images. Click Upload images. After the upload completes, click Close.
Click next to begin tagging the images.
Select the first image to begin tagging.
Hover over the image, near an item you wish to tag. A dotted-lined box should appear around the item. It has been detected as a single item that can be tagged.
Click on the item and select the matching object name.
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.
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.
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.
Once you have defined enough tags for training the model, you will be allowed to initiate the training. Click Next.
The training takes a few moments.
Navigate to the saved model view and confirm your model has completed training.
Select the model you just made.
Select Quick test.
Upload or drag and drop one of your test images to be analyzed.
You will see the analysis and level of confidence for the match.
Upload an image you know will not match. You will see the analysis and level of confidence for the match.
Publish your model.
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.
Navigate to Apps, and select Create an app, then select Canvas. If asked, grant permission for the app to use your active CDS credentials.
Select Blank app with Phone layout.
On the maker canvas, select the Insert tab in the ribbon and expand AI Builder. Select Object detector to place this control on your app.
Select the AI model you built.
Resize the control to better use the space.
Make sure to leave room for more items we will be placing soon.
Play your app.
Click on Detect.
Choose one of your test images and click Open.
The image will now be analyzed.
Our model has detected each tea in the image.
Exit the app player.
Bonus exercise- build out the data in your canvas app
We will now select our data source. Select View from the ribbon and select Data Sources.
Click + Add Data Source.
Add the Common Data Service data source. Do not use Common Data Service (current environment).
Select the Object Detection Products entity and click Connect.
Close the Data pane.
With Screen1 selected in the Tree view, navigate to the Insert ribbon tab, expand Gallery and select Blank vertical gallery.
Rename the Gallery productGallery. You are re-naming the gallery so you can reference it from your formulas.
Resize and move the gallery control to fit the available space on the screen, leaving some space at the bottom for using later.
Select the edit icon from the gallery.
Add a label to the gallery.
Click edit again and add a Text input box to the gallery. Resize and place it to line up with the label we've already placed. We will be updating inventory counts in this text box.
Rename the Text Input inventoryInput. You are renaming this control so you can reference it from your formulas.
With focus on the Screen1 in the Tree view, click in the ribbon on Insert and select Button.
Drag and move the button to the bottom of the screen, double click on it to edit the text. Rename it to Update.
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.
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'
Select the label in your gallery. Replace the Text formula with the following:
Select inventoryInput and replace the formula for Default with the following: