def uncast_image(image: str) -> "Image":
    """Convert a base64 data URI string to a PIL image."""
    if isinstance(image, Image.Image):
        return image
    elif not isinstance(image, str):
        raise ValueError("The image must be a data URI string.")
    elif image.startswith("data:image"):
        try:
            image_data = base64.b64decode(image.split(",")[1])
            image = Image.open(io.BytesIO(image_data))
        except Exception as e:
            raise ValueError("An error occurred while converting the data URI to a PIL image.") from e
        return image
    elif image.startswith("http"):
        return image
    elif Path(image).exists():
        return Image.open(image)
    else:
        raise ValueError("The image must be a data URI string.")
Convert a base64 data URI string to a PIL image.
argilla/src/argilla/_helpers/_media.py