Spaces:
Build error
Build error
Commit
·
d187e5b
1
Parent(s):
8b787f3
update: mto return base64
Browse files
src/api/mannequin_to_model_api.py
CHANGED
|
@@ -84,9 +84,14 @@ async def mto_image(image: UploadFile = File(...), store_name: str = Form(...),
|
|
| 84 |
return JSONResponse({"error": "Face swap process failed"}, status_code=500)
|
| 85 |
|
| 86 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
logger.info("MTO image process completed successfully")
|
| 88 |
return JSONResponse(content={
|
| 89 |
-
"output":
|
| 90 |
"status": "success",
|
| 91 |
"inference_time": round((time.time() - start_time), 2)
|
| 92 |
}, status_code=200)
|
|
|
|
| 84 |
return JSONResponse({"error": "Face swap process failed"}, status_code=500)
|
| 85 |
|
| 86 |
try:
|
| 87 |
+
response = requests.get(str(output['image']))
|
| 88 |
+
image_content = response.content
|
| 89 |
+
|
| 90 |
+
base64_image = base64.b64encode(image_content).decode('utf-8')
|
| 91 |
+
|
| 92 |
logger.info("MTO image process completed successfully")
|
| 93 |
return JSONResponse(content={
|
| 94 |
+
"output": f"data:image/webp;base64,{base64_image}",
|
| 95 |
"status": "success",
|
| 96 |
"inference_time": round((time.time() - start_time), 2)
|
| 97 |
}, status_code=200)
|