Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
let lineItems = []
let i = 0
/* To generate two empty rows */
while(i < 2) {
    lineItems.push({
        "weight": "",
        "unit": ""
      })
      i += 1
  }
/* Variant is the field name */
if(Array.isArray(lineItems)){
  this.changeFormValue("Variant", JSON.stringify(lineItems))
}
  1. Calculation IOU at level 3 for rejection logic

Code Block
languagejs
if(currentUserLevel == 3) {
  let totalIOU = 0
  let totalAnnotations = annotations.length
  
  for (let step = 0; step < totalAnnotations; step++) {
    // Current level annotation points for a box
    let ann1 = annotations[step]["points"]
    // Get previous level annotation points for the same box
    let ann2 = JSON.parse(initialValues["Annotations"])[step]["points"]
    
    let x1 = ann1[0][0]
    let x2 = ann1[2][0]
    let x3 = ann2[0][0]
    let x4 = ann2[2][0]
    
    let y1 = ann1[0][1]
    let y2 = ann1[2][1]
    let y3 = ann2[0][1]
    let y4 = ann2[2][1]
    
    let x_inter1 = Math.max(x1, x3)
    let x_inter2 = Math.min(x2, x4)
    
    let y_inter1 = Math.max(y1, y3)
    let y_inter2 = Math.min(y2, y4)
    
    console.log(x_inter1, y_inter2)
    let width = x_inter2 -x_inter1
    let height = y_inter2 - y_inter1
    
    let area_inter = width * height
    
    let width_box1 = x2 - x1
    let width_box2 = x4 - x3
    let height_box1 = y2 - y1
    let height_box2 = y4 - y3
    
    let area_box1 = width_box1 * height_box1
    let area_box2 = width_box2 * height_box2
    let area_union = area_box1 + area_box2 - area_inter
    let iou = area_inter / area_union
    totalIOU = totalIOU + iou
  }
  
  //Average IOU between level 3 and previous level annotations
  let avgIOU = totalIOU/totalAnnotations
  
  if (avgIOU < 0.90) {
    alert("IOU dropped below 0.9")
  }
}