ljp commited on
Commit
c676336
•
1 Parent(s): b50e15b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +21 -28
README.md CHANGED
@@ -9,7 +9,11 @@ tags:
9
  library_name: diffusers
10
  ---
11
 
12
- # SD3 ControlNet Inpainting
 
 
 
 
13
 
14
  ![SD3](images/sd3_compressed.png)
15
 
@@ -19,6 +23,8 @@ library_name: diffusers
19
 
20
  <center><i>a person wearing a white shoe, carrying a white bucket with text "alibaba" on it</i></center>
21
 
 
 
22
  Finetuned controlnet inpainting model based on sd3-medium, the inpainting model offers several advantages:
23
 
24
  * Leveraging the SD3 16-channel VAE and high-resolution generation capability at 1024, the model effectively preserves the integrity of non-inpainting regions, including text.
@@ -48,28 +54,21 @@ From left to right: Input image, Masked image, SDXL inpainting, Ours.
48
 
49
  # Using with Diffusers
50
 
51
- Step1: Make sure you upgrade to the latest version of diffusers(>=0.29.2): pip install -U diffusers.
52
 
53
- Step2: Download the two required Python files from [GitHub](https://github.com/JPlin/SD3-Controlnet-Inpainting).
54
- (We will merge this Feature to official Diffusers.)
55
-
56
- Step3: And then you can run demo.py or following:
57
 
58
  ``` python
59
- from diffusers.utils import load_image, check_min_version
60
  import torch
 
 
 
61
 
62
- # Local File
63
- from controlnet_sd3 import SD3ControlNetModel
64
- from pipeline_stable_diffusion_3_controlnet_inpainting import StableDiffusion3ControlNetInpaintingPipeline
65
-
66
- check_min_version("0.29.2")
67
-
68
- # Build model
69
  controlnet = SD3ControlNetModel.from_pretrained(
70
- "alimama-creative/SD3-Controlnet-Inpainting",
71
- use_safetensors=True,
72
- extra_conditioning_channels=1,
73
  )
74
  pipe = StableDiffusion3ControlNetInpaintingPipeline.from_pretrained(
75
  "stabilityai/stable-diffusion-3-medium-diffusers",
@@ -80,35 +79,29 @@ pipe.text_encoder.to(torch.float16)
80
  pipe.controlnet.to(torch.float16)
81
  pipe.to("cuda")
82
 
83
- # Load image
84
  image = load_image(
85
  "https://huggingface.co/alimama-creative/SD3-Controlnet-Inpainting/resolve/main/images/dog.png"
86
  )
87
  mask = load_image(
88
  "https://huggingface.co/alimama-creative/SD3-Controlnet-Inpainting/resolve/main/images/dog_mask.png"
89
  )
90
-
91
- # Set args
92
  width = 1024
93
  height = 1024
94
- prompt="A cat is sitting next to a puppy."
95
  generator = torch.Generator(device="cuda").manual_seed(24)
96
-
97
- # Inference
98
  res_image = pipe(
99
- negative_prompt='deformed, distorted, disfigured, poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, mutated hands and fingers, disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, NSFW',
100
  prompt=prompt,
101
  height=height,
102
  width=width,
103
- control_image = image,
104
- control_mask = mask,
105
  num_inference_steps=28,
106
  generator=generator,
107
  controlnet_conditioning_scale=0.95,
108
  guidance_scale=7,
109
  ).images[0]
110
-
111
- res_image.save(f'sd3.png')
112
  ```
113
 
114
 
 
9
  library_name: diffusers
10
  ---
11
 
12
+ # Updates
13
+
14
+ ✨🎉 This model has been merged into [Diffusers](https://moon-ci-docs.huggingface.co/docs/diffusers/pr_9099/en/api/pipelines/controlnet_sd3) and can now be used conveniently. 💡 🎉✨
15
+
16
+ # Examples
17
 
18
  ![SD3](images/sd3_compressed.png)
19
 
 
23
 
24
  <center><i>a person wearing a white shoe, carrying a white bucket with text "alibaba" on it</i></center>
25
 
26
+ ## SD3 Controlnet Inpainting
27
+
28
  Finetuned controlnet inpainting model based on sd3-medium, the inpainting model offers several advantages:
29
 
30
  * Leveraging the SD3 16-channel VAE and high-resolution generation capability at 1024, the model effectively preserves the integrity of non-inpainting regions, including text.
 
54
 
55
  # Using with Diffusers
56
 
57
+ Install from source and Run
58
 
59
+ ``` Shell
60
+ pip uninstall diffusers
61
+ pip install git+https://github.com/huggingface/diffusers
62
+ ```
63
 
64
  ``` python
 
65
  import torch
66
+ from diffusers.utils import load_image, check_min_version
67
+ from diffusers.pipelines import StableDiffusion3ControlNetInpaintingPipeline
68
+ from diffusers.models.controlnet_sd3 import SD3ControlNetModel
69
 
 
 
 
 
 
 
 
70
  controlnet = SD3ControlNetModel.from_pretrained(
71
+ "alimama-creative/SD3-Controlnet-Inpainting", use_safetensors=True, extra_conditioning_channels=1
 
 
72
  )
73
  pipe = StableDiffusion3ControlNetInpaintingPipeline.from_pretrained(
74
  "stabilityai/stable-diffusion-3-medium-diffusers",
 
79
  pipe.controlnet.to(torch.float16)
80
  pipe.to("cuda")
81
 
 
82
  image = load_image(
83
  "https://huggingface.co/alimama-creative/SD3-Controlnet-Inpainting/resolve/main/images/dog.png"
84
  )
85
  mask = load_image(
86
  "https://huggingface.co/alimama-creative/SD3-Controlnet-Inpainting/resolve/main/images/dog_mask.png"
87
  )
 
 
88
  width = 1024
89
  height = 1024
90
+ prompt = "A cat is sitting next to a puppy."
91
  generator = torch.Generator(device="cuda").manual_seed(24)
 
 
92
  res_image = pipe(
93
+ negative_prompt="deformed, distorted, disfigured, poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, mutated hands and fingers, disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, NSFW",
94
  prompt=prompt,
95
  height=height,
96
  width=width,
97
+ control_image=image,
98
+ control_mask=mask,
99
  num_inference_steps=28,
100
  generator=generator,
101
  controlnet_conditioning_scale=0.95,
102
  guidance_scale=7,
103
  ).images[0]
104
+ res_image.save(f"sd3.png")
 
105
  ```
106
 
107