{"record":{"id":"08fa3d6b75465789","repo":"sgl-project/sglang","slug":"incorrect-type-of-image-sizes-got-type-type-ima","errorCode":null,"errorMessage":"Incorrect type of image sizes. Got type: {type(images_spatial_crop)}","messagePattern":"Incorrect type of image sizes\\. Got type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/models/deepseek_ocr.py","lineNumber":1609,"sourceCode":"        images_crop = kwargs.pop(\"images_crop\", None)\n        has_images = kwargs.pop(\"has_images\", None)\n\n        if pixel_values is None:\n            return None\n        if has_images is not None:\n            if not has_images:\n                return None\n        elif torch.sum(pixel_values).item() == 0:\n            return None\n\n        if pixel_values is not None:\n            if not isinstance(pixel_values, (torch.Tensor, list)):\n                raise ValueError(\n                    \"Incorrect type of pixel values. \" f\"Got type: {type(pixel_values)}\"\n                )\n\n            if not isinstance(images_spatial_crop, (torch.Tensor, list)):\n                raise ValueError(\n                    \"Incorrect type of image sizes. \"\n                    f\"Got type: {type(images_spatial_crop)}\"\n                )\n\n            if not isinstance(images_crop, (torch.Tensor, list)):\n                raise ValueError(\n                    \"Incorrect type of image crop. \" f\"Got type: {type(images_crop)}\"\n                )\n\n            return [pixel_values, images_crop, images_spatial_crop]\n\n        raise AssertionError(\"This line should be unreachable.\")\n\n    def _pixel_values_to_embedding(\n        self,\n        pixel_values: torch.Tensor,\n        images_crop: torch.Tensor,\n        images_spatial_crop: torch.Tensor,","sourceCodeStart":1591,"sourceCodeEnd":1627,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/models/deepseek_ocr.py#L1591-L1627","documentation":"Raised by _parse_and_validate_image_input in deepseek_ocr.py when images_spatial_crop (the per-image spatial crop/grid metadata) is not a torch.Tensor or list. DeepseekOCR needs the crop grid to slice the image patches, so a wrong type here is fatal.","triggerScenarios":"Calling get_multimodal_embeddings with mm_item_kwargs that includes pixel_values but omits or corrupts images_spatial_crop — e.g. it is a numpy array, an int, a dict, or a tensor of wrong nesting — so the isinstance((torch.Tensor, list)) guard fails.","commonSituations":"Using a processor config that doesn't emit image_spatial_crop, version mismatch between the processor and sglang model code, or hand-built multimodal payloads that skip the crop metadata.","solutions":["Run the HF processor for the OCR model and pass its image_spatial_crop output unchanged","If building manually, supply images_spatial_crop as a torch tensor or list matching one entry per image","Verify processor and sglang versions are matched (the expected key names changed across releases)"],"exampleFix":"// before\ninputs = {\"pixel_values\": pv}  # spatial crop missing -> becomes invalid type\n\n// after\nproc_out = processor(images=img, return_tensors=\"pt\")\ninputs = {\"pixel_values\": proc_out[\"pixel_values\"],\n          \"images_spatial_crop\": proc_out[\"image_spatial_crop\"]}","handlingStrategy":"type-guard","validationCode":"sc = mm_kwargs.get(\"images_spatial_crop\")\nassert isinstance(sc, (torch.Tensor, list)), \"images_spatial_crop must be tensor/list\"","typeGuard":"def is_valid_spatial_crop(v) -> bool:\n    return isinstance(v, (torch.Tensor, list))","tryCatchPattern":null,"preventionTips":["Include image_spatial_crop from the processor output in every request","Pin processor version to the sglang model version"],"tags":["multimodal","vision","type-validation","deepseek-ocr"],"backgroundTag":"input-type-validation-failed","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}