www
This commit is contained in:
@@ -15,9 +15,7 @@ celery 是一个简单、灵活且可靠的分布式系统,主要用于处理
|
|||||||
Flower WebUi 监视和调试Celery应用程序的运行情况。它提供了实时查看任务状态、参数、返回结果等功能,帮助开发者更好地管理和调试分布式任务队列
|
Flower WebUi 监视和调试Celery应用程序的运行情况。它提供了实时查看任务状态、参数、返回结果等功能,帮助开发者更好地管理和调试分布式任务队列
|
||||||
|
|
||||||
|
|
||||||
python -B main.py
|
uvicorn main:app --reload --port 9945
|
||||||
|
|
||||||
uvicorn main:app --reload
|
|
||||||
|
|
||||||
celery -A src.celery.main.app worker -l info -P eventlet
|
celery -A src.celery.main.app worker -l info -P eventlet
|
||||||
|
|
||||||
|
|||||||
1
main.py
1
main.py
@@ -35,7 +35,6 @@ app = startApp()
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import uvicorn
|
import uvicorn
|
||||||
|
|
||||||
uvicorn.run(
|
uvicorn.run(
|
||||||
app=settings.APP_NAME,
|
app=settings.APP_NAME,
|
||||||
host=settings.HOST,
|
host=settings.HOST,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ uvicorn==0.27.1
|
|||||||
pydantic==2.6.1
|
pydantic==2.6.1
|
||||||
pydantic-settings==2.2.0
|
pydantic-settings==2.2.0
|
||||||
requests==2.31.0
|
requests==2.31.0
|
||||||
|
|
||||||
numpy==1.26.4
|
numpy==1.26.4
|
||||||
torch==2.2.0
|
torch==2.2.0
|
||||||
opencv-python==4.9.0.80
|
opencv-python==4.9.0.80
|
||||||
|
|||||||
59
run.bat
59
run.bat
@@ -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
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
0e6c5784-911f-49db-b759-70844e9d3d6e
|
|
||||||
12
src/ai/checkHandStatic.py
Normal file
12
src/ai/checkHandStatic.py
Normal 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)
|
||||||
@@ -13,22 +13,22 @@ class Settings(BaseSettings):
|
|||||||
|
|
||||||
APP_NAME: str = "main:app"
|
APP_NAME: str = "main:app"
|
||||||
HOST: str = "0.0.0.0" # 允许访问程序的ip, 只允许本地访问使用 127.0.0.1, 只在直接允许程序时候生效
|
HOST: str = "0.0.0.0" # 允许访问程序的ip, 只允许本地访问使用 127.0.0.1, 只在直接允许程序时候生效
|
||||||
PORT: int = 8000 # 程序端口,只在直接运行程序的时候生效
|
PORT: int = 9945 # 程序端口,只在直接运行程序的时候生效
|
||||||
RELOAD: bool = True # 是否自动重启,只在直接运行程序时候生效
|
RELOAD: bool = True # 是否自动重启,只在直接运行程序时候生效
|
||||||
|
|
||||||
CORS_ORIGINS: list[str] = ['*'] # 跨域请求(务必指定精确ip, 不要用localhost)
|
CORS_ORIGINS: list[str] = ['*'] # 跨域请求(务必指定精确ip, 不要用localhost)
|
||||||
MOUNT_LOCATION: str = '/ws'
|
MOUNT_LOCATION: str = '/ws'
|
||||||
|
|
||||||
STATIC_DIR: str = "static" # 静态文件目录
|
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):
|
class DevelopmentConfig(Settings):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class ProductionConfig(Settings):
|
class ProductionConfig(Settings):
|
||||||
BASE_URL: AnyHttpUrl = "http://114.115.143.81:8000" # 生产环境(为了存放图片全路径)
|
BASE_URL: AnyHttpUrl = "http://192.168.31.100:9945" # 生产环境(为了存放图片全路径)
|
||||||
CORS_ORIGINS: list[AnyHttpUrl] = ["http://114.115.143.81"] # 跨域请求
|
CORS_ORIGINS: list[AnyHttpUrl] = ["*"] # 跨域请求
|
||||||
|
|
||||||
# REDIS_URI: str = "redis://:123456@redis:6379/0" # Redis
|
# REDIS_URI: str = "redis://:123456@redis:6379/0" # Redis
|
||||||
# DATABASE_URI: str = "mysql://root:123456@mysql:3306/demo?charset=utf8" # MySQL
|
# DATABASE_URI: str = "mysql://root:123456@mysql:3306/demo?charset=utf8" # MySQL
|
||||||
|
|||||||
@@ -1,20 +1,28 @@
|
|||||||
from fastapi import APIRouter
|
from fastapi import APIRouter
|
||||||
from src.celery.ai_image import start_ai_img
|
from src.celery.ai_image import start_ai_img
|
||||||
from src.controller.ai.schemas import textSearchVideoSchemas
|
from src.controller.ai.schemas import textSearchVideoSchemas
|
||||||
|
from src.ai.checkHandStatic import checkHandStatic
|
||||||
from src.utils import *
|
from src.utils import *
|
||||||
|
|
||||||
router = APIRouter()
|
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")
|
@router.post("/text_search_video")
|
||||||
async def textSearchVideo(params: textSearchVideoSchemas):
|
async def textSearchVideo(params: textSearchVideoSchemas):
|
||||||
task = start_ai_img.delay(params.keyWord, params.imgList)
|
task = start_ai_img.delay(params.keyWord, params.imgList)
|
||||||
return {
|
return {
|
||||||
'task_id': task.id,
|
'task_id': task.id,
|
||||||
'message': 'ai任务已添加后台'
|
'message': 'ai任务已添加后台'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# @router.websocket("/ws")
|
# @router.websocket("/ws")
|
||||||
# async def task_status(websocket: WebSocket):
|
# async def task_status(websocket: WebSocket):
|
||||||
# await websocket.accept()
|
# await websocket.accept()
|
||||||
@@ -27,20 +35,20 @@ async def textSearchVideo(params: textSearchVideoSchemas):
|
|||||||
# await websocket.send_json(res)
|
# await websocket.send_json(res)
|
||||||
# break;
|
# break;
|
||||||
# time.sleep(3)
|
# time.sleep(3)
|
||||||
|
|
||||||
|
|
||||||
# http://127.0.0.1:8000/api/v1/ai/task_status?task_id=c4b57ff1-0ca4-448e-ad95-e3d549841842
|
# http://127.0.0.1:8000/api/v1/ai/task_status?task_id=c4b57ff1-0ca4-448e-ad95-e3d549841842
|
||||||
@router.get("/task_status")
|
@router.get("/task_status")
|
||||||
def taskStatus(task_id: str):
|
def taskStatus(task_id: str):
|
||||||
return getTaskStaus(task_id)
|
return getTaskStaus(task_id)
|
||||||
|
|
||||||
|
|
||||||
def getTaskStaus(id: str):
|
def getTaskStaus(id: str):
|
||||||
async_result = start_ai_img.AsyncResult(id)
|
async_result = start_ai_img.AsyncResult(id)
|
||||||
if async_result.successful():
|
if async_result.successful():
|
||||||
return async_result.get() | { 'status': True }
|
return async_result.get() | {'status': True}
|
||||||
else:
|
else:
|
||||||
return {
|
return {
|
||||||
'status': False,
|
'status': False,
|
||||||
'message': tool.getState(async_result.status)
|
'message': tool.getState(async_result.status)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ from src.celery.ai_image import start_ai_img
|
|||||||
|
|
||||||
router = APIRouter()
|
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")
|
@router.get("/like")
|
||||||
async def LikeVideo(pcursor: str = ''):
|
async def LikeVideo(pcursor: str = ''):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user