Compute the output size given input size and target long side length.
(
oldh: int, oldw: int, long_side_length: int = 1024
)
| 106 | |
| 107 | @staticmethod |
| 108 | def get_preprocess_shape( |
| 109 | oldh: int, oldw: int, long_side_length: int = 1024 |
| 110 | ) -> Tuple[int, int]: |
| 111 | """ |
| 112 | Compute the output size given input size and target long side length. |
| 113 | """ |
| 114 | scale = long_side_length * 1.0 / max(oldh, oldw) |
| 115 | newh, neww = oldh * scale, oldw * scale |
| 116 | neww = int(neww + 0.5) |
| 117 | newh = int(newh + 0.5) |
| 118 | return (newh, neww) |