GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — ViMax/agents/character_portraits_generator.py at main · MarchGe/ViMax Expand file tree/ Copy pathcharacter_portraits_generator.pyMore file actions 87 lines (75 loc) · 3.35 KB / Copy pathcharacter_portraits_generator.pyFile metadata and controls87 lines (75 loc) · 3.35 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 import logging import os import asyncio from langchain_core.prompts import ChatPromptTemplate from langchain_core.output_parsers import PydanticOutputParser from langchain.chat_models.base import BaseChatModel from langchain.chat_models import init_chat_model from pydantic import BaseModel, Field from typing import List, Optional, Dict from interfaces import CharacterInScene, ImageOutput from langchain_core.messages import HumanMessage, SystemMessage prompt_template_front = \ """ Generate a full-body, front-view portrait of character {identifier} based on the following description, with a pure white background. Use a wide 16:9 landscape canvas, not a vertical portrait canvas. The character should be centered in the image, occupying the middle of the wide frame with enough horizontal empty space. Gazing straight ahead. Standing with arms relaxed at sides. Natural expression. Features: {features} Style: {style} """ prompt_template_side = \ """ Generate a full-body, side-view portrait of character {identifier} based on the provided front-view portrait, with a pure white background. Use a wide 16:9 landscape canvas, not a vertical portrait canvas. The character should be centered in the image, occupying the middle of the wide frame with enough horizontal empty space. Facing left. Standing with arms relaxed at sides. """ prompt_template_back = \ """ Generate a full-body, back-view portrait of character {identifier} based on the provided front-view portrait, with a pure white background. Use a wide 16:9 landscape canvas, not a vertical portrait canvas. The character should be centered in the image, occupying the middle of the wide frame with enough horizontal empty space. No facial features should be visible. """ class CharacterPortraitsGenerator: def __init__( self, image_generator, ): self.image_generator = image_generator async def generate_front_portrait( self, character: CharacterInScene, style: str, ) -> ImageOutput: features = "(static) " + (character.static_features or "") + "; (dynamic) " + (character.dynamic_features or "") prompt = prompt_template_front.format( identifier=character.identifier_in_scene, features=features, style=style, ) image_output = await self.image_generator.generate_single_image( prompt=prompt, # size="512x512", ) return image_output async def generate_side_portrait( self, character: CharacterInScene, front_image_path: str, ) -> ImageOutput: prompt = prompt_template_side.format( identifier=character.identifier_in_scene, ) image_output = await self.image_generator.generate_single_image( prompt=prompt, reference_image_paths=[front_image_path], # size="1024x1024", ) return image_output async def generate_back_portrait( self, character: CharacterInScene, front_image_path: str, ) -> ImageOutput: prompt = prompt_template_back.format( identifier=character.identifier_in_scene, ) image_output = await self.image_generator.generate_single_image( prompt=prompt, reference_image_paths=[front_image_path], # size="512x512", ) return image_output |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |