EAST icon indicating copy to clipboard operation
EAST copied to clipboard

Has anybody implement QUAD method?

Open jjprincess opened this issue 6 years ago • 11 comments

I've tried to do QUAD method in this paper,can anybody help me ,thank you very much!

jjprincess avatar Jul 02 '18 11:07 jjprincess

I have implemented quad mode, predict the offset relative to each positive pixel, use the smooth L1 loss

Yuanhang8605 avatar Jul 13 '18 12:07 Yuanhang8605

@Yuanhang8605 Can I read your code for some reference? I've tried to implement it with caffe,and also used smooth L1 loss,but the normalization factor used was diffirent with the paper.I got high loss,and struggled to fix it.

jjprincess avatar Jul 14 '18 02:07 jjprincess

@jjprincess, here is my tensorflow code :

  def _localization_loss(self, pred_geo_map, 
                         gt_geo_map, gt_score_map):
    """Cal the localization loss. 
    """
    # the point order: x1, y1, x2, y2, x3, y3, x4, y4
    # smooth_L1 loss. 
    gt_geo_map = gt_geo_map / float(self._text_scale)     # I set _text_scale = 50 to shrink the gt_geo_map. 
    gt_min_edge = gt_geo_map[:, :, :, -1]
    gt_min_edge = tf.expand_dims(gt_min_edge, 3)
    diff = pred_geo_map - gt_geo_map[:, :, :, :-1]

    abs_diff = tf.abs(diff)
    abs_diff_lt_1 = tf.less(abs_diff, 1)
    L_g = tf.where(abs_diff_lt_1, 0.5 * tf.square(abs_diff), abs_diff - 0.5) 
    L_g = L_g / gt_min_edge
    L_g = tf.reduce_mean(L_g, axis=3)

Yuanhang8605 avatar Jul 24 '18 08:07 Yuanhang8605

@Yuanhang8605 Thanks, I has implemented this with caffe too.^_^

jjprincess avatar Jul 27 '18 02:07 jjprincess

@jjprincess I also got very high loss using NQ* mentioned in the paper, can you share your code for my reference? @Yuanhang8605 Do you shrink by self._text_scale to fix this?

xuannianc avatar Feb 18 '19 03:02 xuannianc

@jjprincess, here is my tensorflow code :

  def _localization_loss(self, pred_geo_map, 
                         gt_geo_map, gt_score_map):
    """Cal the localization loss. 
    """
    # the point order: x1, y1, x2, y2, x3, y3, x4, y4
    # smooth_L1 loss. 
    gt_geo_map = gt_geo_map / float(self._text_scale)     # I set _text_scale = 50 to shrink the gt_geo_map. 
    gt_min_edge = gt_geo_map[:, :, :, -1]
    gt_min_edge = tf.expand_dims(gt_min_edge, 3)
    diff = pred_geo_map - gt_geo_map[:, :, :, :-1]

    abs_diff = tf.abs(diff)
    abs_diff_lt_1 = tf.less(abs_diff, 1)
    L_g = tf.where(abs_diff_lt_1, 0.5 * tf.square(abs_diff), abs_diff - 0.5) 
    L_g = L_g / gt_min_edge
    L_g = tf.reduce_mean(L_g, axis=3)

Hi @Yuanhang8605 , can you share your code for quad box? i has implemented but got the high loss, seem it not working

uname0x96 avatar Jun 12 '19 10:06 uname0x96

@jjprincess, here is my tensorflow code :

  def _localization_loss(self, pred_geo_map, 
                         gt_geo_map, gt_score_map):
    """Cal the localization loss. 
    """
    # the point order: x1, y1, x2, y2, x3, y3, x4, y4
    # smooth_L1 loss. 
    gt_geo_map = gt_geo_map / float(self._text_scale)     # I set _text_scale = 50 to shrink the gt_geo_map. 
    gt_min_edge = gt_geo_map[:, :, :, -1]
    gt_min_edge = tf.expand_dims(gt_min_edge, 3)
    diff = pred_geo_map - gt_geo_map[:, :, :, :-1]

    abs_diff = tf.abs(diff)
    abs_diff_lt_1 = tf.less(abs_diff, 1)
    L_g = tf.where(abs_diff_lt_1, 0.5 * tf.square(abs_diff), abs_diff - 0.5) 
    L_g = L_g / gt_min_edge
    L_g = tf.reduce_mean(L_g, axis=3)

Hi @Yuanhang8605 , can you share your code for quad box? i has implemented but got the high loss, seem it not working

Hi bro,, i am trying to implement QUAD geometry for this tensorflow EAST code. can you share your working code with me ?

Adnan-annan avatar Nov 04 '19 15:11 Adnan-annan

@Yuanhang8605 Thanks, I has implemented this with caffe too.^_^

Hi bro how did you fix the high loss problem ?

Adnan-annan avatar Nov 04 '19 15:11 Adnan-annan

@jjprincess, here is my tensorflow code :

  def _localization_loss(self, pred_geo_map, 
                         gt_geo_map, gt_score_map):
    """Cal the localization loss. 
    """
    # the point order: x1, y1, x2, y2, x3, y3, x4, y4
    # smooth_L1 loss. 
    gt_geo_map = gt_geo_map / float(self._text_scale)     # I set _text_scale = 50 to shrink the gt_geo_map. 
    gt_min_edge = gt_geo_map[:, :, :, -1]
    gt_min_edge = tf.expand_dims(gt_min_edge, 3)
    diff = pred_geo_map - gt_geo_map[:, :, :, :-1]

    abs_diff = tf.abs(diff)
    abs_diff_lt_1 = tf.less(abs_diff, 1)
    L_g = tf.where(abs_diff_lt_1, 0.5 * tf.square(abs_diff), abs_diff - 0.5) 
    L_g = L_g / gt_min_edge
    L_g = tf.reduce_mean(L_g, axis=3)

Hi bro. could you guide me where in multigpu_train.py i need to adjust this code for QUAD ?

Adnan-annan avatar Nov 09 '19 06:11 Adnan-annan

@Yuanhang8605 Thanks, I has implemented this with caffe too.^_^

How to modify the geometry map generation for QUAD?

Adnan-annan avatar Dec 02 '19 06:12 Adnan-annan

@jjprincess, here is my tensorflow code :

  def _localization_loss(self, pred_geo_map, 
                         gt_geo_map, gt_score_map):
    """Cal the localization loss. 
    """
    # the point order: x1, y1, x2, y2, x3, y3, x4, y4
    # smooth_L1 loss. 
    gt_geo_map = gt_geo_map / float(self._text_scale)     # I set _text_scale = 50 to shrink the gt_geo_map. 
    gt_min_edge = gt_geo_map[:, :, :, -1]
    gt_min_edge = tf.expand_dims(gt_min_edge, 3)
    diff = pred_geo_map - gt_geo_map[:, :, :, :-1]

    abs_diff = tf.abs(diff)
    abs_diff_lt_1 = tf.less(abs_diff, 1)
    L_g = tf.where(abs_diff_lt_1, 0.5 * tf.square(abs_diff), abs_diff - 0.5) 
    L_g = L_g / gt_min_edge
    L_g = tf.reduce_mean(L_g, axis=3)

I think these two lines just gives the last value y4 instead of smallest edge. Please correct me if I am wrong. gt_min_edge = gt_geo_map[:, :, :, -1] gt_min_edge = tf.expand_dims(gt_min_edge, 3)

ankschin avatar May 21 '21 23:05 ankschin