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

Function example

examples/EntityControl/entity_control.py:7–26  ·  view source on GitHub ↗
(pipe, seeds, example_id, global_prompt, entity_prompts)

Source from the content-addressed store, hash-verified

5import torch
6
7def example(pipe, seeds, example_id, global_prompt, entity_prompts):
8 dataset_snapshot_download(dataset_id="DiffSynth-Studio/examples_in_diffsynth", local_dir="./", allow_file_pattern=f"data/examples/eligen/entity_control/example_{example_id}/*.png")
9 masks = [Image.open(f"./data/examples/eligen/entity_control/example_{example_id}/{i}.png").convert('RGB') for i in range(len(entity_prompts))]
10 negative_prompt = "worst quality, low quality, monochrome, zombie, interlocked fingers, Aissist, cleavage, nsfw,"
11 for seed in seeds:
12 # generate image
13 image = pipe(
14 prompt=global_prompt,
15 cfg_scale=3.0,
16 negative_prompt=negative_prompt,
17 num_inference_steps=50,
18 embedded_guidance=3.5,
19 seed=seed,
20 height=1024,
21 width=1024,
22 eligen_entity_prompts=entity_prompts,
23 eligen_entity_masks=masks,
24 )
25 image.save(f"eligen_example_{example_id}_{seed}.png")
26 visualize_masks(image, masks, entity_prompts, f"eligen_example_{example_id}_mask_{seed}.png")
27
28# download and load model
29model_manager = ModelManager(torch_dtype=torch.bfloat16, device="cuda", model_id_list=["FLUX.1-dev"])

Callers 1

entity_control.pyFile · 0.70

Calls 2

visualize_masksFunction · 0.90
saveMethod · 0.80

Tested by

no test coverage detected