Spaces:
Running
Running
zhiweili
commited on
Commit
·
1d8e854
1
Parent(s):
3a274a9
test single adapter
Browse files
app_haircolor_inpaint_adapter_15.py
CHANGED
@@ -3,6 +3,7 @@ import gradio as gr
|
|
3 |
import time
|
4 |
import torch
|
5 |
import numpy as np
|
|
|
6 |
|
7 |
from PIL import Image
|
8 |
from segment_utils import(
|
@@ -91,12 +92,13 @@ def image_to_image(
|
|
91 |
run_task_time = 0
|
92 |
time_cost_str = ''
|
93 |
run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
|
94 |
-
canny_image = canny_detector(input_image, int(generate_size*1), generate_size)
|
|
|
95 |
# lineart_image = lineart_detector(input_image, int(generate_size*1), generate_size)
|
96 |
# run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
|
97 |
pidiNet_image = pidiNet_detector(input_image, int(generate_size*1), generate_size)
|
98 |
-
cond_image = [canny_image, pidiNet_image]
|
99 |
-
cond_scale = [cond_scale1, cond_scale2]
|
100 |
|
101 |
cond_image = canny_image
|
102 |
cond_scale = cond_scale1
|
@@ -130,6 +132,16 @@ def make_inpaint_condition(image, image_mask):
|
|
130 |
image = torch.from_numpy(image)
|
131 |
return image
|
132 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
def get_time_cost(run_task_time, time_cost_str):
|
134 |
now_time = int(time.time()*1000)
|
135 |
if run_task_time == 0:
|
|
|
3 |
import time
|
4 |
import torch
|
5 |
import numpy as np
|
6 |
+
import cv2
|
7 |
|
8 |
from PIL import Image
|
9 |
from segment_utils import(
|
|
|
92 |
run_task_time = 0
|
93 |
time_cost_str = ''
|
94 |
run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
|
95 |
+
# canny_image = canny_detector(input_image, int(generate_size*1), generate_size)
|
96 |
+
canny_image = custom_canny_detector(input_image)
|
97 |
# lineart_image = lineart_detector(input_image, int(generate_size*1), generate_size)
|
98 |
# run_task_time, time_cost_str = get_time_cost(run_task_time, time_cost_str)
|
99 |
pidiNet_image = pidiNet_detector(input_image, int(generate_size*1), generate_size)
|
100 |
+
# cond_image = [canny_image, pidiNet_image]
|
101 |
+
# cond_scale = [cond_scale1, cond_scale2]
|
102 |
|
103 |
cond_image = canny_image
|
104 |
cond_scale = cond_scale1
|
|
|
132 |
image = torch.from_numpy(image)
|
133 |
return image
|
134 |
|
135 |
+
def custom_canny_detector(image):
|
136 |
+
image = np.array(image)
|
137 |
+
|
138 |
+
low_threshold = 100
|
139 |
+
high_threshold = 200
|
140 |
+
|
141 |
+
image = cv2.Canny(image, low_threshold, high_threshold)
|
142 |
+
image = Image.fromarray(image)
|
143 |
+
return image
|
144 |
+
|
145 |
def get_time_cost(run_task_time, time_cost_str):
|
146 |
now_time = int(time.time()*1000)
|
147 |
if run_task_time == 0:
|