Repository: roboflow/supervision
File: supervision/detection/core.py (Python)

Code before:
            Detections: A new Detections object.

        Raises:
            ValueError: If the LMM is invalid, required arguments are missing, or
                disallowed arguments are provided.
            ValueError: If the specified LMM is not supported.

        Examples:
            ```python
            import supervision as sv

            paligemma_result = "<loc0256><loc0256><loc0768><loc0768> cat"
            detections = sv.Detections.from_lmm(
                sv.LMM.PALIGEMMA,
                paligemma_result,
                resolution_wh=(1000, 1000),
                classes=['cat', 'dog']
            )
            detections.xyxy
            # array([[250., 250., 750., 750.]])

            detections.class_id
            # array([0])
            ```
        """
        # filler logic mapping old from_lmm to new from_vlm
        lmm_to_vlm = {
            LMM.PALIGEMMA: VLM.PALIGEMMA,
            LMM.FLORENCE_2: VLM.FLORENCE_2,
            LMM.QWEN_2_5_VL: VLM.QWEN_2_5_VL,
        }

        # (this works even if the LMM enum is wrapped by @deprecated)
        if isinstance(lmm, Enum) and lmm.__class__.__name__ == "LMM":
            vlm = lmm_to_vlm[lmm]

        elif isinstance(lmm, str):
            try:
                lmm_enum = LMM(lmm.lower())
            except ValueError:
                raise ValueError(
                    f"Invalid LMM string '{lmm}'. Must be one of "
                    f"{[m.value for m in LMM]}"
                )
            vlm = lmm_to_vlm[lmm_enum]

        else:
            raise ValueError(
                f"Invalid type for 'lmm': {type(lmm)}. Must be LMM or str."
            )


Review comment (suggestion):
`from_lmm` is actually deprecated; while working on `from_lmm` docs changes make sure to copy the docsstring to `from_vlm` with all proper changes

Code after:
        Returns:
            Detections: A new Detections object.

        Raises:
            ValueError: If the LMM is invalid, required arguments are missing, or
                disallowed arguments are provided.
            ValueError: If the specified LMM is not supported.

        Examples:
            ```python
            import supervision as sv

            paligemma_result = "<loc0256><loc0256><loc0768><loc0768> cat"
            detections = sv.Detections.from_lmm(
                sv.LMM.PALIGEMMA,
                paligemma_result,
                resolution_wh=(1000, 1000),
                classes=['cat', 'dog']
            )
            detections.xyxy
            # array([[250., 250., 750., 750.]])

            detections.class_id
            # array([0])
            ```

        Examples:
            ```python
            from google import genai
            from google.genai import types
            import supervision as sv
            from PIL import Image

            IMAGE = Image.open(<SOURCE_IMAGE_PATH>)
            GENAI_CLIENT = genai.Client(api_key=<API_KEY>)

            system_instructions = '''
                Return bounding boxes as a JSON array with labels and ids. Never return masks or code fencing. Limit to 25 objects.
                If an object is present multiple times, name them according to their unique characteristic (colors, size, position, unique characteristics, etc..).
                '''

            safety_settings = [
                types.SafetySetting(
                    category="HARM_CATEGORY_DANGEROUS_CONTENT",
                    threshold="BLOCK_ONLY_HIGH",
                ),
            ]

            response = GENAI_CLIENT.models.generate_content(
                model="gemini-2.0-flash-exp",
                contents=[prompt, IMAGE],