35 lines
1.0 KiB
Python
35 lines
1.0 KiB
Python
import json
|
|
import logging
|
|
|
|
from fastapi import APIRouter, HTTPException
|
|
|
|
from app.schemas.brand_dna import BrandDnaModel
|
|
from app.schemas.response_template import ResponseModel
|
|
from app.service.brand_dna.service import BrandDna
|
|
|
|
router = APIRouter()
|
|
logger = logging.getLogger()
|
|
|
|
|
|
@router.post("/seg_product")
|
|
def image2sketch(request_item: BrandDnaModel):
|
|
"""
|
|
创建一个具有以下参数的请求体:
|
|
- **image_url**: 提取图片url
|
|
- **is_brand_dna**: 是否提取属性
|
|
|
|
示例参数:
|
|
{
|
|
"image_url": "aida-results/result_00006a48-e315-11ee-b7c8-b48351119060.png",
|
|
"is_brand_dna": false
|
|
}
|
|
"""
|
|
try:
|
|
logger.info(f"brand dna request item is : @@@@@@:{json.dumps(request_item.dict())}")
|
|
service = BrandDna(request_item)
|
|
result_url = service.get_result()
|
|
except Exception as e:
|
|
logger.warning(f"brand dna Run Exception @@@@@@:{e}")
|
|
raise HTTPException(status_code=404, detail=str(e))
|
|
return ResponseModel(data=result_url)
|