MCPcopy Create free account
hub / github.com/dcharatan/flowmap / get_image_shape

Function get_image_shape

flowmap/misc/cropping.py:82–93  ·  view source on GitHub ↗
(
    original_shape: tuple[int, int],
    cfg: CroppingCfg,
)

Source from the content-addressed store, hash-verified

80
81
82def get_image_shape(
83 original_shape: tuple[int, int],
84 cfg: CroppingCfg,
85) -> tuple[int, int]:
86 # If the image shape is exact, return it.
87 if isinstance(cfg.image_shape, tuple):
88 return cfg.image_shape
89
90 # Otherwise, the image shape is assumed to be an approximate number of pixels.
91 h, w = original_shape
92 scale = (cfg.image_shape / (h * w)) ** 0.5
93 return (round(h * scale), round(w * scale))
94
95
96def crop_and_resize_batch_for_model(

Callers 3

mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected