This commit is contained in:
编码猿
2025-08-29 22:05:02 +08:00
parent b083368f67
commit 858077692d
9 changed files with 33 additions and 75 deletions

View File

@@ -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

View File

@@ -35,7 +35,6 @@ app = startApp()
if __name__ == "__main__":
import uvicorn
uvicorn.run(
app=settings.APP_NAME,
host=settings.HOST,

View File

@@ -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

59
run.bat
View File

@@ -1,59 +0,0 @@
@echo off
:menu
cls
echo.
echo. AI<41><49><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD>
echo.
echo. 1: <20><><EFBFBD><EFBFBD> FastApi
echo. 2: <20><><EFBFBD><EFBFBD> Celery
echo. 3: <20><><EFBFBD><EFBFBD> Flower WebUi
echo. 4: <20><><EFBFBD><EFBFBD> Redis Server
echo. 5: ȫ<><C8AB> <20><><EFBFBD><EFBFBD>
ECHO.
set/p option="<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD>:"
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 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FastApi<70><69><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>... && python -B main.py"
goto:eof
:celery
start cmd /k "echo <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Celery<72><79><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>... && celery -A src.celery.main.app worker -l info -P eventlet"
goto:eof
:flower
start cmd /k "echo <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Flower<65><72><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>... && celery --broker=redis://:lb714500@127.0.0.1:6379/0 flower --port=5551"
goto:eof
:redis
start cmd /k "echo <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Redis Server<65><72><EFBFBD><EFBFBD><EFBFBD>Ե<EFBFBD>... && 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

View File

@@ -1 +0,0 @@
0e6c5784-911f-49db-b759-70844e9d3d6e

12
src/ai/checkHandStatic.py Normal file
View File

@@ -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)

View File

@@ -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

View File

@@ -1,12 +1,19 @@
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)
@@ -15,6 +22,7 @@ async def textSearchVideo(params: textSearchVideoSchemas):
'message': 'ai任务已添加后台'
}
# @router.websocket("/ws")
# async def task_status(websocket: WebSocket):
# await websocket.accept()
@@ -38,7 +46,7 @@ def taskStatus(task_id: str):
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,

View File

@@ -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 = ''):
"""