feat(新功能): clothing seg
fix(修复bug): docs(文档变更): refactor(重构): test(增加测试):
This commit is contained in:
51
app/api/api_clothing_seg.py
Normal file
51
app/api/api_clothing_seg.py
Normal file
@@ -0,0 +1,51 @@
|
||||
import json
|
||||
import logging
|
||||
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
from app.schemas.response_template import ResponseModel
|
||||
from app.schemas.clothing_seg import ClothingSegModel
|
||||
from app.service.clothing_seg.service import ClothingSeg
|
||||
|
||||
router = APIRouter()
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
@router.post("/clothing_seg")
|
||||
def clothing_seg(request_item: ClothingSegModel):
|
||||
"""
|
||||
创建一个具有以下参数的请求体:
|
||||
- **user_id**: 用户id
|
||||
- **image_data**: 图片数据
|
||||
{
|
||||
"image_url": "test/clothing_seg/dress.jpg",
|
||||
"image_type": "product"
|
||||
}
|
||||
|
||||
示例参数:
|
||||
{
|
||||
"user_id": 89,
|
||||
"image_data": [
|
||||
{
|
||||
"image_url": "test/clothing_seg/dress.jpg",
|
||||
"image_type": "sketch"
|
||||
},
|
||||
{
|
||||
"image_url": "test/clothing_seg/skirt_559.jpg",
|
||||
"image_type": "sketch"
|
||||
},
|
||||
{
|
||||
"image_url": "test/clothing_seg/10144613.jpg",
|
||||
"image_type": "product"
|
||||
}
|
||||
]
|
||||
}
|
||||
"""
|
||||
try:
|
||||
logger.info(f"clothing_seg request item is : @@@@@@:{json.dumps(request_item.dict())}")
|
||||
server = ClothingSeg(request_item)
|
||||
result_url = server.get_result()
|
||||
except Exception as e:
|
||||
logger.warning(f"clothing_seg Run Exception @@@@@@:{e}")
|
||||
raise HTTPException(status_code=404, detail=str(e))
|
||||
return ResponseModel(data=result_url)
|
||||
Reference in New Issue
Block a user