Initial commit: Video detection platform with YOLO models

Features:
- Fire detection (YOLOv10)
- Helmet detection (YOLOv8)
- Crowd detection (YOLOv8)
- Smoking detection (YOLOv8)
- Loitering detection (YOLOv8)

Tech Stack:
- Frontend: Vue 3 + Vite + Element Plus
- Backend: FastAPI + WebSocket
- Monorepo: pnpm workspace + Turbo
- Docker support included
This commit is contained in:
wwh
2026-05-18 10:54:10 +08:00
commit 8fb58c75fe
42 changed files with 6663 additions and 0 deletions

31
docker/Dockerfile.server Normal file
View File

@@ -0,0 +1,31 @@
FROM python:3.11-slim
WORKDIR /app
# 安装系统依赖
RUN apt-get update && apt-get install -y \
libgl1-mesa-glx \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
# 复制依赖文件
COPY requirements.txt .
# 安装 Python 依赖
RUN pip install --no-cache-dir -r requirements.txt
# 复制应用代码
COPY . .
# 创建静态文件目录
RUN mkdir -p static/uploads static/results static/temp
# 暴露端口
EXPOSE 8000
# 启动命令
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

31
docker/Dockerfile.web Normal file
View File

@@ -0,0 +1,31 @@
# 构建阶段
FROM node:20-alpine AS builder
WORKDIR /app
# 复制 package.json
COPY package.json ./
# 安装依赖
RUN npm install
# 复制源代码
COPY . .
# 构建
RUN npm run build
# 生产阶段
FROM nginx:alpine
# 复制构建产物
COPY --from=builder /app/dist /usr/share/nginx/html
# 复制 nginx 配置
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 暴露端口
EXPOSE 80
# 启动 nginx
CMD ["nginx", "-g", "daemon off;"]

26
docker/docker-compose.yml Normal file
View File

@@ -0,0 +1,26 @@
version: '3.8'
services:
backend:
build:
context: ../apps/server
dockerfile: ../../docker/Dockerfile.server
ports:
- "8000:8000"
volumes:
- ../models:/app/models:ro
- ../apps/server/static:/app/static
environment:
- MODEL_PATH=/app/models
- STATIC_PATH=/app/static
restart: unless-stopped
frontend:
build:
context: ../apps/web
dockerfile: ../../docker/Dockerfile.web
ports:
- "80:80"
depends_on:
- backend
restart: unless-stopped

40
docker/nginx.conf Normal file
View File

@@ -0,0 +1,40 @@
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
# 前端静态文件
location / {
try_files $uri $uri/ /index.html;
}
# API 代理
location /api/ {
proxy_pass http://backend:8000/api/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# WebSocket 代理
location /ws/ {
proxy_pass http://backend:8000/ws/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# 静态文件代理
location /static/ {
proxy_pass http://backend:8000/static/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}