@@ -51,12 +51,12 @@ def __init__(self, wpodnet: WPODNet):
5151 self .wpodnet = wpodnet
5252 self .wpodnet .eval ()
5353
54- def _resize_to_fixed_ratio (self , image : Image .Image ) -> Image .Image :
54+ def _resize_to_fixed_ratio (self , image : Image .Image , dim_min : int , dim_max : int ) -> Image .Image :
5555 h , w = image .height , image .width
5656
5757 wh_ratio = max (h , w ) / min (h , w )
58- side = int (wh_ratio * 288 )
59- bound_dim = min (side + side % self ._stride , 608 )
58+ side = int (wh_ratio * dim_min )
59+ bound_dim = min (side + side % self ._stride , dim_max )
6060
6161 factor = bound_dim / min (h , w )
6262 reg_w , reg_h = int (w * factor ), int (h * factor )
@@ -103,12 +103,12 @@ def _get_bounds(self, affines: np.ndarray, anchor_y: int, anchor_x: int, scaling
103103
104104 return np .transpose (bounds )
105105
106- def predict (self , image : Image .Image , scaling_ratio : float = 1.0 ) -> Prediction :
106+ def predict (self , image : Image .Image , scaling_ratio : float = 1.0 , dim_min : int = 288 , dim_max : int = 608 ) -> Prediction :
107107 orig_h , orig_w = image .height , image .width
108108
109109 # Resize the image to fixed ratio
110110 # This operation is convienence for setup the anchors
111- resized = self ._resize_to_fixed_ratio (image )
111+ resized = self ._resize_to_fixed_ratio (image , dim_min = dim_min , dim_max = dim_max )
112112 resized = self ._to_torch_image (resized )
113113 resized = resized .to (self .wpodnet .device )
114114
0 commit comments