MCPcopy Index your code
hub / github.com/modelscope/DiffSynth-Studio / generate

Function generate

examples/EntityControl/entity_transfer.py:30–56  ·  view source on GitHub ↗
(pipe: FluxImagePipeline, source_image, target_image, mask, height, width, prompt, entity_prompt, image_save_path, mask_save_path, seed=0)

Source from the content-addressed store, hash-verified

28
29
30def generate(pipe: FluxImagePipeline, source_image, target_image, mask, height, width, prompt, entity_prompt, image_save_path, mask_save_path, seed=0):
31 input_mask = Image.new('RGB', (width * 2, height))
32 input_mask.paste(mask.resize((width, height), resample=Image.NEAREST).convert('RGB'), (width, 0))
33
34 input_image = Image.new('RGB', (width * 2, height))
35 input_image.paste(source_image.resize((width, height)).convert('RGB'), (0, 0))
36 input_image.paste(target_image.resize((width, height)).convert('RGB'), (width, 0))
37
38 image = pipe(
39 prompt=prompt,
40 input_image=input_image,
41 cfg_scale=3.0,
42 negative_prompt="",
43 num_inference_steps=50,
44 embedded_guidance=3.5,
45 seed=seed,
46 height=height,
47 width=width * 2,
48 eligen_entity_prompts=[entity_prompt],
49 eligen_entity_masks=[input_mask],
50 enable_eligen_on_negative=False,
51 enable_eligen_inpaint=True,
52 )
53 target_image = image.crop((width, 0, 2 * width, height))
54 target_image.save(image_save_path)
55 visualize_masks(target_image, [mask], [entity_prompt], mask_save_path)
56 return target_image
57
58
59pipe = build_pipeline()

Callers 1

entity_transfer.pyFile · 0.85

Calls 2

visualize_masksFunction · 0.90
saveMethod · 0.80

Tested by

no test coverage detected