MCPcopy Create free account
hub / github.com/MotrixLab/ViMoGen / get_closest_ratio

Function get_closest_ratio

datasets/aspect.py:439–443  ·  view source on GitHub ↗
(height: float, width: float, ratios: dict)

Source from the content-addressed store, hash-verified

437
438
439def get_closest_ratio(height: float, width: float, ratios: dict):
440 aspect_ratio = height / width
441 closest_ratio = min(
442 ratios.keys(), key=lambda ratio: abs(float(ratio) - aspect_ratio))
443 return closest_ratio
444
445
446ASPECT_RATIOS = {

Callers 1

get_bucket_idMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected