Define format
Browse files- handler.py +5 -2
handler.py
CHANGED
@@ -25,10 +25,13 @@ class EndpointHandler():
|
|
25 |
"height": 768,
|
26 |
"width": 768}
|
27 |
|
28 |
-
img = self._pipe(**params).images[0]
|
29 |
|
|
|
|
|
30 |
res = {"status": 200,
|
31 |
-
"image": base64.b64encode(
|
|
|
32 |
return res
|
33 |
|
34 |
if __name__ == "__main__":
|
|
|
25 |
"height": 768,
|
26 |
"width": 768}
|
27 |
|
28 |
+
img: Image = self._pipe(**params).images[0]
|
29 |
|
30 |
+
stream = BytesIO()
|
31 |
+
img.save(stream, format="jpeg")
|
32 |
res = {"status": 200,
|
33 |
+
"image": base64.b64encode(stream.getvalue()).decode("utf8")
|
34 |
+
}
|
35 |
return res
|
36 |
|
37 |
if __name__ == "__main__":
|