0

issue 1: How to take arbitrary number of bounding box for image ? is it recommended to take 1 bounding boxes for image and do same for all bounding box ?

issue 2: I am struggling the custom loss function, so far I have come is this

def assymetric_loss(bboxes):
  def custom_loss(input_images,recons_images):
    batch_size=input_images.get_shape().as_list()[0]
    bbox_size=input_images.get_shape().as_list()[1]
    losses=[]
    for i in range(20):
      input_image=input_images[i]
      recons_image=recons_images[i]
      bbox=bboxes[i]  
      #condition = tf.placeholder(tf.int32, shape=[], name="condition")
      if bbox_size != None:   
        bbarea_input_image=create_mask_from_bounding_boxes(input_image, bbox)
        bbarea_recons_image=create_mask_from_bounding_boxes(recons_image, bbox)
        square = tf.square(tf.subtract(bbarea_input_image, bbarea_recons_image))
        reconstruction_error_bbarea=tf.reduce_sum(square)

        nonbbx_area_input_image    = create_inverse_mask_from_bounding_boxes(input_image, bbox)
        nonbbx_area_recons_image  = create_inverse_mask_from_bounding_boxes(recons_image, bbox)    
        square2 = tf.square(tf.subtract(nonbbx_area_input_image, nonbbx_area_recons_image))
        reconstruction_error_nonbbx=tf.reduce_sum(square2)
        total_loss=tf.add(reconstruction_error_bbarea,reconstruction_error_nonbbx)
        #loss=reconstruction_error_bbarea+reconstruction_error_nonbbx
        losses.append(tota_loss) 
      else:
        square3 = tf.square(tf.subtract(input_image,recons_image))
        reconstruction_loss=tf.reduce_sum(square3)
        losses.append(reconstruction_loss)
    loss = tf.stack(losses)
    return loss      
  return custom_loss

Note: i am assuming batch size as 20

some guidance will help Thanks

rakeshKM
  • 53
  • 6
  • Try including the error which you are facing. – Shubham Panchal Jun 19 '20 at 14:24
  • Hi Shubham, I have moved little forward from this step,check out this question for more detail code and explanation, https://stackoverflow.com/questions/62468956/why-am-i-getting-none-gradient-error-in-keras-custom-loss-function – rakeshKM Jun 19 '20 at 14:29

0 Answers0