frodos commited on
Commit
1bc1c8f
1 Parent(s): a8a6ee4

Define format

Browse files
Files changed (1) hide show
  1. 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(img.tobytes()).decode("utf8")}
 
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__":