4.2.1 High-Quality CG Monster Generation
import torch
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
class AIMonsterConceptGenerator:
def __init__(self):
self.model_id = "aimonster/sd-v1-5-movie-monster-finetuned"
self.pipe = StableDiffusionPipeline.from_pretrained(self.model_id, torch_dtype=torch.float16)
self.pipe.scheduler = DPMSolverMultistepScheduler.from_config(self.pipe.scheduler.config)
self.pipe = self.pipe.to("cuda")
def generate_concept(self, prompt, num_images=4, guidance_scale=7.5, num_inference_steps=50):
images = self.pipe(
prompt,
num_images_per_prompt=num_images,
guidance_scale=guidance_scale,
num_inference_steps=num_inference_steps
).images
return images
def batch_generate(self, prompts):
all_images = []
for prompt in prompts:
images = self.generate_concept(prompt)
all_images.extend(images)
return all_images
# Usage
generator = AIMonsterConceptGenerator()
prompts = [
"A bioluminescent deep sea creature with multiple eyes and tentacles, cinematic lighting",
"A massive rock golem with crystals growing from its body, epic scale, mountain background",
"A shape-shifting alien made of liquid metal, reflective surface, sci-fi setting"
]
concept_images = generator.batch_generate(prompts)
# Save or display images
for i, img in enumerate(concept_images):
img.save(f"monster_concept_{i}.png")Last updated