52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
|
|
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)
|