parameters: (box, gt_box)
return_statement: return result
docstring: Compute refinement needed to transform box to gt_box.
      box and gt_box are [N, (y1, x1, y2, x2)]
docstring_summary: Compute refinement needed to transform box to gt_box.
      box and gt_box are [N, (y1, x1, y2, x2)]
docstring_tokens: Compute refinement needed to transform box to gt_box . box and gt_box are [ N ( y1 x1 y2 x2 ) ]
function: def box_refinement_graph(box, gt_box):
      """Compute refinement needed to transform box to gt_box.
      box and gt_box are [N, (y1, x1, y2, x2)]
      """
      box = tf.cast(box, tf.float32)
      gt_box = tf.cast(gt_box, tf.float32)
  
      height = box[:, 2] - box[:, 0]
      width = box[:, 3] - box[:, 1]
      center_y = box[:, 0] + 0.5 * height
      center_x = box[:, 1] + 0.5 * width
  
      gt_height = gt_box[:, 2] - gt_box[:, 0]
      gt_width = gt_box[:, 3] - gt_box[:, 1]
      gt_center_y = gt_box[:, 0] + 0.5 * gt_height
      gt_center_x = gt_box[:, 1] + 0.5 * gt_width
  
      dy = (gt_center_y - center_y) / height
      dx = (gt_center_x - center_x) / width
      dh = tf.log(gt_height / height)
      dw = tf.log(gt_width / width)
  
      result = tf.stack([dy, dx, dh, dw], axis=1)
      return result
function_tokens: def box_refinement_graph ( box , gt_box ) : box = tf . cast ( box , tf . float32 ) gt_box = tf . cast ( gt_box , tf . float32 ) height = box [ : , 2 ] - box [ : , 0 ] width = box [ : , 3 ] - box [ : , 1 ] center_y = box [ : , 0 ] + 0.5 * height center_x = box [ : , 1 ] + 0.5 * width gt_height = gt_box [ : , 2 ] - gt_box [ : , 0 ] gt_width = gt_box [ : , 3 ] - gt_box [ : , 1 ] gt_center_y = gt_box [ : , 0 ] + 0.5 * gt_height gt_center_x = gt_box [ : , 1 ] + 0.5 * gt_width dy = ( gt_center_y - center_y ) / height dx = ( gt_center_x - center_x ) / width dh = tf . log ( gt_height / height ) dw = tf . log ( gt_width / width ) result = tf . stack ( [ dy , dx , dh , dw ] , axis = 1 ) return result