()
| 124 | |
| 125 | |
| 126 | def 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 |
no test coverage detected