add custom handler
Browse files- handler.py +6 -3
handler.py
CHANGED
|
@@ -55,14 +55,17 @@ class EndpointHandler():
|
|
| 55 |
|
| 56 |
def __call__(self, data: Dict[str, Any]) -> str:
|
| 57 |
# get inputs
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
| 59 |
batch_size = data.pop("batch_size", 1)
|
| 60 |
|
| 61 |
-
context = base64.b64decode(
|
| 62 |
context = np.frombuffer(context, dtype="float32")
|
| 63 |
context = np.reshape(context, (batch_size, 77, 768))
|
| 64 |
|
| 65 |
-
unconditional_context = base64.b64decode(
|
| 66 |
unconditional_context = np.frombuffer(unconditional_context, dtype="float32")
|
| 67 |
unconditional_context = np.reshape(unconditional_context, (batch_size, 77, 768))
|
| 68 |
|
|
|
|
| 55 |
|
| 56 |
def __call__(self, data: Dict[str, Any]) -> str:
|
| 57 |
# get inputs
|
| 58 |
+
data = data.pop("inputs", data)
|
| 59 |
+
data = data.decode('utf-8')
|
| 60 |
+
data = json.loads(data)
|
| 61 |
+
|
| 62 |
batch_size = data.pop("batch_size", 1)
|
| 63 |
|
| 64 |
+
context = base64.b64decode(data["context_b64str"])
|
| 65 |
context = np.frombuffer(context, dtype="float32")
|
| 66 |
context = np.reshape(context, (batch_size, 77, 768))
|
| 67 |
|
| 68 |
+
unconditional_context = base64.b64decode(data['unconditional_context_b64str'])
|
| 69 |
unconditional_context = np.frombuffer(unconditional_context, dtype="float32")
|
| 70 |
unconditional_context = np.reshape(unconditional_context, (batch_size, 77, 768))
|
| 71 |
|