zhiweili commited on
Commit
b6c2393
·
1 Parent(s): 7397cc1

try to change t2i

Browse files
Files changed (1) hide show
  1. app_haircolor_pix2pix.py +4 -12
app_haircolor_pix2pix.py CHANGED
@@ -33,8 +33,10 @@ DEFAULT_NEGATIVE_PROMPT = "worst quality, normal quality, low quality, low res,
33
 
34
  DEFAULT_CATEGORY = "hair"
35
 
 
 
36
  adapter = T2IAdapter.from_pretrained(
37
- "TencentARC/t2iadapter_canny_sd15v2",
38
  torch_dtype=torch.float16,
39
  varient="fp16",
40
  )
@@ -67,7 +69,7 @@ def image_to_image(
67
  run_task_time = 0
68
  time_cost_str = ''
69
  run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
70
- canny_image = custom_canny_detector(input_image)
71
 
72
  cond_image = canny_image
73
  cond_scale = cond_scale1
@@ -91,16 +93,6 @@ def image_to_image(
91
 
92
  return generated_image, time_cost_str
93
 
94
- def custom_canny_detector(image):
95
- image = np.array(image)
96
-
97
- low_threshold = 100
98
- high_threshold = 200
99
-
100
- image = cv2.Canny(image, low_threshold, high_threshold)
101
- image = Image.fromarray(image)
102
- return image
103
-
104
  def get_time_cost(run_task_time, time_cost_str):
105
  now_time = int(time.time()*1000)
106
  if run_task_time == 0:
 
33
 
34
  DEFAULT_CATEGORY = "hair"
35
 
36
+ canny_detector = CannyDetector()
37
+
38
  adapter = T2IAdapter.from_pretrained(
39
+ "TencentARC/t2i-adapter-canny-sdxl-1.0",
40
  torch_dtype=torch.float16,
41
  varient="fp16",
42
  )
 
69
  run_task_time = 0
70
  time_cost_str = ''
71
  run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
72
+ canny_image = canny_detector(input_image)
73
 
74
  cond_image = canny_image
75
  cond_scale = cond_scale1
 
93
 
94
  return generated_image, time_cost_str
95
 
 
 
 
 
 
 
 
 
 
 
96
  def get_time_cost(run_task_time, time_cost_str):
97
  now_time = int(time.time()*1000)
98
  if run_task_time == 0: