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

Function example_6

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

Source from the content-addressed store, hash-verified

156
157
158def example_6():
159 model_manager = ModelManager(torch_dtype=torch.bfloat16, model_id_list=[
160 "FLUX.1-dev",
161 "jasperai/Flux.1-dev-Controlnet-Surface-Normals",
162 "alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Beta"
163 ])
164 pipe = FluxImagePipeline.from_model_manager(model_manager, controlnet_config_units=[
165 ControlNetConfigUnit(
166 processor_id="inpaint",
167 model_path="models/ControlNet/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Beta/diffusion_pytorch_model.safetensors",
168 scale=0.9
169 ),
170 ControlNetConfigUnit(
171 processor_id="normal",
172 model_path="models/ControlNet/jasperai/Flux.1-dev-Controlnet-Surface-Normals/diffusion_pytorch_model.safetensors",
173 scale=0.6
174 ),
175 ])
176
177 image_1 = pipe(
178 prompt="a beautiful Asian woman looking at the sky, wearing a blue t-shirt.",
179 height=1024, width=1024,
180 seed=10
181 )
182 image_1.save("image_11.jpg")
183
184 mask = np.zeros((1024, 1024, 3), dtype=np.uint8)
185 mask[-400:, 10:-40] = 255
186 mask = Image.fromarray(mask)
187 mask.save("mask_11.jpg")
188
189 image_2 = pipe(
190 prompt="a beautiful Asian woman looking at the sky, wearing a yellow t-shirt.",
191 controlnet_image=image_1, controlnet_inpaint_mask=mask,
192 height=1024, width=1024,
193 seed=11
194 )
195 image_2.save("image_12.jpg")
196
197
198def example_7():

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