def _PIL_to_opencv(pil_image: ImageType) -> ndarray:
    """switches between PIL and cv2 -  assumes BGR for cv2

    Args:
        pil_image (ImageType): _description_

    Raises:
        TypeError: _description_

    Returns:
        ndarray: _description_
    """
    if isinstance(pil_image, ImageType):
        return cv2.cvtColor(np.array(pil_image), cv2.COLOR_RGB2BGR)
    raise TypeError(f"expected a PIL image but received {type(pil_image)}")
switches between PIL and cv2 -  assumes BGR for cv2

    Args:
        pil_image (ImageType): _description_

    Raises:
        TypeError: _description_

    Returns:
        ndarray: _description_
    
src/marqo/s2_inference/processing/image_utils.py