Commit 4fa66545 authored by Yuxin Wu's avatar Yuxin Wu

fix Shift & Rotation (fix #394)

parent e891b9e7
...@@ -16,6 +16,7 @@ help: ...@@ -16,6 +16,7 @@ help:
docset: html docset: html
doc2dash -d ./ -n $(SPHINXPROJ) --enable-js --force $(BUILDDIR)/html/ -I tutorial/index.html doc2dash -d ./ -n $(SPHINXPROJ) --enable-js --force $(BUILDDIR)/html/ -I tutorial/index.html
tar czvf tensorpack.docset.tgz tensorpack.docset
# Catch-all target: route all unknown targets to Sphinx using the new # Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
......
...@@ -36,7 +36,9 @@ class Shift(TransformAugmentorBase): ...@@ -36,7 +36,9 @@ class Shift(TransformAugmentorBase):
dy = np.round(self._rand_range(-max_dy, max_dy)) dy = np.round(self._rand_range(-max_dy, max_dy))
mat = np.array([[1, 0, dx], [0, 1, dy]], dtype='float32') mat = np.array([[1, 0, dx], [0, 1, dy]], dtype='float32')
return WarpAffineTransform(mat, img.shape[1::-1], self.border, self.border_value) return WarpAffineTransform(
mat, img.shape[1::-1],
borderMode=self.border, borderValue=self.border_value)
class Rotation(TransformAugmentorBase): class Rotation(TransformAugmentorBase):
...@@ -80,7 +82,9 @@ class Rotation(TransformAugmentorBase): ...@@ -80,7 +82,9 @@ class Rotation(TransformAugmentorBase):
assert np.all(arr == orig) assert np.all(arr == orig)
""" """
mat = cv2.getRotationMatrix2D(tuple(center - 0.5), deg, 1) mat = cv2.getRotationMatrix2D(tuple(center - 0.5), deg, 1)
return WarpAffineTransform(mat, img.shape[1::-1], self.border, self.border_value) return WarpAffineTransform(
mat, img.shape[1::-1], interp=self.interp,
borderMode=self.border, borderValue=self.border_value)
class RotationAndCropValid(ImageAugmentor): class RotationAndCropValid(ImageAugmentor):
......
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