Spaces:
Runtime error
Runtime error
fix base64
Browse files
main.py
CHANGED
|
@@ -55,7 +55,14 @@ async def predict(prompt=Body(...),imgbase64data=Body(...),userId=Body(None)):
|
|
| 55 |
print("测试",output_image)
|
| 56 |
print("s生成完成:", end2 - end1)
|
| 57 |
# 将图片对象转换为bytes
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
print("完成的图片:", output_image_base64)
|
| 60 |
logger = logging.getLogger('')
|
| 61 |
logger.info(output_image_base64)
|
|
|
|
| 55 |
print("测试",output_image)
|
| 56 |
print("s生成完成:", end2 - end1)
|
| 57 |
# 将图片对象转换为bytes
|
| 58 |
+
image_data = io.BytesIO()
|
| 59 |
+
|
| 60 |
+
# 将图像保存到BytesIO对象中,格式为JPEG
|
| 61 |
+
output_image.save(image_data, format='JPEG')
|
| 62 |
+
|
| 63 |
+
# 将BytesIO对象的内容转换为字节串
|
| 64 |
+
image_data_bytes = image_data.getvalue()
|
| 65 |
+
output_image_base64 = base64.b64encode(image_data_bytes).decode('utf-8')
|
| 66 |
print("完成的图片:", output_image_base64)
|
| 67 |
logger = logging.getLogger('')
|
| 68 |
logger.info(output_image_base64)
|