Commit
•
f364bfe
1
Parent(s):
add5a0b
Update handler.py
Browse filesthe following input is send to the endpoint with a post request.
```
{'json': {'inputs': 'a dog waiting for its companion to come.', 'parameters': {'negative_prompt': 'no dog', 'height': 512, 'width': 512, 'num_inference_steps': 25, 'guidance_scale': 7.5}}}
```
- handler.py +12 -6
handler.py
CHANGED
@@ -9,15 +9,21 @@ class EndpointHandler:
|
|
9 |
).to("cuda")
|
10 |
|
11 |
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
12 |
-
|
13 |
-
prompt =
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
17 |
|
18 |
prediction = self.pipeline(
|
19 |
prompt,
|
20 |
-
negative_prompt=
|
|
|
|
|
21 |
guidance_scale=guidance_scale,
|
22 |
num_inference_steps=num_inference_steps,
|
23 |
generator=torch.manual_seed(seed)
|
|
|
9 |
).to("cuda")
|
10 |
|
11 |
def __call__(self, data: Dict[str, Any]) -> List[Dict[str, Any]]:
|
12 |
+
data = data.pop("json")
|
13 |
+
prompt = data.pop("inputs", None)
|
14 |
+
parameters = data.pop("parameters", {})
|
15 |
+
negative_prompt = parameters.pop("negative_prompt", "bad quality, worse quality, deformed")
|
16 |
+
height = parameters.pop("height", 512)
|
17 |
+
width = parameters.pop("width", 512)
|
18 |
+
guidance_scale = parameters.pop("guidance_scale", 4.5)
|
19 |
+
num_inference_steps = parameters.pop("num_inference_steps", 28)
|
20 |
+
seed = parameters.pop("seed", 0)
|
21 |
|
22 |
prediction = self.pipeline(
|
23 |
prompt,
|
24 |
+
negative_prompt=negative_prompt,
|
25 |
+
height=height,
|
26 |
+
width=width,
|
27 |
guidance_scale=guidance_scale,
|
28 |
num_inference_steps=num_inference_steps,
|
29 |
generator=torch.manual_seed(seed)
|