ljp commited on
Commit
dff0fb6
1 Parent(s): 4049887

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +10 -9
README.md CHANGED
@@ -50,7 +50,7 @@ From left to right: Input image, Masked image, SDXL inpainting, Ours.
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(pipeline_sd3_controlnet_inpainting.py and controlnet_sd3.py) from either the current repo or 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:
@@ -59,8 +59,9 @@ Step3: And then you can run demo.py or following:
59
  from diffusers.utils import load_image, check_min_version
60
  import torch
61
 
62
- from pipeline_sd3_controlnet_inpainting import StableDiffusion3ControlNetInpaintingPipeline, one_image_and_mask
63
  from controlnet_sd3 import SD3ControlNetModel
 
64
 
65
  check_min_version("0.29.2")
66
 
@@ -68,6 +69,7 @@ check_min_version("0.29.2")
68
  controlnet = SD3ControlNetModel.from_pretrained(
69
  "alimama-creative/SD3-Controlnet-Inpainting",
70
  use_safetensors=True,
 
71
  )
72
  pipe = StableDiffusion3ControlNetInpaintingPipeline.from_pretrained(
73
  "stabilityai/stable-diffusion-3-medium-diffusers",
@@ -80,18 +82,17 @@ pipe.to("cuda")
80
 
81
  # Load image
82
  image = load_image(
83
- "https://huggingface.co/alimama-creative/SD3-Controlnet-Inpainting/resolve/main/images/prod.png"
84
  )
85
  mask = load_image(
86
- "https://huggingface.co/alimama-creative/SD3-Controlnet-Inpainting/resolve/main/images/mask.jpeg"
87
  )
88
 
89
  # Set args
90
  width = 1024
91
  height = 1024
92
  prompt="a woman wearing a white jacket, black hat and black pants is standing in a field, the hat writes SD3"
93
- generator = torch.Generator(device="cuda").manual_seed(48)
94
- input_dict = one_image_and_mask(image, mask, size=(width, height), latent_scale=pipe.vae_scale_factor, invert_mask = True)
95
 
96
  # Inference
97
  res_image = pipe(
@@ -99,15 +100,15 @@ res_image = pipe(
99
  prompt=prompt,
100
  height=height,
101
  width=width,
102
- control_image= input_dict['pil_masked_image'], # H, W, C,
103
- control_mask=input_dict["mask"] > 0.5, # B,1,H,W
104
  num_inference_steps=28,
105
  generator=generator,
106
  controlnet_conditioning_scale=0.95,
107
  guidance_scale=7,
108
  ).images[0]
109
 
110
- res_image.save(f'res.png')
111
  ```
112
 
113
 
 
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:
 
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
 
 
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",
 
82
 
83
  # Load image
84
  image = load_image(
85
+ "https://huggingface.co/alimama-creative/SD3-Controlnet-Inpainting/blob/main/images/prod.png"
86
  )
87
  mask = load_image(
88
+ "https://huggingface.co/alimama-creative/SD3-Controlnet-Inpainting/blob/main/images/mask.jpeg"
89
  )
90
 
91
  # Set args
92
  width = 1024
93
  height = 1024
94
  prompt="a woman wearing a white jacket, black hat and black pants is standing in a field, the hat writes SD3"
95
+ generator = torch.Generator(device="cuda").manual_seed(24)
 
96
 
97
  # Inference
98
  res_image = pipe(
 
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