from typing import Literal
from pydantic import BaseModel, Field
from vlmrun.client.types import GenerationConfig
class ImagePrediction(BaseModel):
label: Literal["tv", "document", "other"] = Field(..., title="Class label for the image.")
caption: str = Field(..., title="Caption for the image.")
# Initialize the client
client = VLMRun()
# Load the image, and process it with the custom schema
image: Image.Image = Image.open("path/to/image.jpg")
response: PredictionResponse = client.image.generate(
images=[image],
domain="image.classification",
config=GenerationConfig(
json_schema=ImagePrediction.model_json_schema()
)
)