zhiweili commited on
Commit
37a1718
1 Parent(s): c4a2b6e
Files changed (1) hide show
  1. app_haircolor_inpaint_15.py +10 -5
app_haircolor_inpaint_15.py CHANGED
@@ -53,6 +53,10 @@ controlnet = [
53
  "lllyasviel/control_v11p_sd15_softedge",
54
  torch_dtype=torch.float16,
55
  ),
 
 
 
 
56
  ]
57
 
58
  basepipeline = StableDiffusionControlNetInpaintPipeline.from_pretrained(
@@ -79,15 +83,16 @@ def image_to_image(
79
  generate_size: int,
80
  cond_scale1: float = 1.2,
81
  cond_scale2: float = 1.2,
 
82
  ):
83
  run_task_time = 0
84
  time_cost_str = ''
85
  run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
86
- # canny_image = canny_detector(input_image, int(generate_size*0.375), generate_size)
87
- lineart_image = lineart_detector(input_image, int(generate_size*0.375), generate_size)
88
  run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
89
- pidiNet_image = pidiNet_detector(input_image, int(generate_size*0.5), generate_size)
90
- control_image = [lineart_image, pidiNet_image]
91
 
92
  generator = torch.Generator(device=DEVICE).manual_seed(seed)
93
  generated_image = basepipeline(
@@ -101,7 +106,7 @@ def image_to_image(
101
  width=generate_size,
102
  guidance_scale=guidance_scale,
103
  num_inference_steps=num_steps,
104
- controlnet_conditioning_scale=[cond_scale1, cond_scale2]
105
  ).images[0]
106
 
107
  run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
 
53
  "lllyasviel/control_v11p_sd15_softedge",
54
  torch_dtype=torch.float16,
55
  ),
56
+ ControlNetModel.from_pretrained(
57
+ "lllyasviel/control_v11p_sd15_canny",
58
+ torch_dtype=torch.float16,
59
+ ),
60
  ]
61
 
62
  basepipeline = StableDiffusionControlNetInpaintPipeline.from_pretrained(
 
83
  generate_size: int,
84
  cond_scale1: float = 1.2,
85
  cond_scale2: float = 1.2,
86
+ cond_scale3: float = 1.2,
87
  ):
88
  run_task_time = 0
89
  time_cost_str = ''
90
  run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
91
+ canny_image = canny_detector(input_image, int(generate_size*1), generate_size)
92
+ lineart_image = lineart_detector(input_image, int(generate_size*1), generate_size)
93
  run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
94
+ pidiNet_image = pidiNet_detector(input_image, int(generate_size*1), generate_size)
95
+ control_image = [lineart_image, pidiNet_image, canny_image]
96
 
97
  generator = torch.Generator(device=DEVICE).manual_seed(seed)
98
  generated_image = basepipeline(
 
106
  width=generate_size,
107
  guidance_scale=guidance_scale,
108
  num_inference_steps=num_steps,
109
+ controlnet_conditioning_scale=[cond_scale1, cond_scale2, cond_scale3],
110
  ).images[0]
111
 
112
  run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)