kentaroy47 / frcnn-from-scratch-with-keras

:collision:Faster R-CNN from scratch written with Keras
Apache License 2.0
168 stars 107 forks source link

Mistake in positive anchor box calculation (calc_rpn in data_generator.py) #86

Open RohanUBagewadi opened 4 years ago

RohanUBagewadi commented 4 years ago

In calc_rpn function of data_generator.py. The width(anchor_x ) and height (anchor_y) for the anchor boxes are calculated based on (self.anchor_box_scales, self.anchor_box_ratios) in config.py file and these values corresponds to the original input image not the resized image. But these anchor boxes are being drawn on the resized image in calc_rpn function. The script should resize the anchor boxes to the same size.

original: anchor_x = anchor_sizes[anchor_size_idx] anchor_ratios[anchor_ratio_idx][0] anchor_y = anchor_sizes[anchor_size_idx] anchor_ratios[anchor_ratio_idx][1]

suggested: anchor_x = anchor_sizes[anchor_size_idx] anchor_ratios[anchor_ratio_idx][0] (resized_width / float(width)) anchor_y = anchor_sizes[anchor_size_idx] anchor_ratios[anchor_ratio_idx][1] (resized_height / float(height))

Am I correct? Is this an implementation error?

TiasM commented 4 years ago

I think the anchor should be drawn to the resized image because we are working with resized image for the whole training/testing process (which is the way it is implemented). In the original paper the author also resize all the image used for training and testing as a preprocess. Please correct me if i'm wrong