added more params
Browse files- handler.py +18 -5
handler.py
CHANGED
@@ -20,16 +20,29 @@ class EndpointHandler():
|
|
20 |
inputs (:obj:`string`)
|
21 |
parameters (:obj:)
|
22 |
Return:
|
23 |
-
A :obj:`string`:.
|
24 |
"""
|
25 |
|
26 |
|
27 |
-
image_data = data.pop(
|
28 |
# decode base64 image to PIL
|
29 |
image = Image.open(BytesIO(base64.b64decode(image_data)))
|
30 |
|
31 |
-
parameters = data.pop(
|
32 |
-
prompt = parameters
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
-
images = self.pipe(prompt, image=image, num_inference_steps=10, image_guidance_scale=1).images
|
35 |
return images[0]
|
|
|
20 |
inputs (:obj:`string`)
|
21 |
parameters (:obj:)
|
22 |
Return:
|
23 |
+
A :obj:`string`:. image string
|
24 |
"""
|
25 |
|
26 |
|
27 |
+
image_data = data.pop('inputs', data)
|
28 |
# decode base64 image to PIL
|
29 |
image = Image.open(BytesIO(base64.b64decode(image_data)))
|
30 |
|
31 |
+
parameters = data.pop('parameters', [])
|
32 |
+
prompt = parameters.pop('prompt', None)
|
33 |
+
negative_prompt = parameters.pop('negative_prompt', None)
|
34 |
+
num_inference_steps = parameters.pop('num_inference_steps', 10)
|
35 |
+
image_guidance_scale = parameters.pop('image_guidance_scale', 1.5)
|
36 |
+
guidance_scale = parameters.pop('guidance_scale', 7.5)
|
37 |
+
|
38 |
+
|
39 |
+
images = self.pipe(
|
40 |
+
prompt,
|
41 |
+
image = image,
|
42 |
+
negative_prompt = negative_prompt,
|
43 |
+
num_inference_steps = num_inference_steps,
|
44 |
+
image_guidance_scale = image_guidance_scale,
|
45 |
+
guidance_scale = guidance_scale
|
46 |
+
).images
|
47 |
|
|
|
48 |
return images[0]
|