Я хочу сохранить исходный внешний вид, стиль и фон , но только /> Я пытаюсь регенерировать отдельные видео кадры < /strong>, используя StablediffusionControlnetimg2imgpipeline < /code> с открытым вводом в качестве управляющего ввода.
Моя цель - сохранить исходное изображение (лицо, одежда, фоновая) < /strong>, настраивая только человеческий поклон, чтобы соответствовать новому скелету. < /prilels < />> < />
Код: Выделить всё
controlnet_pose = ControlNetModel.from_pretrained(
"lllyasviel/control_v11p_sd15_openpose", torch_dtype=torch.float16
).to("cuda")
pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5",
controlnet=controlnet_pose,
torch_dtype=torch.float16
).to("cuda")
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
pipe.enable_model_cpu_offload()
pipe.enable_xformers_memory_efficient_attention()
def regenerate_frame(frame_number):
image_path = os.path.join(image_folder, f"frame_{frame_number}.png")
pose_path = os.path.join(image_folder, f"pose_{frame_number}.png")
ref_image = Image.open(image_path).convert("RGB").resize((512, 512))
pose_image = Image.open(pose_path).convert("RGB").resize((512, 512))
prompt = "same person, same style, same clothes, same background, realistic"
negative_prompt = "blurry, deformed, inconsistent face, wrong pose, bad anatomy"
try:
result = pipe(
prompt=prompt,
negative_prompt=negative_prompt,
image=ref_image,
control_image=pose_image,
strength=0.3,
num_inference_steps=30,
guidance_scale=7.5
).images[0]
except Exception as e:
print("Error occurred:", e)
return
result.save(...)
Идентичность лица не сохраняется. /> < /ul>
я попробовал: < /p>
снижение силы < /code> (до 0.2–0.4) < /p>
< /li>
gudics_scale < /code> < /p>
< /li>
< /p>
< /li li>
Но результат все еще нестабилен. < /p>
< /li>
< /ul>
Подробнее здесь: https://stackoverflow.com/questions/796 ... se-pose-co