弃用mq 采用回调接口方式
This commit is contained in:
@@ -156,7 +156,7 @@ async def to_3views(request_data: ToSVGRequest):
|
||||
logger.warning(f"img_to_3D Run Exception: {e}")
|
||||
|
||||
|
||||
@router.post("/img_to_3D_mq")
|
||||
@router.post("/img_to_3D_v2")
|
||||
async def img_to_3d_endpoint(request_data: ImageTo3DRequest):
|
||||
"""
|
||||
### 接口说明:
|
||||
@@ -169,9 +169,13 @@ async def img_to_3d_endpoint(request_data: ImageTo3DRequest):
|
||||
### 请求体示例:
|
||||
**单张图片模式:**
|
||||
```json
|
||||
{
|
||||
"input_images": ["test/img_to_3d_data/example/character_1.png"],
|
||||
"model": "single"
|
||||
{
|
||||
"input_images": [
|
||||
"test/img_to_3d_data/example_multi_image/character_1.png"
|
||||
],
|
||||
"model": "single",
|
||||
"task_id": "123",
|
||||
"callback_url": "https://example.com/"
|
||||
}
|
||||
```
|
||||
**多张图片模式:**
|
||||
@@ -182,7 +186,9 @@ async def img_to_3d_endpoint(request_data: ImageTo3DRequest):
|
||||
"test/img_to_3d_data/example_multi_image/character_2.png",
|
||||
"test/img_to_3d_data/example_multi_image/character_3.png"
|
||||
],
|
||||
"model": "multi"
|
||||
"model": "multi",
|
||||
"task_id": "123",
|
||||
"callback_url": "https://example.com/"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -190,11 +196,11 @@ async def img_to_3d_endpoint(request_data: ImageTo3DRequest):
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "ok",
|
||||
"msg": "OK!",
|
||||
"data": {
|
||||
"job_id": "b2c3d4e5-f6g7-8901-hijk-lm2345678901",
|
||||
"status": "queued",
|
||||
"message": "任务已进入后台处理"
|
||||
"state": "success",
|
||||
"task_id": "123",
|
||||
"message": "任务已成功提交,正在后台处理..."
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -204,6 +210,7 @@ async def img_to_3d_endpoint(request_data: ImageTo3DRequest):
|
||||
"message": "ok",
|
||||
"data": {
|
||||
"status": "queue_full",
|
||||
"task_id": "123",
|
||||
"message": "当前 3D 生成请求较多,请稍后重试。",
|
||||
"queue_length": 10,
|
||||
"max_length": 10
|
||||
@@ -216,69 +223,14 @@ async def img_to_3d_endpoint(request_data: ImageTo3DRequest):
|
||||
"message": "ok",
|
||||
"data": {
|
||||
"status": "fail",
|
||||
"task_id": "123",
|
||||
"message": "提交失败,请稍后重试。",
|
||||
"error": str(e)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
--------------------------------------------------------------------
|
||||
RabbitMQ 结果消息说明:
|
||||
处理完成后,结果会通过 RabbitMQ 发送到以下位置:
|
||||
Queue: img_to_3d_results
|
||||
|
||||
消息格式:
|
||||
```json
|
||||
{
|
||||
"job_id": "6d0492dd-f276-4512-913c-134de2ba4b84",
|
||||
"status": "completed",
|
||||
"timestamp": "2026-04-01T11:54:31.146435",
|
||||
"task_type": "img_to_3d_results-prod",
|
||||
"result": {
|
||||
"glb_path": "test/3d_result/glb/3d2777e6ac4f48769e5bb4642807bfdb.glb",
|
||||
"glb_static_img_path": "test/3d_result/png/d54f1fff6b0b48b5ba4604d334aed73b.png",
|
||||
"glb_info": {
|
||||
"file_format": ".glb",
|
||||
"vertex_count": 5519,
|
||||
"centroid": [
|
||||
-0.01005209478665426,
|
||||
0.10863836704985305,
|
||||
-0.011404903160470693
|
||||
],
|
||||
"bounding_box_min": [
|
||||
-0.17623867094516754,
|
||||
-0.499397873878479,
|
||||
-0.16439560055732727
|
||||
],
|
||||
"bounding_box_max": [
|
||||
0.18468153476715088,
|
||||
0.5002236366271973,
|
||||
0.1541675627231598
|
||||
],
|
||||
"size": [
|
||||
0.3609202057123184,
|
||||
0.9996215105056763,
|
||||
0.31856316328048706
|
||||
],
|
||||
"size_ratio": [
|
||||
0.21494798217733652,
|
||||
0.5953300015447786,
|
||||
0.189722016277885
|
||||
],
|
||||
"size_ratio_percentage": [
|
||||
21.494798217733653,
|
||||
59.533000154477854,
|
||||
18.9722016277885
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
status 说明:
|
||||
completed: 处理成功,result 中包含 3D 模型相关路径和信息
|
||||
failed: 处理失败,result 中会包含 error 字段
|
||||
"""
|
||||
result = submit_img_to_3d_task(input_images=request_data.input_images, model=request_data.model)
|
||||
result = submit_img_to_3d_task(input_images=request_data.input_images, model=request_data.model, task_id=request_data.task_id, callback_url=request_data.callback_url)
|
||||
if result.get("state") == "success":
|
||||
state_code = 200
|
||||
elif result.get("state") == "queue_full":
|
||||
@@ -289,7 +241,7 @@ async def img_to_3d_endpoint(request_data: ImageTo3DRequest):
|
||||
return ResponseModel(data=result, code=state_code)
|
||||
|
||||
|
||||
@router.post("/3d_to_3views_mq")
|
||||
@router.post("/3d_to_3views_v2")
|
||||
async def to_3views(request_data: ToSVGRequest):
|
||||
"""
|
||||
### 接口说明:
|
||||
@@ -311,21 +263,8 @@ async def to_3views(request_data: ToSVGRequest):
|
||||
"code": 200,
|
||||
"message": "任务已提交",
|
||||
"data": {
|
||||
"job_id": "b2c3d4e5-f6g7-8901-hijk-lm2345678901",
|
||||
"status": "queued",
|
||||
"message": "任务已进入后台处理"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 输出示例:
|
||||
```json
|
||||
{
|
||||
"code": 200,
|
||||
"message": "ok",
|
||||
"data": {
|
||||
"job_id": "b2c3d4e5-f6g7-8901-hijk-lm2345678901",
|
||||
"status": "queued",
|
||||
"task_id": "123",
|
||||
"status": "success",
|
||||
"message": "任务已进入后台处理"
|
||||
}
|
||||
}
|
||||
@@ -336,6 +275,7 @@ async def to_3views(request_data: ToSVGRequest):
|
||||
"message": "ok",
|
||||
"data": {
|
||||
"status": "queue_full",
|
||||
"task_id": "123",
|
||||
"message": "当前 3D 生成请求较多,请稍后重试。",
|
||||
"queue_length": 10,
|
||||
"max_length": 10
|
||||
@@ -348,31 +288,14 @@ async def to_3views(request_data: ToSVGRequest):
|
||||
"message": "ok",
|
||||
"data": {
|
||||
"status": "fail",
|
||||
"task_id": "123",
|
||||
"message": "提交失败,请稍后重试。",
|
||||
"error": str(e)
|
||||
}
|
||||
}
|
||||
```
|
||||
--------------------------------------------------------------------
|
||||
RabbitMQ 结果消息说明:
|
||||
Queue: three_d_to_3views_results
|
||||
消息格式:
|
||||
```json
|
||||
{
|
||||
"job_id": "88047a47-6c16-4607-a548-00034b6d56cf",
|
||||
"status": "completed",
|
||||
"timestamp": "2026-04-01T12:28:41.026066",
|
||||
"task_type": "three_d_to_3views_results",
|
||||
"result": {
|
||||
"minio_svg_path": "test/3d_result/svg/dac119f93b3f46a3ad8a476b608feb71.svg"
|
||||
}
|
||||
}
|
||||
```
|
||||
status 说明:
|
||||
completed: 处理成功,result 中包含转换后的视图图片路径
|
||||
failed: 处理失败,result 中会包含 "error" 字段
|
||||
"""
|
||||
result = submit_three_d_to_3views_task(minio_glb_path=request_data.minio_glb_path)
|
||||
result = submit_three_d_to_3views_task(minio_glb_path=request_data.minio_glb_path, task_id=request_data.task_id, callback_url=request_data.callback_url)
|
||||
if result.get("state") == "success":
|
||||
state_code = 200
|
||||
elif result.get("state") == "queue_full":
|
||||
|
||||
Reference in New Issue
Block a user