Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:869413421 Ai moive studio SceneImageService batch generate scene images

From Leeroopedia
Knowledge Sources
Domains Vision, Generative_AI
Last Updated 2026-10-23 12:00 GMT

Overview

Service that batch-generates establishing shot images for scenes without existing scene images, using concurrent workers with independent database sessions.

Description

SceneImageService.batch_generate_scene_images loads a script with scenes and shots, filters to only scenes missing scene_image_url, and concurrently generates establishing shot images. Each worker uses an independent database session to avoid connection conflicts.

Workers use retry_with_backoff around GatewayProvider.generate_image calls and upload results to MinIO. Scene scene_image_url and scene_image_prompt are updated per worker.

Usage

Import when generating establishing shot images for AI movie scenes. Called by the movie generation pipeline after shot extraction.

Code Reference

Source Location

  • Repository: ai-moive-studio
  • File: backend/src/services/scene_image_service.py:L204-273

Signature

class SceneImageService(BaseService):
    async def batch_generate_scene_images(
        self,
        script_id: str,
        api_key_id: str,
        model: Optional[str] = None
    ) -> Dict[str, Any]:
        """
        Args:
            script_id: script UUID
            api_key_id: API key UUID
            model: image model name

        Returns:
            Dict with total, success, failed, message
        """

Import

from src.services.scene_image_service import SceneImageService

I/O Contract

Inputs

Name Type Required Description
script_id str Yes Script UUID
api_key_id str Yes API key UUID
model str No Image model name

Outputs

Name Type Description
return value dict {total, success, failed, message}
DB side effects — Updates MovieScene.scene_image_url, scene_image_prompt

Usage Examples

Generating Scene Images

from src.services.scene_image_service import SceneImageService

service = SceneImageService(db_session)
result = await service.batch_generate_scene_images(
    script_id="script-uuid",
    api_key_id="key-uuid",
    model="gemini-3-pro-image-preview",
)
print(f"Scene images: {result['success']}/{result['total']}")

Related Pages

Implements Principle

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment