Commit 07fcdcc1 authored by Yuxin Wu's avatar Yuxin Wu

[FasterRCNN] pad roi

parent ace39425
...@@ -26,7 +26,7 @@ def maybe_freeze_affine(getter, *args, **kwargs): ...@@ -26,7 +26,7 @@ def maybe_freeze_affine(getter, *args, **kwargs):
def resnet_argscope(): def resnet_argscope():
with argscope([Conv2D, MaxPooling, BatchNorm], data_format='channels_first'), \ with argscope([Conv2D, MaxPooling, BatchNorm], data_format='channels_first'), \
argscope(Conv2D, use_bias=False), \ argscope(Conv2D, use_bias=False), \
argscope(BatchNorm, training=False), \ argscope(BatchNorm, training=False, epsilon=0), \
custom_getter_scope(maybe_freeze_affine): custom_getter_scope(maybe_freeze_affine):
yield yield
......
...@@ -270,7 +270,7 @@ def get_train_dataflow(add_mask=False): ...@@ -270,7 +270,7 @@ def get_train_dataflow(add_mask=False):
return ret return ret
ds = MapData(ds, preprocess) ds = MapData(ds, preprocess)
ds = PrefetchDataZMQ(ds, 3) ds = PrefetchDataZMQ(ds, 1)
return ds return ds
......
...@@ -312,6 +312,10 @@ def crop_and_resize(image, boxes, box_ind, crop_size): ...@@ -312,6 +312,10 @@ def crop_and_resize(image, boxes, box_ind, crop_size):
""" """
assert isinstance(crop_size, int), crop_size assert isinstance(crop_size, int), crop_size
# TF's crop_and_resize fails on border
image = tf.pad(image, [[0, 0], [0, 0], [1, 1], [1, 1]])
boxes = boxes + 1
@under_name_scope() @under_name_scope()
def transform_fpcoor_for_tf(boxes, image_shape, crop_shape): def transform_fpcoor_for_tf(boxes, image_shape, crop_shape):
""" """
...@@ -570,8 +574,6 @@ if __name__ == '__main__': ...@@ -570,8 +574,6 @@ if __name__ == '__main__':
7 7.5 8 8.5 7 7.5 8 8.5
9.5 10 10.5 11 9.5 10 10.5 11
12 12.5 13 13.5 12 12.5 13 13.5
Our implementation is not perfect either. When boxes are on the border of
images, TF pads zeros instead of border values. But this rarely happens so it's fine.
You cannot easily get the above results with tf.image.crop_and_resize. You cannot easily get the above results with tf.image.crop_and_resize.
Try out yourself here: Try out yourself here:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment