From 858077692d99f0b691a82a8ee9e217302f995f87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BC=96=E7=A0=81=E7=8C=BF?= Date: Fri, 29 Aug 2025 22:05:02 +0800 Subject: [PATCH] www --- README.md | 4 +- main.py | 1 - requirements.txt | 1 + run.bat | 59 ----------------------------- src/ai/.pydio | 1 - src/ai/checkHandStatic.py | 12 ++++++ src/config/setting.py | 8 ++-- src/controller/ai/ai.py | 20 +++++++--- src/controller/kuaishou/kuaishou.py | 2 +- 9 files changed, 33 insertions(+), 75 deletions(-) delete mode 100644 run.bat delete mode 100644 src/ai/.pydio create mode 100644 src/ai/checkHandStatic.py diff --git a/README.md b/README.md index b9fe78a..f86b457 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,7 @@ celery 是一个简单、灵活且可靠的分布式系统,主要用于处理 Flower WebUi 监视和调试Celery应用程序的运行情况‌。它提供了实时查看任务状态、参数、返回结果等功能,帮助开发者更好地管理和调试分布式任务队列 -python -B main.py - -uvicorn main:app --reload +uvicorn main:app --reload --port 9945 celery -A src.celery.main.app worker -l info -P eventlet diff --git a/main.py b/main.py index 2d91a46..e02fa7a 100644 --- a/main.py +++ b/main.py @@ -35,7 +35,6 @@ app = startApp() if __name__ == "__main__": import uvicorn - uvicorn.run( app=settings.APP_NAME, host=settings.HOST, diff --git a/requirements.txt b/requirements.txt index 5995093..eabc6d1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,6 +3,7 @@ uvicorn==0.27.1 pydantic==2.6.1 pydantic-settings==2.2.0 requests==2.31.0 + numpy==1.26.4 torch==2.2.0 opencv-python==4.9.0.80 diff --git a/run.bat b/run.bat deleted file mode 100644 index 4538de5..0000000 --- a/run.bat +++ /dev/null @@ -1,59 +0,0 @@ -@echo off - -:menu -cls -echo. -echo. AI ˵ -echo. -echo. 1: FastApi -echo. 2: Celery -echo. 3: Flower WebUi -echo. 4: Redis Server -echo. 5: ȫ -ECHO. - -set/p option="ѡ:" -if "%option%"=="1" ( - call:fastapi - goto menu -) -if "%option%"=="2" ( - call:celery - goto menu -) -if "%option%"=="3" ( - call:flower - goto menu -) -if "%option%"=="4" ( - call:redis - goto menu -) -if "%option%"=="5" ( - call:all - goto menu -) - -:fastapi -start cmd /k "echo FastApiԵ... && python -B main.py" -goto:eof - -:celery -start cmd /k "echo CeleryԵ... && celery -A src.celery.main.app worker -l info -P eventlet" -goto:eof - -:flower -start cmd /k "echo FlowerԵ... && celery --broker=redis://:lb714500@127.0.0.1:6379/0 flower --port=5551" -goto:eof - -:redis -start cmd /k "echo Redis ServerԵ... && cd C:\Program Files\Redis && redis-server.exe redis.windows.conf" -goto:eof - -:all -call:redis -call:fastapi -call:celery -call:flower -goto menu -goto:eof \ No newline at end of file diff --git a/src/ai/.pydio b/src/ai/.pydio deleted file mode 100644 index fa54e0e..0000000 --- a/src/ai/.pydio +++ /dev/null @@ -1 +0,0 @@ -0e6c5784-911f-49db-b759-70844e9d3d6e \ No newline at end of file diff --git a/src/ai/checkHandStatic.py b/src/ai/checkHandStatic.py new file mode 100644 index 0000000..b04aa29 --- /dev/null +++ b/src/ai/checkHandStatic.py @@ -0,0 +1,12 @@ +from modelscope.pipelines import pipeline +from modelscope.utils.constant import Tasks + +class checkHandStatic: + modelName: str = 'damo/cv_mobileface_hand-static' + + def check(self, url): + hand_static = pipeline( + task=Tasks.hand_static, + model=self.modelName + ) + return hand_static(url) \ No newline at end of file diff --git a/src/config/setting.py b/src/config/setting.py index a61b340..6d80abb 100644 --- a/src/config/setting.py +++ b/src/config/setting.py @@ -13,22 +13,22 @@ class Settings(BaseSettings): APP_NAME: str = "main:app" HOST: str = "0.0.0.0" # 允许访问程序的ip, 只允许本地访问使用 127.0.0.1, 只在直接允许程序时候生效 - PORT: int = 8000 # 程序端口,只在直接运行程序的时候生效 + PORT: int = 9945 # 程序端口,只在直接运行程序的时候生效 RELOAD: bool = True # 是否自动重启,只在直接运行程序时候生效 CORS_ORIGINS: list[str] = ['*'] # 跨域请求(务必指定精确ip, 不要用localhost) MOUNT_LOCATION: str = '/ws' STATIC_DIR: str = "static" # 静态文件目录 - BASE_URL: AnyHttpUrl = "http://127.0.0.1:8000" # 开发环境(为了存放图片全路径) + BASE_URL: AnyHttpUrl = "http://127.0.0.1:9945" # 开发环境(为了存放图片全路径) class DevelopmentConfig(Settings): pass class ProductionConfig(Settings): - BASE_URL: AnyHttpUrl = "http://114.115.143.81:8000" # 生产环境(为了存放图片全路径) - CORS_ORIGINS: list[AnyHttpUrl] = ["http://114.115.143.81"] # 跨域请求 + BASE_URL: AnyHttpUrl = "http://192.168.31.100:9945" # 生产环境(为了存放图片全路径) + CORS_ORIGINS: list[AnyHttpUrl] = ["*"] # 跨域请求 # REDIS_URI: str = "redis://:123456@redis:6379/0" # Redis # DATABASE_URI: str = "mysql://root:123456@mysql:3306/demo?charset=utf8" # MySQL diff --git a/src/controller/ai/ai.py b/src/controller/ai/ai.py index 0b940b0..611f3cc 100644 --- a/src/controller/ai/ai.py +++ b/src/controller/ai/ai.py @@ -1,20 +1,28 @@ from fastapi import APIRouter from src.celery.ai_image import start_ai_img from src.controller.ai.schemas import textSearchVideoSchemas +from src.ai.checkHandStatic import checkHandStatic from src.utils import * router = APIRouter() +# 传手势照片的地址,ai进行手势识别,判断是什么手势,支持14种手势 +# http://127.0.0.1:9945/api/v1/ai/check_hand?url= +@router.get("/check_hand") +async def checkHand(url: str = ''): + hand = checkHandStatic() + return hand.check(url) -# http://127.0.0.1:8000/api/v1/ai/text_search_video +# http://127.0.0.1:9945/api/v1/ai/text_search_video @router.post("/text_search_video") async def textSearchVideo(params: textSearchVideoSchemas): task = start_ai_img.delay(params.keyWord, params.imgList) - return { + return { 'task_id': task.id, 'message': 'ai任务已添加后台' } + # @router.websocket("/ws") # async def task_status(websocket: WebSocket): # await websocket.accept() @@ -27,20 +35,20 @@ async def textSearchVideo(params: textSearchVideoSchemas): # await websocket.send_json(res) # break; # time.sleep(3) - + # http://127.0.0.1:8000/api/v1/ai/task_status?task_id=c4b57ff1-0ca4-448e-ad95-e3d549841842 @router.get("/task_status") def taskStatus(task_id: str): return getTaskStaus(task_id) - + def getTaskStaus(id: str): async_result = start_ai_img.AsyncResult(id) if async_result.successful(): - return async_result.get() | { 'status': True } + return async_result.get() | {'status': True} else: return { 'status': False, 'message': tool.getState(async_result.status) - } \ No newline at end of file + } diff --git a/src/controller/kuaishou/kuaishou.py b/src/controller/kuaishou/kuaishou.py index 4fe7a4f..8c56daf 100644 --- a/src/controller/kuaishou/kuaishou.py +++ b/src/controller/kuaishou/kuaishou.py @@ -5,7 +5,7 @@ from src.celery.ai_image import start_ai_img router = APIRouter() -# http://127.0.0.1:8000/api/v1/ks/like +# http://127.0.0.1:9945/api/v1/ks/like @router.get("/like") async def LikeVideo(pcursor: str = ''): """