【Diffusers】OmniGen ③ 写真から人物を抽出して新たな画像を生成する

元画像

FLUX.1-devで2枚の画像を作成しました。

結果

それぞれの画像から人物を抽出して新たな画像を生成しました。

素晴らしい結果でした。
なかなかこれができるモデルは他にありません。

はじめに

OmniGenはいろいろなことができるモデルです。
過去に2本の記事を書いています。
touch-sp.hatenablog.com
touch-sp.hatenablog.com

Pythonスクリプト

import torch
from diffusers import OmniGenPipeline
from diffusers.utils import load_image 

pipe = OmniGenPipeline.from_pretrained(
    "Shitao/OmniGen-v1-diffusers",
    torch_dtype=torch.bfloat16
).to("cuda")

prompt="Two woman are sitting side by side on a sofa in a cafe. One woman is the woman in <img><|image_1|></img>. The other woman is the woman in <img><|image_2|></img>"
input_image_1 = load_image("lady1.jpg")
input_image_2 = load_image("lady2.jpg")
input_images=[input_image_1, input_image_2]

seed = 666
generator = torch.manual_seed(seed)
image = pipe(
    prompt=prompt, 
    input_images=input_images, 
    height=1024,
    width=1024,
    guidance_scale=2.5, 
    img_guidance_scale=1.6,
    generator=generator
).images[0]

image.save("output.png")