experiencor / keras-yolo2

Easy training on custom dataset. Various backends (MobileNet and SqueezeNet) supported. A YOLO demo to detect raccoon run entirely in brower is accessible at https://git.io/vF7vI (not on Windows).
MIT License
1.73k stars 787 forks source link

why still need to use conf_mask but not y_true[...,4] #454

Open speeding-motor opened 4 years ago

speeding-motor commented 4 years ago

I m very confused with this, I still read know the loss_code but still don't know why, what directly different with this,

conf_mask = conf_mask + tf.to_float(best_ious < 0.6) * (1 - y_true[..., 4])
conf_mask = conf_mask + y_true[..., 4] (forget to multiply best_ious >0.6 ? )

here compute the pred_box and true_box iou in each picture, and get the best anchor for each per cell prod anchor_box, 1、iou_scores shape = [batch_size, grid_w, grid_h, anchor_num, max_box_per_image], 2、and then use,best_iou = tf.reduce_max(iou_scores, axis=4), get each best iou for each cell, shape =[batch_size, grid_w, grid_h, anchor_num] 3、if the iou <0.6, it means the iou is not enough, so conf_mask[I]=0, if iou >0.6, if means here probability have box, so conf_mask[i]=1

why still need to calculate the conf_mask but not use y_ture[...,4], just like the coord_mask, it's not easy to got is , every little help is very appreciate, thank in advance @experiencor @hobson @mrshu @sirotenko @usatenko

speeding-motor commented 4 years ago

why need to make a distinction between coord_mask, conf_mask, and class_mask , use the y_true[..., 4] directly is work well ,right?

hope to receive you reply, thanks in advance

speeding-motor commented 4 years ago

the code :

class_wt = tf.ones(num_classes)
class_mask = y_true[..., 4] * tf.gather(self.class_wt, true_box_class)     

is total equals to : class_mask = y_true[..., 4] so why still have to do like this, is there other detail I have oversight? it's very appreciate to have any help , thanks in advance

speeding-motor commented 4 years ago

why need to make a distinction between coord_mask, conf_mask, and class_mask , use the y_true[..., 4] directly is work well ,right?

hope to receive you reply, thanks in advance

no, it's not right to use y_true[..., 0] directly, if we do that it more like to random choice some cell to compute the conf_loss, not relative to the y_pred, so it's wrong

speeding-motor commented 4 years ago

maybe use tf.exp(tf.sofrmax(pred[..., 2:4])) instead of tf.exp(pred[..., 2:4]) ?

because tf.exp(pred[..., 2:4]) is always NAN in training

chhluo commented 4 years ago

I m very confused with this, I still read know the loss_code but still don't know why, what directly different with this,

conf_mask = conf_mask + tf.to_float(best_ious < 0.6) * (1 - y_true[..., 4])
conf_mask = conf_mask + y_true[..., 4] (forget to multiply best_ious >0.6 ? )

here compute the pred_box and true_box iou in each picture, and get the best anchor for each per cell prod anchor_box, 1、iou_scores shape = [batch_size, grid_w, grid_h, anchor_num, max_box_per_image], 2、and then use,best_iou = tf.reduce_max(iou_scores, axis=4), get each best iou for each cell, shape =[batch_size, grid_w, grid_h, anchor_num] 3、if the iou <0.6, it means the iou is not enough, so conf_mask[I]=0, if iou >0.6, if means here probability have box, so conf_mask[i]=1

why still need to calculate the conf_mask but not use y_ture[...,4], just like the coord_mask, it's not easy to got is , every little help is very appreciate, thank in advance @experiencor @hobson @mrshu @sirotenko @usatenko

I have the same quesion, please tell me that if you solve the problem.

speeding-motor commented 4 years ago

I m very confused with this, I still read know the loss_code but still don't know why, what directly different with this,

conf_mask = conf_mask + tf.to_float(best_ious < 0.6) * (1 - y_true[..., 4])
conf_mask = conf_mask + y_true[..., 4] (forget to multiply best_ious >0.6 ? )

here compute the pred_box and true_box iou in each picture, and get the best anchor for each per cell prod anchor_box, 1、iou_scores shape = [batch_size, grid_w, grid_h, anchor_num, max_box_per_image], 2、and then use,best_iou = tf.reduce_max(iou_scores, axis=4), get each best iou for each cell, shape =[batch_size, grid_w, grid_h, anchor_num] 3、if the iou <0.6, it means the iou is not enough, so conf_mask[I]=0, if iou >0.6, if means here probability have box, so conf_mask[i]=1 why still need to calculate the conf_mask but not use y_ture[...,4], just like the coord_mask, it's not easy to got is , every little help is very appreciate, thank in advance @experiencor @hobson @mrshu @sirotenko @usatenko

I have the same quesion, please tell me that if you solve the problem.

I stil not got this