Commit d4484474 authored by Yuxin Wu's avatar Yuxin Wu

fix crop

parent 5aed2cc0
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
# Author: Yuxin Wu <ppwwyyxx@gmail.com> # Author: Yuxin Wu <ppwwyyxx@gmail.com>
from .base import ImageAugmentor from .base import ImageAugmentor
import cv2
__all__ = ['RandomCrop', 'CenterCrop', 'Resize'] __all__ = ['RandomCrop', 'CenterCrop', 'Resize']
...@@ -42,11 +43,11 @@ class Resize(ImageAugmentor): ...@@ -42,11 +43,11 @@ class Resize(ImageAugmentor):
def __init__(self, shape): def __init__(self, shape):
""" """
Args: Args:
shape: (w, h) shape: (h, w)
""" """
self._init(locals()) self._init(locals())
def _augment(self, img): def _augment(self, img):
img.arr = cv2.resize( img.arr = cv2.resize(
img.arr, self.shape, img.arr, self.shape[::-1],
interpolation=cv2.INTER_CUBIC) interpolation=cv2.INTER_CUBIC)
...@@ -46,6 +46,7 @@ def ImageSample(template, mapping): ...@@ -46,6 +46,7 @@ def ImageSample(template, mapping):
mapping: bxh2xw2x2 (y, x) real-value coordinates mapping: bxh2xw2x2 (y, x) real-value coordinates
Return: bxh2xw2xc Return: bxh2xw2xc
""" """
assert template.get_shape().ndims == 4 and mapping.get_shape().ndims == 4
mapping = tf.maximum(mapping, 0.0) mapping = tf.maximum(mapping, 0.0)
tf.check_numerics(mapping, "mapping") tf.check_numerics(mapping, "mapping")
lcoor = tf.cast(mapping, tf.int32) # floor lcoor = tf.cast(mapping, tf.int32) # floor
......
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