hirol commited on
Commit
e1197fa
1 Parent(s): 67e6a13

Update generate_img.py

Browse files
Files changed (1) hide show
  1. generate_img.py +19 -20
generate_img.py CHANGED
@@ -5,24 +5,6 @@ import numpy as np
5
  from pipeline_stable_diffusion_controlnet_inpaint import *
6
  from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_controlnet import *
7
  import random
8
- #model1
9
- controlnet = ControlNetModel.from_pretrained("lllyasviel/control_v11f1p_sd15_depth", torch_dtype=torch.float16)
10
- pipe = StableDiffusionControlNetInpaintPipeline.from_pretrained(
11
- "./models/Any-inpainting", controlnet=controlnet, torch_dtype=torch.float16,cache_dir='./models'
12
- )
13
-
14
- pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
15
- pipe.to('cuda')
16
-
17
- # model2
18
- controlnet1 = ControlNetModel.from_pretrained("lllyasviel/control_v11p_sd15_scribble",torch_dtype=torch.float16)
19
-
20
- pipe1 = StableDiffusionControlNetInpaintPipeline.from_pretrained(
21
- "./models/Any-inpainting", controlnet=controlnet1, torch_dtype=torch.float16
22
- )
23
-
24
- pipe1.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
25
- pipe1.to('cuda')
26
 
27
  def make_inpaint_condition(image, image_mask):
28
  image = np.array(image.convert("RGB")).astype(np.float32) / 255.0
@@ -35,7 +17,16 @@ def make_inpaint_condition(image, image_mask):
35
 
36
 
37
  def generate_image(prompt:str, negative_prompt:str, openpose_image, original_image, mask_image):
 
 
 
 
 
 
38
 
 
 
 
39
  a = random.randint(10000,90000)
40
  generator = torch.manual_seed(a)
41
  # control_image = make_inpaint_condition(original_image, mask_image)
@@ -59,8 +50,16 @@ def generate_image(prompt:str, negative_prompt:str, openpose_image, original_ima
59
  def generate_image_sketch(prompt: str, negative_prompt: str, openpose_image, original_image, mask_image):
60
  b = random.randint(10000, 90000)
61
  generator = torch.manual_seed(b)
62
- # control_image = make_inpaint_condition(original_image, mask_image)
63
- # images = [openpose_image, control_image]
 
 
 
 
 
 
 
 
64
 
65
  image = pipe1(
66
  prompt=prompt,
 
5
  from pipeline_stable_diffusion_controlnet_inpaint import *
6
  from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_controlnet import *
7
  import random
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
  def make_inpaint_condition(image, image_mask):
10
  image = np.array(image.convert("RGB")).astype(np.float32) / 255.0
 
17
 
18
 
19
  def generate_image(prompt:str, negative_prompt:str, openpose_image, original_image, mask_image):
20
+ # model1
21
+ controlnet = ControlNetModel.from_pretrained("lllyasviel/control_v11p_sd15_openpose", torch_dtype=torch.float16,
22
+ cache_dir='./models')
23
+ pipe = StableDiffusionControlNetInpaintPipeline.from_pretrained(
24
+ "./models/Any-inpainting", controlnet=controlnet, torch_dtype=torch.float16, cache_dir='./models'
25
+ )
26
 
27
+ pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
28
+ pipe.to('cuda')
29
+
30
  a = random.randint(10000,90000)
31
  generator = torch.manual_seed(a)
32
  # control_image = make_inpaint_condition(original_image, mask_image)
 
50
  def generate_image_sketch(prompt: str, negative_prompt: str, openpose_image, original_image, mask_image):
51
  b = random.randint(10000, 90000)
52
  generator = torch.manual_seed(b)
53
+ # model2
54
+ controlnet1 = ControlNetModel.from_pretrained("lllyasviel/control_v11p_sd15_scribble", torch_dtype=torch.float16,
55
+ cache_dir='./models')
56
+
57
+ pipe1 = StableDiffusionControlNetInpaintPipeline.from_pretrained(
58
+ "./models/Any-inpainting", controlnet=controlnet1, torch_dtype=torch.float16, cache_dir='./models'
59
+ )
60
+
61
+ pipe1.scheduler = UniPCMultistepScheduler.from_config(pipe1.scheduler.config)
62
+ pipe1.to('cuda')
63
 
64
  image = pipe1(
65
  prompt=prompt,