Skip to content

Commit

Permalink
Change .format to string interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
BloodAxe committed Jun 28, 2023
1 parent 99fd7f6 commit f2abdad
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions src/super_gradients/training/transforms/keypoint_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def get_equivalent_preprocessing(self) -> List:
]

def __repr__(self):
return self.__class__.__name__ + "()"
return self.__class__.__name__ + f"(permutation={self.permutation})"


@register_transform(Transforms.KeypointsImageStandardize)
Expand All @@ -118,7 +118,7 @@ def get_equivalent_preprocessing(self) -> List[Dict]:
return [{Processings.StandardizeImage: {"max_value": self.max_value}}]

def __repr__(self):
return self.__class__.__name__ + "()"
return self.__class__.__name__ + f"(max_value={self.max_value})"


@register_transform(Transforms.KeypointsImageNormalize)
Expand All @@ -136,7 +136,7 @@ def __call__(self, image: np.ndarray, mask: np.ndarray, joints: np.ndarray, area
return image, mask, joints, areas, bboxes

def __repr__(self):
return self.__class__.__name__ + "(mean={0}, std={1})".format(self.mean, self.std)
return self.__class__.__name__ + f"(mean={self.mean}, std={self.std})"

def get_equivalent_preprocessing(self) -> List:
return [{Processings.NormalizeImage: {"mean": self.mean, "std": self.std}}]
Expand All @@ -160,7 +160,7 @@ def __init__(self, flip_index: List[int], prob: float = 0.5):
self.prob = prob

def __repr__(self):
return self.__class__.__name__ + "(flip_index={0}, prob={1})".format(self.flip_index, self.prob)
return self.__class__.__name__ + f"(flip_index={self.flip_index}, prob={self.prob})"

def __call__(self, image, mask, joints, areas: Optional[np.ndarray], bboxes: Optional[np.ndarray]):
if image.shape[:2] != mask.shape[:2]:
Expand Down Expand Up @@ -238,7 +238,7 @@ def get_equivalent_preprocessing(self) -> List:
raise RuntimeError("KeypointsRandomHorizontalFlip does not have equivalent preprocessing.")

def __repr__(self):
return self.__class__.__name__ + "(prob={0})".format(self.prob)
return self.__class__.__name__ + f"(prob={self.prob})"


@register_transform(Transforms.KeypointsLongestMaxSize)
Expand Down Expand Up @@ -301,8 +301,10 @@ def apply_to_bboxes(cls, bboxes, scale):
return bboxes * scale

def __repr__(self):
return self.__class__.__name__ + "(max_height={0}, max_width={1}, interpolation={2}, prob={3})".format(
self.max_height, self.max_width, self.interpolation, self.prob
return (
self.__class__.__name__ + f"(max_height={self.max_height}, "
f"max_width={self.max_width}, "
f"interpolation={self.interpolation}, prob={self.prob})"
)

def get_equivalent_preprocessing(self) -> List:
Expand Down Expand Up @@ -346,8 +348,11 @@ def __call__(self, image, mask, joints, areas: Optional[np.ndarray], bboxes: Opt
return image, mask, joints, areas, bboxes

def __repr__(self):
return self.__class__.__name__ + "(min_height={0}, min_width={1}, image_pad_value={2}, mask_pad_value={3})".format(
self.min_height, self.min_width, self.image_pad_value, self.mask_pad_value
return (
self.__class__.__name__ + f"(min_height={self.min_height}, "
f"min_width={self.min_width}, "
f"image_pad_value={self.image_pad_value}, "
f"mask_pad_value={self.mask_pad_value})"
)

def get_equivalent_preprocessing(self) -> List:
Expand Down Expand Up @@ -387,10 +392,13 @@ def __init__(

def __repr__(self):
return (
self.__class__.__name__
+ "(max_rotation={0}, min_scale={1}, max_scale={2}, max_translate={3}, image_pad_value={4}, mask_pad_value={5}, prob={6})".format(
self.max_rotation, self.min_scale, self.max_scale, self.max_translate, self.image_pad_value, self.mask_pad_value, self.prob
)
self.__class__.__name__ + f"(max_rotation={self.max_rotation}, "
f"min_scale={self.min_scale}, "
f"max_scale={self.max_scale}, "
f"max_translate={self.max_translate}, "
f"image_pad_value={self.image_pad_value}, "
f"mask_pad_value={self.mask_pad_value}, "
f"prob={self.prob})"
)

def _get_affine_matrix(self, img, angle, scale, dx, dy):
Expand Down

0 comments on commit f2abdad

Please sign in to comment.