from typing import Literal
from pydantic import BaseModel, Field
from perceptron import configure, perceive, pydantic_format, image, text
configure(provider="perceptron", api_key="YOUR_API_KEY")
class SceneAnalysis(BaseModel):
scene_type: Literal["urban", "nature"]
main_subjects: list[str] = Field(description="Primary objects in the scene")
mood: Literal["energetic", "peaceful", "tense"]
time_of_day: Literal["day", "night", "unknown"]
@perceive(model="isaac-0.2-2b-preview", response_format=pydantic_format(SceneAnalysis))
def analyze_scene(photo):
return image(photo) + text("Analyze this scene. Output in JSON with scene type, subjects, mood and time of day.")
scene = analyze_scene("photo.jpg")
print(f"Scene type: {scene.scene_type}")
print(f"Subjects: {scene.main_subjects}")
print(f"Mood: {scene.mood}")
print(f"Time: {scene.time_of_day}")