-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathStep1X-Edit.py
More file actions
25 lines (22 loc) · 950 Bytes
/
Step1X-Edit.py
File metadata and controls
25 lines (22 loc) · 950 Bytes
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
import torch
from diffsynth.pipelines.flux_image import FluxImagePipeline, ModelConfig
from diffsynth import load_state_dict
from PIL import Image
pipe = FluxImagePipeline.from_pretrained(
torch_dtype=torch.bfloat16,
device="cuda",
model_configs=[
ModelConfig(model_id="Qwen/Qwen2.5-VL-7B-Instruct", origin_file_pattern="model-*.safetensors"),
ModelConfig(model_id="stepfun-ai/Step1X-Edit", origin_file_pattern="step1x-edit-i1258.safetensors"),
ModelConfig(model_id="stepfun-ai/Step1X-Edit", origin_file_pattern="vae.safetensors"),
],
)
state_dict = load_state_dict("models/train/Step1X-Edit_full/epoch-0.safetensors")
pipe.dit.load_state_dict(state_dict)
image = pipe(
prompt="Make the dog turn its head around.",
step1x_reference_image=Image.open("data/example_image_dataset/2.jpg").resize((768, 768)),
height=768, width=768, cfg_scale=6,
seed=0
)
image.save("image_Step1X-Edit_full.jpg")