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 MovieCharacterService generate character avatar

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

Overview

Service that generates character avatar/portrait images from three-view prompts with optional reference images, retry, and generation history tracking.

Description

MovieCharacterService.generate_character_avatar takes a character's three-view prompt (the generated_prompt field), enhances it with the character name in the top-left corner, and calls GatewayProvider.generate_image via retry_with_backoff. Optional reference images from the character's reference_images list can be passed via reference_indices.

The generated image is extracted and uploaded to MinIO, the character's avatar_url is updated, and a generation history record is created.

Usage

Import when generating character avatar/portrait images. Called by the movie generation pipeline after character extraction.

Code Reference

Source Location

  • Repository: ai-moive-studio
  • File: backend/src/services/movie_character_service.py:L302-393

Signature

class MovieCharacterService(BaseService):
    async def generate_character_avatar(
        self,
        character_id: str,
        api_key_id: str,
        model: str = None,
        prompt: str = None,
        style: str = "cinematic",
        reference_indices: list = None
    ) -> str:
        """
        Args:
            character_id: character UUID
            api_key_id: API key UUID
            model: image model name
            prompt: three-view prompt (required)
            reference_indices: optional indices into character.reference_images

        Returns:
            MinIO object key string for generated avatar
        """

Import

from src.services.movie_character_service import MovieCharacterService

I/O Contract

Inputs

Name Type Required Description
character_id str Yes Character UUID
api_key_id str Yes API key UUID
model str No Image model name
prompt str Yes Three-view prompt (user-adjusted)
reference_indices list No Indices into character.reference_images

Outputs

Name Type Description
return value str MinIO object key for avatar image
DB side effects — Updates MovieCharacter.avatar_url; creates GenerationHistory

Usage Examples

Generating an Avatar

from src.services.movie_character_service import MovieCharacterService

service = MovieCharacterService(db_session)
avatar_key = await service.generate_character_avatar(
    character_id="char-uuid",
    api_key_id="key-uuid",
    model="gemini-3-pro-image-preview",
    prompt=character.generated_prompt,
    reference_indices=[0, 1],  # use first two reference images
)
print(f"Avatar stored at: {avatar_key}")

Related Pages

Implements Principle

Page Connections

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