Commit ·
019d0a4
1
Parent(s): dff4d6d
add parameters
Browse files- handler.py +16 -6
handler.py
CHANGED
|
@@ -146,7 +146,19 @@ class EndpointHandler():
|
|
| 146 |
self.app = FaceAnalysis(name="buffalo_l", root="./", providers=["CPUExecutionProvider"])
|
| 147 |
self.app.prepare(ctx_id=0, det_size=(640, 640))
|
| 148 |
|
| 149 |
-
def __call__(self,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
self.pipe.scheduler = diffusers.LCMScheduler.from_config(self.pipe.scheduler.config)
|
| 151 |
self.pipe.enable_lora()
|
| 152 |
|
|
@@ -155,7 +167,7 @@ class EndpointHandler():
|
|
| 155 |
pose_strength = 0.4
|
| 156 |
canny_strength = 0.3
|
| 157 |
# depth_strength = 0.5
|
| 158 |
-
controlnet_selection = ["pose"
|
| 159 |
# controlnet_selection = ["pose", "canny", "depth"]
|
| 160 |
|
| 161 |
face_image_path = "https://i.ibb.co/SKg69dD/kaifu-resize.png"
|
|
@@ -205,8 +217,6 @@ class EndpointHandler():
|
|
| 205 |
# )
|
| 206 |
# check the prompt
|
| 207 |
# if prompt is None:
|
| 208 |
-
prompt = "watercolor painting, a man. vibrant, beautiful, painterly, detailed, textural, artistic"
|
| 209 |
-
negative_prompt = "(lowres, low quality, worst quality:1.2), (text:1.2), watermark, anime, photorealistic, 35mm film, deformed, glitch, low contrast, noisy"
|
| 210 |
|
| 211 |
# apply the style template
|
| 212 |
# prompt, negative_prompt = apply_style(style_name, prompt, negative_prompt)
|
|
@@ -297,8 +307,8 @@ class EndpointHandler():
|
|
| 297 |
image=control_images,
|
| 298 |
control_mask=control_mask,
|
| 299 |
controlnet_conditioning_scale=control_scales,
|
| 300 |
-
num_inference_steps=
|
| 301 |
-
guidance_scale=
|
| 302 |
height=height,
|
| 303 |
width=width,
|
| 304 |
generator=generator,
|
|
|
|
| 146 |
self.app = FaceAnalysis(name="buffalo_l", root="./", providers=["CPUExecutionProvider"])
|
| 147 |
self.app.prepare(ctx_id=0, det_size=(640, 640))
|
| 148 |
|
| 149 |
+
def __call__(self, data):
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
default_prompt = "watercolor painting, {prompt}. vibrant, beautiful, painterly, detailed, textural, artistic"
|
| 153 |
+
default_negative_prompt = "(lowres, low quality, worst quality:1.2), (text:1.2), watermark, anime, photorealistic, 35mm film, deformed, glitch, low contrast, noisy"
|
| 154 |
+
|
| 155 |
+
# hyperparamters
|
| 156 |
+
prompt_input = data.pop("inputs", "a man")
|
| 157 |
+
prompt=default_prompt.replace("{prompt}", prompt_input)
|
| 158 |
+
num_inference_steps = data.pop("num_inference_steps", 5)
|
| 159 |
+
guidance_scale = data.pop("guidance_scale", 1.5)
|
| 160 |
+
negative_prompt = data.pop("negative_prompt", default_negative_prompt)
|
| 161 |
+
|
| 162 |
self.pipe.scheduler = diffusers.LCMScheduler.from_config(self.pipe.scheduler.config)
|
| 163 |
self.pipe.enable_lora()
|
| 164 |
|
|
|
|
| 167 |
pose_strength = 0.4
|
| 168 |
canny_strength = 0.3
|
| 169 |
# depth_strength = 0.5
|
| 170 |
+
controlnet_selection = ["pose"]
|
| 171 |
# controlnet_selection = ["pose", "canny", "depth"]
|
| 172 |
|
| 173 |
face_image_path = "https://i.ibb.co/SKg69dD/kaifu-resize.png"
|
|
|
|
| 217 |
# )
|
| 218 |
# check the prompt
|
| 219 |
# if prompt is None:
|
|
|
|
|
|
|
| 220 |
|
| 221 |
# apply the style template
|
| 222 |
# prompt, negative_prompt = apply_style(style_name, prompt, negative_prompt)
|
|
|
|
| 307 |
image=control_images,
|
| 308 |
control_mask=control_mask,
|
| 309 |
controlnet_conditioning_scale=control_scales,
|
| 310 |
+
num_inference_steps=num_inference_steps,
|
| 311 |
+
guidance_scale=guidance_scale,
|
| 312 |
height=height,
|
| 313 |
width=width,
|
| 314 |
generator=generator,
|