MCPcopy Create free account
hub / github.com/MrSyee/SAM-remove-background / get_preprocess_shape

Method get_preprocess_shape

src/server/tasks/sam.py:108–118  ·  view source on GitHub ↗

Compute the output size given input size and target long side length.

(
        oldh: int, oldw: int, long_side_length: int = 1024
    )

Source from the content-addressed store, hash-verified

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)

Callers 1

preprocessMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected