Wednesday, November 24, 2021

Find objects from Images using computer/custom vision with simple flow

Find objects from Images — Simple flow

Azure Cognitive Services Computer Vision and Custom Vision

Use Computer vision to identify objects in an image

Use Case

  • Identify objects in an image which are common in a range of scenarios
  • Check for condition on objects detected For Example if certain objects are present in an image
  • Use Custom vision to detect more custom objects
  • use other cognitive services to infuse AI into the process
  • Event based

Architecture

BalamuruganBalakreshnan_0-1637418644770.jpeg

 

Logic Flow

BalamuruganBalakreshnan_1-1637418677795.jpeg

 

BalamuruganBalakreshnan_2-1637418677778.jpeg

 

BalamuruganBalakreshnan_3-1637418677753.jpeg

 

Code

  • Configure Azure Storage
BalamuruganBalakreshnan_4-1637418677916.jpeg

 

  • Now sent to Analyze image
BalamuruganBalakreshnan_5-1637418677903.jpeg

 

  • Delete existing files
BalamuruganBalakreshnan_6-1637418677922.jpeg

 

  • Save the output
BalamuruganBalakreshnan_7-1637418677891.jpeg

 

  • Parse JSON
BalamuruganBalakreshnan_8-1637418677842.jpeg

 

{
"properties": {
"categories": {
"items": {
"properties": {
"detail": {
"properties": {
"celebrities": {
"type": "array"
}
},
"type": "object"
},
"name": {
"type": "string"
},
"score": {
"type": "number"
}
},
"required": [
"name",
"score",
"detail"
],
"type": "object"
},
"type": "array"
},
"description": {
"properties": {
"captions": {
"items": {
"properties": {
"confidence": {
"type": "number"
},
"text": {
"type": "string"
}
},
"required": [
"text",
"confidence"
],
"type": "object"
},
"type": "array"
},
"tags": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"faces": {
"items": {
"properties": {
"age": {
"type": "integer"
},
"faceRectangle": {
"properties": {
"height": {
"type": "integer"
},
"left": {
"type": "integer"
},
"top": {
"type": "integer"
},
"width": {
"type": "integer"
}
},
"type": "object"
},
"gender": {
"type": "string"
}
},
"required": [
"age",
"gender",
"faceRectangle"
],
"type": "object"
},
"type": "array"
},
"metadata": {
"properties": {
"format": {
"type": "string"
},
"height": {
"type": "integer"
},
"width": {
"type": "integer"
}
},
"type": "object"
},
"modelVersion": {
"type": "string"
},
"objects": {
"items": {
"properties": {
"confidence": {
"type": "number"
},
"object": {
"type": "string"
},
"parent": {
"properties": {
"confidence": {
"type": "number"
},
"object": {
"type": "string"
}
},
"type": "object"
},
"rectangle": {
"properties": {
"h": {
"type": "integer"
},
"w": {
"type": "integer"
},
"x": {
"type": "integer"
},
"y": {
"type": "integer"
}
},
"type": "object"
}
},
"required": [
"rectangle",
"object",
"confidence"
],
"type": "object"
},
"type": "array"
},
"requestId": {
"type": "string"
},
"tags": {
"items": {
"properties": {
"confidence": {
"type": "number"
},
"name": {
"type": "string"
}
},
"required": [
"name",
"confidence"
],
"type": "object"
},
"type": "array"
}
},
"type": "object"
}
 
  • Set the condition
BalamuruganBalakreshnan_9-1637418677848.jpeg

 

  • If True then send to custom vision
  • Send to custom vision
BalamuruganBalakreshnan_10-1637418677870.jpeg

 

  • Delete existing files
BalamuruganBalakreshnan_11-1637418677877.jpeg

 

  • Save the data to blob as json
BalamuruganBalakreshnan_12-1637418677818.jpeg

 

Original article Samples2021/computervision1.md at main · balakreshnan/Samples2021 (github.com)

 

Posted at https://sl.advdat.com/30W3ddm