{"record":{"id":"3aa76cb72a3e558f","repo":"roboflow/supervision","slug":"invalid-vlm-result-type-type-result-must-be-d","errorCode":null,"errorMessage":"Invalid VLM result type: {type(result)}. Must be dict.","messagePattern":"Invalid VLM result type: (.+?)\\. Must be dict\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/detection/core.py","lineNumber":2075,"sourceCode":"            xyxy, class_id, class_name = from_qwen_3_vl(result, **kwargs)\n            data = {CLASS_NAME_DATA_FIELD: class_name}\n            confidence_arr = np.ones(len(xyxy), dtype=float)\n            return cls(\n                xyxy=xyxy, class_id=class_id, confidence=confidence_arr, data=data\n            )\n\n        if vlm == VLM.DEEPSEEK_VL_2:\n            if not isinstance(result, str):\n                raise ValueError(\n                    f\"Invalid VLM result type: {type(result)}. Must be str.\"\n                )\n            xyxy, class_id, class_name = from_deepseek_vl_2(result, **kwargs)\n            data = {CLASS_NAME_DATA_FIELD: class_name}\n            return cls(xyxy=xyxy, class_id=class_id, data=data)\n\n        if vlm == VLM.FLORENCE_2:\n            if not isinstance(result, dict):\n                raise ValueError(\n                    f\"Invalid VLM result type: {type(result)}. Must be dict.\"\n                )\n            xyxy, labels, mask, xyxyxyxy = from_florence_2(result, **kwargs)\n            if len(xyxy) == 0:\n                empty = cls.empty()\n                empty.data = {CLASS_NAME_DATA_FIELD: np.empty(0, dtype=str)}\n                return empty\n\n            data = {}\n            if labels is not None:\n                data[CLASS_NAME_DATA_FIELD] = labels\n            if xyxyxyxy is not None:\n                data[ORIENTED_BOX_COORDINATES] = xyxyxyxy\n\n            return cls(xyxy=xyxy, mask=mask, data=data)\n\n        if vlm == VLM.GOOGLE_GEMINI_2_0:\n            if not isinstance(result, str):","sourceCodeStart":2057,"sourceCodeEnd":2093,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/detection/core.py#L2057-L2093","documentation":"The FLORENCE_2 branch of Detections.from_vlm expects the Florence-2 post-processed output as a dict — typically {'<TASK>': value} entries produced by the Florence2Processor, e.g. {'<OD>': 'box1...</od>'} or '<OD>' plus '<OD_SEGMENTS>'. The parser from_florence_2 requires a dict; strings raise this ValueError.","triggerScenarios":"Calling from_vlm(vlm=sv.VLM.FLORENCE_2, result='box_1 ... ...') with a raw string; passing the decoded generation text instead of processor.post_process_generation(...) output; passing a list of task results.","commonSituations":"Skipping post_process_generation and decoding generate() output manually; extracting one task's string value from the dict and passing that; using a wrapper that flattens dict output to text.","solutions":["Run outputs through Florence2Processor.post_process_generation(generated_ids, task='<OD>', image_size=(h, w)) and pass the resulting dict.","Keep the whole dict — the parser reads the task keys itself; do not pre-extract strings.","For segmentation use task '<OD_SEGMENTS>'/'<REFERRING_EXPRESSION_SEGMENTATION>' so the dict contains segmentation entries."],"exampleFix":"# before\ntext = processor.decode(generated_ids[0], skip_special_tokens=False)\ndetections = sv.Detections.from_vlm(vlm=sv.VLM.FLORENCE_2, result=text)  # str -> ValueError\n\n# after\nparsed = processor.post_process_generation(\n    text, task='<OD>', image_size=(image.height, image.width)\n)\ndetections = sv.Detections.from_vlm(vlm=sv.VLM.FLORENCE_2, result=parsed)","handlingStrategy":"type-guard","validationCode":"parsed = (\n    result if isinstance(result, dict)\n    else processor.post_process_generation(result, task='<OD>', image_size=(h, w))\n)\nassert isinstance(parsed, dict)\ndetections = sv.Detections.from_vlm(vlm=sv.VLM.FLORENCE_2, result=parsed)","typeGuard":"def is_florence2_result_dict(result) -> bool:\n    return isinstance(result, dict)","tryCatchPattern":"try:\n    detections = sv.Detections.from_vlm(vlm=sv.VLM.FLORENCE_2, result=result)\nexcept ValueError as e:\n    if 'Must be dict' in str(e):\n        parsed = processor.post_process_generation(result, task='<OD>', image_size=(h, w))\n        detections = sv.Detections.from_vlm(vlm=sv.VLM.FLORENCE_2, result=parsed)\n    else:\n        raise","preventionTips":["Always run post_process_generation for Florence-2","Pass the full task dict, not extracted strings","Match the task token to the capability you want (OD vs segmentation)"],"tags":["vlm","florence-2","type","from-vlm","post-process"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}