Update handler.py
Browse files- handler.py +5 -5
handler.py
CHANGED
|
@@ -28,7 +28,7 @@ STYLE_NAMES = list(styles.keys())
|
|
| 28 |
DEFAULT_STYLE_NAME = "Spring Festival"
|
| 29 |
|
| 30 |
class GenerateImageRequest(BaseModel):
|
| 31 |
-
|
| 32 |
negative_prompt: str
|
| 33 |
style: str
|
| 34 |
num_steps: int
|
|
@@ -164,7 +164,7 @@ class EndpointHandler:
|
|
| 164 |
return p.replace("{prompt}", positive), n + " " + negative
|
| 165 |
|
| 166 |
request = GenerateImageRequest(**data)
|
| 167 |
-
|
| 168 |
negative_prompt = request.negative_prompt
|
| 169 |
style_name = request.style
|
| 170 |
identitynet_strength_ratio = request.identitynet_strength_ratio
|
|
@@ -185,7 +185,7 @@ class EndpointHandler:
|
|
| 185 |
self.pipe.scheduler = diffusers.EulerDiscreteScheduler.from_config(self.pipe.scheduler.config)
|
| 186 |
|
| 187 |
# apply the style template
|
| 188 |
-
|
| 189 |
|
| 190 |
face_image_path = data.get("face_image_path", "https://i.ibb.co/GQzm527/examples-musk-resize.jpg")
|
| 191 |
pose_image_path = data.get("pose_image_path", "https://i.ibb.co/TRCK4MS/examples-poses-pose2.jpg")
|
|
@@ -245,11 +245,11 @@ class EndpointHandler:
|
|
| 245 |
generator = torch.Generator(device=device).manual_seed(seed)
|
| 246 |
|
| 247 |
print("Start inference...")
|
| 248 |
-
print(f"[Debug] Prompt: {
|
| 249 |
|
| 250 |
self.pipe.set_ip_adapter_scale(adapter_strength_ratio)
|
| 251 |
images = self.pipe(
|
| 252 |
-
prompt=
|
| 253 |
negative_prompt=negative_prompt,
|
| 254 |
image_embeds=face_emb,
|
| 255 |
image=control_images,
|
|
|
|
| 28 |
DEFAULT_STYLE_NAME = "Spring Festival"
|
| 29 |
|
| 30 |
class GenerateImageRequest(BaseModel):
|
| 31 |
+
inputs: str
|
| 32 |
negative_prompt: str
|
| 33 |
style: str
|
| 34 |
num_steps: int
|
|
|
|
| 164 |
return p.replace("{prompt}", positive), n + " " + negative
|
| 165 |
|
| 166 |
request = GenerateImageRequest(**data)
|
| 167 |
+
inputs = request.inputs
|
| 168 |
negative_prompt = request.negative_prompt
|
| 169 |
style_name = request.style
|
| 170 |
identitynet_strength_ratio = request.identitynet_strength_ratio
|
|
|
|
| 185 |
self.pipe.scheduler = diffusers.EulerDiscreteScheduler.from_config(self.pipe.scheduler.config)
|
| 186 |
|
| 187 |
# apply the style template
|
| 188 |
+
inputs, negative_prompt = apply_style(style_name, inputs, negative_prompt)
|
| 189 |
|
| 190 |
face_image_path = data.get("face_image_path", "https://i.ibb.co/GQzm527/examples-musk-resize.jpg")
|
| 191 |
pose_image_path = data.get("pose_image_path", "https://i.ibb.co/TRCK4MS/examples-poses-pose2.jpg")
|
|
|
|
| 245 |
generator = torch.Generator(device=device).manual_seed(seed)
|
| 246 |
|
| 247 |
print("Start inference...")
|
| 248 |
+
print(f"[Debug] Prompt: {inputs}, \n[Debug] Neg Prompt: {negative_prompt}")
|
| 249 |
|
| 250 |
self.pipe.set_ip_adapter_scale(adapter_strength_ratio)
|
| 251 |
images = self.pipe(
|
| 252 |
+
prompt=inputs,
|
| 253 |
negative_prompt=negative_prompt,
|
| 254 |
image_embeds=face_emb,
|
| 255 |
image=control_images,
|