Skip to content

Commit cab6462

Browse files
committed
Remove GeAffineTransform processor
1 parent df2f7f9 commit cab6462

File tree

5 files changed

+11
-30
lines changed

5 files changed

+11
-30
lines changed

docs/structure.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@
371371
processors.GetTransformationSize,
372372
processors.GetTransformationScale,
373373
processors.GetSourceDestinationPoints,
374-
processors.GetAffineTransform,
375374
processors.GetImageCenter,
376375
processors.WarpAffine,
377376
]

paz/pipelines/image.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from ..abstract import SequentialProcessor
22
from .. import processors as pr
3+
from ..backend.image import get_affine_transform
34

45

56
class AugmentImage(SequentialProcessor):
@@ -99,15 +100,13 @@ class PreprocessImageHigherHRNet(pr.Processor):
99100
center: center of the image
100101
scale: scaled image dimensions
101102
"""
102-
def __init__(self, scaling_factor=200, input_size=512, inverse=False,
103-
multiple=64):
103+
def __init__(self, scaling_factor=200, input_size=512, multiple=64):
104104
super(PreprocessImageHigherHRNet, self).__init__()
105105
self.get_image_center = pr.GetImageCenter()
106106
self.get_size = pr.GetTransformationSize(input_size, multiple)
107107
self.get_scale = pr.GetTransformationScale(scaling_factor)
108108
self.get_source_destination_point = pr.GetSourceDestinationPoints(
109109
scaling_factor)
110-
self.get_affine_transform = pr.GetAffineTransform(inverse)
111110
self.transform_image = pr.SequentialProcessor(
112111
[pr.WarpAffine(), pr.ImagenetPreprocessInput(), pr.ExpandDims(0)])
113112

@@ -117,6 +116,6 @@ def call(self, image):
117116
scale = self.get_scale(image, size)
118117
source_point, destination_point = self.get_source_destination_point(
119118
center, scale, size)
120-
transform = self.get_affine_transform(source_point, destination_point)
119+
transform = get_affine_transform(source_point, destination_point)
121120
image = self.transform_image(image, transform, size)
122121
return image, center, scale

paz/pipelines/keypoints.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .renderer import RenderTwoViews
55
from ..models import KeypointNet2D
66
from tensorflow.keras.utils import get_file
7+
from ..backend.image import get_affine_transform
78

89

910
class KeypointNetSharedAugmentation(SequentialProcessor):
@@ -183,15 +184,17 @@ class TransformKeypoints(pr.Processor):
183184
"""
184185
def __init__(self, inverse=False):
185186
super(TransformKeypoints, self).__init__()
187+
self.inverse = inverse
186188
self.get_source_destination_point = pr.GetSourceDestinationPoints(
187189
scaling_factor=200)
188-
self.get_affine_transform = pr.GetAffineTransform(inverse=inverse)
189190
self.transform_keypoints = pr.TransformKeypoints()
190191

191192
def call(self, grouped_keypoints, center, scale, shape):
192193
source_point, destination_point = self.get_source_destination_point(
193194
center, scale, shape)
194-
transform = self.get_affine_transform(source_point, destination_point)
195+
if self.inverse:
196+
source_point, destination_point = destination_point, source_point
197+
transform = get_affine_transform(source_point, destination_point)
195198
transformed_keypoints = self.transform_keypoints(grouped_keypoints,
196199
transform)
197200
return transformed_keypoints

paz/processors/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@
7474
from .geometric import GetTransformationSize
7575
from .geometric import GetTransformationScale
7676
from .geometric import GetSourceDestinationPoints
77-
from .geometric import GetAffineTransform
7877
from .geometric import GetImageCenter
7978
from .geometric import WarpAffine
8079

paz/processors/geometric.py

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -507,9 +507,9 @@ class GetSourceDestinationPoints(Processor):
507507
"""Returns the source and destination points for affine transformation.
508508
509509
# Arguments
510-
center: Numpy array. Center coordinates of image
511-
scale: Numpy array. Scale of width and height of image
512-
size: Numpy array. Size of image
510+
center: Numpy array of shape (2,). Center coordinates of image
511+
scale: Numpy array of shape (2,). Scale of width and height of image
512+
size: List of length 2. Size of image
513513
"""
514514
def __init__(self, scaling_factor):
515515
super(GetSourceDestinationPoints, self).__init__()
@@ -547,25 +547,6 @@ def call(self, center, scale, size):
547547
return source_point, destination_point
548548

549549

550-
class GetAffineTransform(Processor):
551-
"""Returns the affine transform of the image.
552-
553-
# Arguments
554-
source_point: Numpy array
555-
destination_point: Numpy array
556-
"""
557-
def __init__(self, inverse):
558-
super(GetAffineTransform, self).__init__()
559-
self.inverse = inverse
560-
561-
def call(self, source_point, destination_point):
562-
if self.inverse:
563-
transform = get_affine_transform(destination_point, source_point)
564-
else:
565-
transform = get_affine_transform(source_point, destination_point)
566-
return transform
567-
568-
569550
class GetImageCenter(Processor):
570551
"""Calculate the center of the image and add an offset to the center.
571552

0 commit comments

Comments
 (0)