File size: 1,242 Bytes
0ed6b0e | 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 | import torch
from PIL import Image
from diffsynth import load_state_dict
from diffsynth.pipelines.boogu_image import BooguImagePipeline, ModelConfig
pipe = BooguImagePipeline.from_pretrained(
torch_dtype=torch.bfloat16,
device="cuda",
model_configs=[
ModelConfig(model_id="Boogu/Boogu-Image-0.1-Edit", origin_file_pattern="transformer/*.safetensors"),
ModelConfig(model_id="Boogu/Boogu-Image-0.1-Edit", origin_file_pattern="mllm/*.safetensors"),
ModelConfig(model_id="Boogu/Boogu-Image-0.1-Edit", origin_file_pattern="vae/*.safetensors"),
],
processor_config=ModelConfig(model_id="Boogu/Boogu-Image-0.1-Edit", origin_file_pattern="mllm/"),
)
state_dict = load_state_dict("models/train/Boogu-Image-0.1-Edit_full/epoch-1.safetensors")
pipe.dit.load_state_dict(state_dict, strict=False)
prompt = "将裙子改为粉色"
edit_image = Image.open("data/diffsynth_example_dataset/boogu_image/Boogu-Image-0.1-Edit/edit/image1.jpg").convert("RGB")
output = pipe(
prompt=prompt,
negative_prompt="",
edit_image=edit_image,
height=1024,
width=1024,
seed=42,
rand_device="cuda",
num_inference_steps=50,
cfg_scale=1.0,
)
output.save("image_Boogu-Image-0.1-Edit_full.jpg")
|