Zhibinhong
commited on
Commit
·
dd3b112
1
Parent(s):
13b296f
Update handler.py
Browse files- handler.py +8 -5
handler.py
CHANGED
@@ -16,8 +16,11 @@ class EndpointHandler():
|
|
16 |
|
17 |
inputs=data['inputs']
|
18 |
text=inputs.pop('text',data)
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
16 |
|
17 |
inputs=data['inputs']
|
18 |
text=inputs.pop('text',data)
|
19 |
+
img = self.pipe(text).images[0]
|
20 |
+
# 将图像转换为字节流
|
21 |
+
img_byte_arr = io.BytesIO()
|
22 |
+
img.save(img_byte_arr, format='JPEG')
|
23 |
+
|
24 |
+
# 将字节流编码为base64格式
|
25 |
+
encoded_string = base64.b64encode(img_byte_arr.getvalue())
|
26 |
+
return {'image':encoded_string}
|