prompt = "anime character portrait, studio ghibli style, detailed, beautiful"
negative = "realistic, photo, 3d render"
from diffusers.utils import load_image
# पोज़ संदर्भ लोड करें
pose_image = load_image("pose_reference.jpg")
# चेहरा और पोज़ दोनों के साथ जेनरेट करें
image = pipe(
prompt="person in action pose, dynamic, high quality",
face_emb=face_emb,
face_kps=face_kps,
image=pose_image, # पोज़ संदर्भ
controlnet_conditioning_scale=0.8,
num_inference_steps=30
).images[0]
import os
from pathlib import Path
def batch_generate(face_image_path, prompts, output_dir):
# चेहरा लोड करें
face_cv = cv2.imread(face_image_path)
face_info = app.get(face_cv)[0]
face_emb = face_info.normed_embedding
face_kps = face_info.kps
os.makedirs(output_dir, exist_ok=True)
for i, prompt in enumerate(prompts):
print(f"Generating {i+1}/{len(prompts)}: {prompt[:50]}...")
image = pipe(
prompt=prompt,
negative_prompt="ugly, blurry, deformed",
face_emb=face_emb,
face_kps=face_kps,
num_inference_steps=30
).images[0]
image.save(f"{output_dir}/output_{i:03d}.png")
# उपयोग
prompts = [
"astronaut in space suit, Earth background",
"medieval knight in armor",
"scientist in laboratory",
"chef in restaurant kitchen",
"athlete on sports field"
]
batch_generate("my_face.jpg", prompts, "./outputs")
# कम शक्ति - अधिक स्टाइल, कम पहचान
image_stylized = pipe(
prompt=prompt,
face_emb=face_emb,
ip_adapter_scale=0.4, # Low
num_inference_steps=30
).images[0]
# अधिक शक्ति - अधिक पहचान, कम स्टाइल
image_faithful = pipe(
prompt=prompt,
face_emb=face_emb,
ip_adapter_scale=0.9, # High
num_inference_steps=30
).images[0]
# अनुकूलन सक्षम करें
pipe.enable_model_cpu_offload()
pipe.enable_vae_slicing()
# या बहुत कम VRAM के लिए क्रमिक ऑफलोड का उपयोग करें
pipe.enable_sequential_cpu_offload()