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

Function example_5

examples/ControlNet/flux_controlnet.py:126–154  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

124
125
126def example_5():
127 model_manager = ModelManager(torch_dtype=torch.bfloat16, model_id_list=["FLUX.1-dev", "alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Beta"])
128 pipe = FluxImagePipeline.from_model_manager(model_manager, controlnet_config_units=[
129 ControlNetConfigUnit(
130 processor_id="inpaint",
131 model_path="models/ControlNet/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Beta/diffusion_pytorch_model.safetensors",
132 scale=0.9
133 ),
134 ])
135
136 image_1 = pipe(
137 prompt="a cat sitting on a chair",
138 height=1024, width=1024,
139 seed=8
140 )
141 image_1.save("image_9.jpg")
142
143 mask = np.zeros((1024, 1024, 3), dtype=np.uint8)
144 mask[100:350, 350: -300] = 255
145 mask = Image.fromarray(mask)
146 mask.save("mask_9.jpg")
147
148 image_2 = pipe(
149 prompt="a cat sitting on a chair, wearing sunglasses",
150 controlnet_image=image_1, controlnet_inpaint_mask=mask,
151 height=1024, width=1024,
152 seed=9
153 )
154 image_2.save("image_10.jpg")
155
156
157

Callers 1

flux_controlnet.pyFile · 0.70

Calls 4

ModelManagerClass · 0.90
saveMethod · 0.80
from_model_managerMethod · 0.45

Tested by

no test coverage detected