diff --git a/README.md b/README.md index ec77e43..211616b 100644 --- a/README.md +++ b/README.md @@ -16,11 +16,10 @@ 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 $ pip install -r requirements.txt $ 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. 启动服务器 diff --git a/app/api/api_attribute.py b/app/api/api_attribute.py index 4054e1b..c0f735e 100644 --- a/app/api/api_attribute.py +++ b/app/api/api_attribute.py @@ -11,7 +11,7 @@ logger = logging.getLogger() router = APIRouter() -@router.post("") +@router.post("/attribute") def attribute(request_data: AttributeModel): logger.info(f"attribute requests is @@@@@@@@@@@:{request_data}") service = AttributeRecognition() diff --git a/app/api/api_outfit_matcher.py b/app/api/api_outfit_matcher.py index bb04d18..ed45cf0 100644 --- a/app/api/api_outfit_matcher.py +++ b/app/api/api_outfit_matcher.py @@ -16,7 +16,7 @@ logger = logging.getLogger() router = APIRouter() -@router.post("outfit_matcher") +@router.post("/outfit_matcher") def outfit_matcher(request_item: OutfitMatcher): start_time = time.time() request_item = dict(request_item) diff --git a/app/api/api_process_lookbooks.py b/app/api/api_process_lookbooks.py index fbda8c8..93864bf 100644 --- a/app/api/api_process_lookbooks.py +++ b/app/api/api_process_lookbooks.py @@ -1,18 +1,17 @@ import logging import os -import shutil from typing import List import aiofiles -import tqdm 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() router = APIRouter() -@router.post("/process-lookbooks/") +@router.post("/process-lookbooks") async def process_lookbooks( background_tasks: BackgroundTasks, files: List[UploadFile] = File(...), diff --git a/app/api/api_route.py b/app/api/api_route.py index 923a9b0..1b7cf93 100644 --- a/app/api/api_route.py +++ b/app/api/api_route.py @@ -5,7 +5,7 @@ from app.api import api_test, api_outfit_matcher, api_attribute, api_similar_mat router = APIRouter() 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_attribute.router, tags=["attribute"], prefix="/api/attribute") -router.include_router(api_similar_match.router, tags=["similar_match"], prefix="/api/similar_match") -router.include_router(api_process_lookbooks.router, tags=["process_lookbooks"], prefix="/api/process_lookbooks") +router.include_router(api_outfit_matcher.router, tags=["outfit_matcher"], prefix="/api") +router.include_router(api_attribute.router, tags=["attribute"], prefix="/api") +router.include_router(api_similar_match.router, tags=["similar_match"], prefix="/api") +router.include_router(api_process_lookbooks.router, tags=["process-lookbooks"], prefix="/api") diff --git a/app/api/api_similar_match.py b/app/api/api_similar_match.py index 4f3ffe2..b4a56d2 100644 --- a/app/api/api_similar_match.py +++ b/app/api/api_similar_match.py @@ -16,11 +16,11 @@ router = APIRouter() @RunTime -@router.post("similar_match") +@router.post("/similar_match") def similar_match(request_item: SimilarMatchMItem): try: 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) search_response = service.match_features() response_data = [] @@ -36,4 +36,4 @@ def similar_match(request_item: SimilarMatchMItem): return {"message": "ok", "data": response_data} except KeyError as 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": []} diff --git a/app/core/config.py b/app/core/config.py index f15c473..eebf282 100644 --- a/app/core/config.py +++ b/app/core/config.py @@ -1,7 +1,9 @@ import logging import os +from typing import ClassVar + 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__), '../../')) logging.info(f"BASE_DIR : {BASE_DIR}") @@ -9,14 +11,14 @@ load_dotenv(os.path.join(BASE_DIR, '.env')) class Settings(BaseSettings): - PROJECT_NAME = os.getenv('PROJECT_NAME', 'FASTAPI BASE') - SECRET_KEY = os.getenv('SECRET_KEY', '') - API_PREFIX = '' - BACKEND_CORS_ORIGINS = ['*'] - DATABASE_URL = os.getenv('SQL_DATABASE_URL', '') + PROJECT_NAME: ClassVar[str] = 'FASTAPI BASE' + SECRET_KEY: str = '' + API_PREFIX: str = '' + BACKEND_CORS_ORIGINS: list[str] = ['*'] + DATABASE_URL: str = '' ACCESS_TOKEN_EXPIRE_SECONDS: int = 60 * 60 * 24 * 7 # Token expired after 7 days - SECURITY_ALGORITHM = 'HS256' - LOGGING_CONFIG_FILE = os.path.join(BASE_DIR, 'logging_env.py') + SECURITY_ALGORITHM: str = 'HS256' + LOGGING_CONFIG_FILE: str = os.path.join(BASE_DIR, 'logging_env.py') settings = Settings() @@ -35,7 +37,7 @@ ATT_TRITON_PORT = "20010" MILVUS_URL = "http://10.1.1.240:19530" -DEBUG = 1 +DEBUG = 2 SHOW_OR_SAVE_result_image = False # service env : 1 # pycharm debug : 2 diff --git a/requirements.txt b/requirements.txt index 3a595e6..0237788 100644 Binary files a/requirements.txt and b/requirements.txt differ