Tuesday, December 5, 2023

Detects Nails or Screws using AI Models

With power automate now you can build your own AI model's and you can use those models into Flows or power apps. 

You can build different AI models like extracting information from Shipping Receipts  or detect sentiment in text or Predict future outcomes from historic data or Detect custom objects in images. 

Here I am going to explain how to create AI model to detect custom objects (Nails or Screws ) in custom images. 

To create AI model you have to start from https://make.powerapps.com/

In Power apps you will find AI Models / AI hubs left side menu.. if it is not there then look into More options. 


Then from AI models select Images --> Detect custom objects in Images


Once you Click on Detect custom objects in Images, you will get option to create custom model.

Now Start creating custom model. 

1. Select one model domain from based on your requirement
      a. Common objects  - anything like Dorne, cats or animals, Car etc.
      b. Objects on retail shelves - Items on shelf like shampoo, soap, electronics etc. 
      c. Brand logos  - company logos 

For my model I used common objects

2. Then you need to list which objects you wan to detect in images. Based on number of objects you want to detect you need to provide number of images to train you AI model. 


3. Now you need to upload images for your object. 
     At least 15 images are required per object. If there are multiple objects in single image then image is counted for multiple objects. 
For better AI model try to load images with different agnel, light or by different object size. 

4. When you done with uploading images, you need to tag objects in images 

You can only draw square or rectangles to select objects. So try to select whole object in images and try to avoid other objects to be tagged. 

If there are multiple objects then upload only one objects images one time and tag them and repeat process for another object.. so that you will easily tag correct object. 

 
Once all tagging is done you are ready to train your AI model.

5. Train AI Model
  Based on images and objects in images, AI model will take time to train. 

Once AI model is trained you can see performance of AI model. Performance is provided based on data provided and how accurate model will detect object. 

6. Quick Test

Once AI model is trained you can test your Model 

From Model home page, you can do quick test for your Model.


7. Re-train or Editing model. 
If your model is not detecting object as expected you can re-train your AI model by providing additional images. 
sometimes if additional images are not good or not correctly tagged objects, retraining may not increase performance of AI model. 




Wednesday, November 18, 2020

MS Flow to update records in D365 CRM

 

Recently we had a requirement to add one new flag in Product entity. Once flag added, I need to update some of the products based on some criteria. But to update products either I need to open each product and update flag or need to find some another way. So, I thought of writing my first power automation flow.

This is just one-time update job, so I created manually trigger flow.

In this flow I used fetch xml query to pull products which I want to update and used for each (Apply to Each) loop to update product.

  •    Start creating flow from blank

·       In Manual trigger a flow, I used to Yes/No input for just confirmation about executing flow.



  •     So far, we are not connected to Common data service. To pull data from D365, you need to connect to D365 using common Data Service and choose environment.   Once Connected to D365, use List Records Action in Common Data Service.



    ·       For List Records Action you need to specify Entity name and there are different options to retrieve records. I used FetchXml.



    ·       Now there are many records and need to update one by one. When using workflow in D365 CRM we cannot update one-by one record in single workflow until we write some custom code. But now in power automation you can using basic loops like Apply to Each.



    ·       Apply to Each loop is a For Each loop.  Which will give you each item. Here we are pulling products and passing to Loop, so need to get each product. In Select an output from previous steps, select list value. Which is a single product value.



    ·       Now we need to work in Loop. Click add Action in Loop and use Common Data Service  à Update Record.

    ·       In Update Record action, use entity name as Product and then Item Id will be Product Unique Identifier. And then need to set attributes whose values need to be updated.



Complete flow will look like





Monday, October 12, 2020

Model Driven App - Script Error

 Recently during some development, I came across one strange error. One user was getting script error when trying to access connection entity form. 

On connection entity, I added some JavaScript code to filter connection from lookup to limit only for Users and Teams. 

JavaScript Code is working fine when I tried to debug issue. 

After doing some more debugging, I realized user is using different app and that app does not have access to Team entity. 

 Once added Team entity into App, error Fixed, and script worked as designed. 

When designing Model Driven App for consider 

 1. When using JavaScript code to filter lookups to specific entity, specially customer lookup, connection entity from / to lookups, make sure entities used in filter are added in App. 

2. When using JavaScript code to redirect to specific form based on value change / option set change, make sure all forms added in App. 

3.  If entity is using Quick create form, then make sure quick create forms added in App otherwise default main form will be used to create record