feat 新增 process lookbooks 接口

fix
This commit is contained in:
zhouchengrong
2024-10-22 15:11:08 +08:00
parent 61af80541b
commit ed017fdf9d
8 changed files with 24 additions and 24 deletions

View File

@@ -16,11 +16,10 @@
1. 安装依赖 1. 安装依赖
$ conda create -n trinity_client_mixi python=3.9 -y $ conda create -n trinity_client_mixi python=3.12 -y
$ conda activate trinity_client_mixi $ conda activate trinity_client_mixi
$ pip install -r requirements.txt $ pip install -r requirements.txt
$ conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia -y $ conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia -y
$ pip install mmcv==1.4.2 -f https://download.openmmlab.com/mmcv/dist/cu117/torch1.13/index.html
2. 启动服务器 2. 启动服务器

View File

@@ -11,7 +11,7 @@ logger = logging.getLogger()
router = APIRouter() router = APIRouter()
@router.post("") @router.post("/attribute")
def attribute(request_data: AttributeModel): def attribute(request_data: AttributeModel):
logger.info(f"attribute requests is @@@@@@@@@@@:{request_data}") logger.info(f"attribute requests is @@@@@@@@@@@:{request_data}")
service = AttributeRecognition() service = AttributeRecognition()

View File

@@ -16,7 +16,7 @@ logger = logging.getLogger()
router = APIRouter() router = APIRouter()
@router.post("outfit_matcher") @router.post("/outfit_matcher")
def outfit_matcher(request_item: OutfitMatcher): def outfit_matcher(request_item: OutfitMatcher):
start_time = time.time() start_time = time.time()
request_item = dict(request_item) request_item = dict(request_item)

View File

@@ -1,18 +1,17 @@
import logging import logging
import os import os
import shutil
from typing import List from typing import List
import aiofiles import aiofiles
import tqdm
from fastapi import UploadFile, File, APIRouter, BackgroundTasks, Form from fastapi import UploadFile, File, APIRouter, BackgroundTasks, Form
from app.service.lookbooks.service import create_image_batch_requests, process_lookbook_task # 引入服务逻辑
from app.service.lookbooks.service import process_lookbook_task # 引入服务逻辑
logger = logging.getLogger() logger = logging.getLogger()
router = APIRouter() router = APIRouter()
@router.post("/process-lookbooks/") @router.post("/process-lookbooks")
async def process_lookbooks( async def process_lookbooks(
background_tasks: BackgroundTasks, background_tasks: BackgroundTasks,
files: List[UploadFile] = File(...), files: List[UploadFile] = File(...),

View File

@@ -5,7 +5,7 @@ from app.api import api_test, api_outfit_matcher, api_attribute, api_similar_mat
router = APIRouter() router = APIRouter()
router.include_router(api_test.router, tags=["test"], prefix="/test") router.include_router(api_test.router, tags=["test"], prefix="/test")
router.include_router(api_outfit_matcher.router, tags=["outfit_matcher"], prefix="/api/outfit_matcher") router.include_router(api_outfit_matcher.router, tags=["outfit_matcher"], prefix="/api")
router.include_router(api_attribute.router, tags=["attribute"], prefix="/api/attribute") router.include_router(api_attribute.router, tags=["attribute"], prefix="/api")
router.include_router(api_similar_match.router, tags=["similar_match"], prefix="/api/similar_match") router.include_router(api_similar_match.router, tags=["similar_match"], prefix="/api")
router.include_router(api_process_lookbooks.router, tags=["process_lookbooks"], prefix="/api/process_lookbooks") router.include_router(api_process_lookbooks.router, tags=["process-lookbooks"], prefix="/api")

View File

@@ -16,11 +16,11 @@ router = APIRouter()
@RunTime @RunTime
@router.post("similar_match") @router.post("/similar_match")
def similar_match(request_item: SimilarMatchMItem): def similar_match(request_item: SimilarMatchMItem):
try: try:
if request_item.result_number <= 0: if request_item.result_number <= 0:
raise KeyError("result number can't be less than 0") raise KeyError("results number can't be less than 0")
service = SimilarMatch(request_item) service = SimilarMatch(request_item)
search_response = service.match_features() search_response = service.match_features()
response_data = [] response_data = []
@@ -36,4 +36,4 @@ def similar_match(request_item: SimilarMatchMItem):
return {"message": "ok", "data": response_data} return {"message": "ok", "data": response_data}
except KeyError as e: except KeyError as e:
logger.warning(str(e)) logger.warning(str(e))
return {"message": "result number can't be less than 0", "data": []} return {"message": "results number can't be less than 0", "data": []}

View File

@@ -1,7 +1,9 @@
import logging import logging
import os import os
from typing import ClassVar
from dotenv import load_dotenv from dotenv import load_dotenv
from pydantic import BaseSettings from pydantic_settings import BaseSettings
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../')) BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))
logging.info(f"BASE_DIR : {BASE_DIR}") logging.info(f"BASE_DIR : {BASE_DIR}")
@@ -9,14 +11,14 @@ load_dotenv(os.path.join(BASE_DIR, '.env'))
class Settings(BaseSettings): class Settings(BaseSettings):
PROJECT_NAME = os.getenv('PROJECT_NAME', 'FASTAPI BASE') PROJECT_NAME: ClassVar[str] = 'FASTAPI BASE'
SECRET_KEY = os.getenv('SECRET_KEY', '') SECRET_KEY: str = ''
API_PREFIX = '' API_PREFIX: str = ''
BACKEND_CORS_ORIGINS = ['*'] BACKEND_CORS_ORIGINS: list[str] = ['*']
DATABASE_URL = os.getenv('SQL_DATABASE_URL', '') DATABASE_URL: str = ''
ACCESS_TOKEN_EXPIRE_SECONDS: int = 60 * 60 * 24 * 7 # Token expired after 7 days ACCESS_TOKEN_EXPIRE_SECONDS: int = 60 * 60 * 24 * 7 # Token expired after 7 days
SECURITY_ALGORITHM = 'HS256' SECURITY_ALGORITHM: str = 'HS256'
LOGGING_CONFIG_FILE = os.path.join(BASE_DIR, 'logging_env.py') LOGGING_CONFIG_FILE: str = os.path.join(BASE_DIR, 'logging_env.py')
settings = Settings() settings = Settings()
@@ -35,7 +37,7 @@ ATT_TRITON_PORT = "20010"
MILVUS_URL = "http://10.1.1.240:19530" MILVUS_URL = "http://10.1.1.240:19530"
DEBUG = 1 DEBUG = 2
SHOW_OR_SAVE_result_image = False SHOW_OR_SAVE_result_image = False
# service env : 1 # service env : 1
# pycharm debug : 2 # pycharm debug : 2

Binary file not shown.