()
| 196 | |
| 197 | |
| 198 | def example_7(): |
| 199 | model_manager = ModelManager(torch_dtype=torch.bfloat16, model_id_list=[ |
| 200 | "FLUX.1-dev", |
| 201 | "InstantX/FLUX.1-dev-Controlnet-Union-alpha", |
| 202 | "alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Beta", |
| 203 | "jasperai/Flux.1-dev-Controlnet-Upscaler", |
| 204 | ]) |
| 205 | pipe = FluxImagePipeline.from_model_manager(model_manager, controlnet_config_units=[ |
| 206 | ControlNetConfigUnit( |
| 207 | processor_id="inpaint", |
| 208 | model_path="models/ControlNet/alimama-creative/FLUX.1-dev-Controlnet-Inpainting-Beta/diffusion_pytorch_model.safetensors", |
| 209 | scale=0.9 |
| 210 | ), |
| 211 | ControlNetConfigUnit( |
| 212 | processor_id="canny", |
| 213 | model_path="models/ControlNet/InstantX/FLUX.1-dev-Controlnet-Union-alpha/diffusion_pytorch_model.safetensors", |
| 214 | scale=0.5 |
| 215 | ), |
| 216 | ]) |
| 217 | |
| 218 | image_1 = pipe( |
| 219 | prompt="a beautiful Asian woman and a cat on a bed. The woman wears a dress.", |
| 220 | height=1024, width=1024, |
| 221 | seed=100 |
| 222 | ) |
| 223 | image_1.save("image_13.jpg") |
| 224 | |
| 225 | mask_global = np.zeros((1024, 1024, 3), dtype=np.uint8) |
| 226 | mask_global = Image.fromarray(mask_global) |
| 227 | mask_global.save("mask_13_global.jpg") |
| 228 | |
| 229 | mask_1 = np.zeros((1024, 1024, 3), dtype=np.uint8) |
| 230 | mask_1[300:-100, 30: 450] = 255 |
| 231 | mask_1 = Image.fromarray(mask_1) |
| 232 | mask_1.save("mask_13_1.jpg") |
| 233 | |
| 234 | mask_2 = np.zeros((1024, 1024, 3), dtype=np.uint8) |
| 235 | mask_2[500:-100, -400:] = 255 |
| 236 | mask_2[-200:-100, -500:-400] = 255 |
| 237 | mask_2 = Image.fromarray(mask_2) |
| 238 | mask_2.save("mask_13_2.jpg") |
| 239 | |
| 240 | image_2 = pipe( |
| 241 | prompt="a beautiful Asian woman and a cat on a bed. The woman wears a dress.", |
| 242 | controlnet_image=image_1, controlnet_inpaint_mask=mask_global, |
| 243 | local_prompts=["an orange cat, highly detailed", "a girl wearing a red camisole"], masks=[mask_1, mask_2], mask_scales=[10.0, 10.0], |
| 244 | height=1024, width=1024, |
| 245 | seed=101 |
| 246 | ) |
| 247 | image_2.save("image_14.jpg") |
| 248 | |
| 249 | model_manager.load_lora("models/lora/FLUX-dev-lora-AntiBlur.safetensors", lora_alpha=2) |
| 250 | image_3 = pipe( |
| 251 | prompt="a beautiful Asian woman wearing a red camisole and an orange cat on a bed. clear background.", |
| 252 | negative_prompt="blur, blurry", |
| 253 | input_image=image_2, denoising_strength=0.7, |
| 254 | height=1024, width=1024, |
| 255 | cfg_scale=2.0, num_inference_steps=50, |
no test coverage detected