Files
AiDA_Python/app/api/api_image2sketch.py
zhouchengrong d11beb0107 feat sketch 提取接口
fix
2024-08-14 16:45:34 +08:00

37 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import json
import logging
from fastapi import APIRouter, HTTPException
from app.schemas.image2sketch import Image2SketchModel
from app.schemas.response_template import ResponseModel
from app.service.image2sketch.server import Image2SketchServer
router = APIRouter()
logger = logging.getLogger()
@router.post("/image2sketch")
def image2sketch(request_item: Image2SketchModel):
"""
创建一个具有以下参数的请求体:
- **sr_image_url**: 超分图片的minio或s3 url地址
- **sr_xn**: 超分的倍数只接受2或4
- **sr_tasks_id**: 任务id 用于取消超分任务和获取超分结果
示例参数:
{
"image_url": "test/real_Top_971fe3085a69f31f3e66c225eabb0eea.jpg_Img.jpg",
"sketch_bucket": "test",
"sketch_name": "12341556-89.jpg"
}
"""
# try:
logger.info(f"image2sketch request item is : @@@@@@:{json.dumps(request_item.dict())}")
service = Image2SketchServer(request_item)
sketch_url = service.get_result()
# except Exception as e:
# logger.warning(f"image2sketch Run Exception @@@@@@:{e}")
# raise HTTPException(status_code=404, detail=str(e))
return ResponseModel(data=sketch_url)