MCPcopy Create free account
hub / github.com/VisionXLab/OF-Diff / __init__

Method __init__

ldm/modules/midas/midas/transforms.py:52–92  ·  view source on GitHub ↗

Init. Args: width (int): desired output width height (int): desired output height resize_target (bool, optional): True: Resize the full sample (image, mask, target). False: Resize image only. Defaults to Tru

(
        self,
        width,
        height,
        resize_target=True,
        keep_aspect_ratio=False,
        ensure_multiple_of=1,
        resize_method="lower_bound",
        image_interpolation_method=cv2.INTER_AREA,
    )

Source from the content-addressed store, hash-verified

50 """
51
52 def __init__(
53 self,
54 width,
55 height,
56 resize_target=True,
57 keep_aspect_ratio=False,
58 ensure_multiple_of=1,
59 resize_method="lower_bound",
60 image_interpolation_method=cv2.INTER_AREA,
61 ):
62 """Init.
63
64 Args:
65 width (int): desired output width
66 height (int): desired output height
67 resize_target (bool, optional):
68 True: Resize the full sample (image, mask, target).
69 False: Resize image only.
70 Defaults to True.
71 keep_aspect_ratio (bool, optional):
72 True: Keep the aspect ratio of the input sample.
73 Output sample might not have the given width and height, and
74 resize behaviour depends on the parameter 'resize_method'.
75 Defaults to False.
76 ensure_multiple_of (int, optional):
77 Output width and height is constrained to be multiple of this parameter.
78 Defaults to 1.
79 resize_method (str, optional):
80 "lower_bound": Output will be at least as large as the given size.
81 "upper_bound": Output will be at max as large as the given size. (Output size might be smaller than given size.)
82 "minimal": Scale as least as possible. (Output size might be smaller than given size.)
83 Defaults to "lower_bound".
84 """
85 self.__width = width
86 self.__height = height
87
88 self.__resize_target = resize_target
89 self.__keep_aspect_ratio = keep_aspect_ratio
90 self.__multiple_of = ensure_multiple_of
91 self.__resize_method = resize_method
92 self.__image_interpolation_method = image_interpolation_method
93
94 def constrain_to_multiple_of(self, x, min_val=0, max_val=None):
95 y = (np.round(x / self.__multiple_of) * self.__multiple_of).astype(int)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected