{"record":{"id":"0eb095223cff52c8","repo":"roboflow/supervision","slug":"could-not-aggregate-images-shape-provided-unknow","errorCode":null,"errorMessage":"Could not aggregate images shape - provided unknown mode: {mode}. Supported modes: {list(SHAPE_AGGREGATION_FUN.keys())}.","messagePattern":"Could not aggregate images shape - provided unknown mode: (.+?)\\. Supported modes: (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/utils/image.py","lineNumber":920,"sourceCode":"    images: list[npt.NDArray[np.uint8]], aggregator: Callable[[list[int]], float]\n) -> tuple[int, int]:\n    height = round(aggregator([i.shape[0] for i in images]))\n    width = round(aggregator([i.shape[1] for i in images]))\n    return width, height\n\n\nSHAPE_AGGREGATION_FUN = {\n    \"min\": partial(_calculate_aggregated_images_shape, aggregator=np.min),\n    \"max\": partial(_calculate_aggregated_images_shape, aggregator=np.max),\n    \"avg\": partial(_calculate_aggregated_images_shape, aggregator=np.average),\n}\n\n\ndef _aggregate_images_shape(\n    images: list[npt.NDArray[np.uint8]], mode: Literal[\"min\", \"max\", \"avg\"]\n) -> tuple[int, int]:\n    if mode not in SHAPE_AGGREGATION_FUN:\n        raise ValueError(\n            f\"Could not aggregate images shape - provided unknown mode: {mode}. \"\n            f\"Supported modes: {list(SHAPE_AGGREGATION_FUN.keys())}.\"\n        )\n    return SHAPE_AGGREGATION_FUN[mode](images)\n\n\ndef _establish_grid_size(\n    images: list[npt.NDArray[np.uint8]],\n    grid_size: tuple[int | None, int | None] | None,\n) -> tuple[int, int]:\n    if grid_size is None or all(e is None for e in grid_size):\n        return _negotiate_grid_size(images=images)\n    if grid_size[0] is None:\n        columns = grid_size[1]\n        assert columns is not None\n        return math.ceil(len(images) / columns), columns\n    if grid_size[1] is None:\n        rows = grid_size[0]","sourceCodeStart":902,"sourceCodeEnd":938,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/utils/image.py#L902-L938","documentation":"Raised when `tile_scaling` (the mode used to aggregate image shapes into a single tile size) is not one of 'min', 'max', 'avg'. The dispatch is a literal dict lookup (`SHAPE_AGGREGATION_FUN`), so any other string — including case variants — is rejected. The error message lists the supported modes.","triggerScenarios":"Passing `tile_scaling='average'`, `'MIN'`, or `'mean'` to `sv.create_tiles`; passing a typo like 'maxi'; forwarding a user-supplied string from a CLI without validation.","commonSituations":"CLI/config options accepting free text; users assuming 'mean' is valid since it is a common numpy aggregator; case-sensitive values from YAML configs.","solutions":["Use one of exactly: 'min', 'max', 'avg'.","Normalize CLI input: `mode = mode.strip().lower()` and reject unknown values with the supported list.","If 'mean' was intended, use 'avg'."],"exampleFix":"# before\nmontage = sv.create_tiles(images=images, tile_scaling='mean')\n# after\nmontage = sv.create_tiles(images=images, tile_scaling='avg')","handlingStrategy":"validation","validationCode":"assert tile_scaling in {'min', 'max', 'avg'}, f'unknown tile_scaling: {tile_scaling}'","typeGuard":"from typing import Literal\nTileScaling = Literal['min', 'max', 'avg']\n\ndef is_valid_tile_scaling(mode: str) -> bool:\n    return mode in {'min', 'max', 'avg'}","tryCatchPattern":null,"preventionTips":["Use a Literal type for the config field so mypy catches typos.","Normalize and lower-case CLI values before forwarding.","Remember 'mean' is not supported — use 'avg'."],"tags":["image","tiles","enum","argument-error"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}