add custom handler
Browse files- __pycache__/handler.cpython-38.pyc +0 -0
- handler.py +1 -6
__pycache__/handler.cpython-38.pyc
CHANGED
Binary files a/__pycache__/handler.cpython-38.pyc and b/__pycache__/handler.cpython-38.pyc differ
|
|
handler.py
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
from typing import Dict, List, Any
|
2 |
|
3 |
import base64
|
4 |
-
import logging
|
5 |
import math
|
6 |
import numpy as np
|
7 |
import tensorflow as tf
|
@@ -57,19 +56,15 @@ class EndpointHandler():
|
|
57 |
def __call__(self, data: Dict[str, Any]) -> str:
|
58 |
# get inputs
|
59 |
contexts = data.pop("inputs", data)
|
60 |
-
logging.warning(contexts)
|
61 |
-
|
62 |
batch_size = data.pop("batch_size", 1)
|
63 |
|
64 |
context = base64.b64decode(contexts[0])
|
65 |
context = np.frombuffer(context, dtype="float32")
|
66 |
context = np.reshape(context, (batch_size, 77, 768))
|
67 |
-
print(context)
|
68 |
|
69 |
unconditional_context = base64.b64decode(contexts[1])
|
70 |
unconditional_context = np.frombuffer(unconditional_context, dtype="float32")
|
71 |
unconditional_context = np.reshape(unconditional_context, (batch_size, 77, 768))
|
72 |
-
print(unconditional_context)
|
73 |
|
74 |
num_steps = data.pop("num_steps", 25)
|
75 |
unconditional_guidance_scale = data.pop("unconditional_guidance_scale", 7.5)
|
@@ -100,4 +95,4 @@ class EndpointHandler():
|
|
100 |
latent_b64 = base64.b64encode(latent.numpy().tobytes())
|
101 |
latent_b64str = latent_b64.decode()
|
102 |
|
103 |
-
return latent_b64str
|
|
|
1 |
from typing import Dict, List, Any
|
2 |
|
3 |
import base64
|
|
|
4 |
import math
|
5 |
import numpy as np
|
6 |
import tensorflow as tf
|
|
|
56 |
def __call__(self, data: Dict[str, Any]) -> str:
|
57 |
# get inputs
|
58 |
contexts = data.pop("inputs", data)
|
|
|
|
|
59 |
batch_size = data.pop("batch_size", 1)
|
60 |
|
61 |
context = base64.b64decode(contexts[0])
|
62 |
context = np.frombuffer(context, dtype="float32")
|
63 |
context = np.reshape(context, (batch_size, 77, 768))
|
|
|
64 |
|
65 |
unconditional_context = base64.b64decode(contexts[1])
|
66 |
unconditional_context = np.frombuffer(unconditional_context, dtype="float32")
|
67 |
unconditional_context = np.reshape(unconditional_context, (batch_size, 77, 768))
|
|
|
68 |
|
69 |
num_steps = data.pop("num_steps", 25)
|
70 |
unconditional_guidance_scale = data.pop("unconditional_guidance_scale", 7.5)
|
|
|
95 |
latent_b64 = base64.b64encode(latent.numpy().tobytes())
|
96 |
latent_b64str = latent_b64.decode()
|
97 |
|
98 |
+
return latent_b64str
|