init: 基于K3s的智慧工厂边缘质量检测系统
基于 K3s 边缘计算框架的工业产品质量检测演示系统,纯 CPU 推理,适用于 AMD 9950 平台。
模拟智慧工厂场景:产线边缘节点(智能摄像头)采集产品图像,在边缘数据中心进行 AI 缺陷检测,只上报检测结果到聚合服务。
体现边缘计算优势:
┌─────────────────────────────────────────────────────┐ │ VMware Workstation (Windows) │ │ AMD 9950 CPU │ │ │ │ ┌──────────────────────────────────────────┐ │ │ │ Ubuntu 22.04 VM - Server │ │ │ │ 2vCPU / 4GB RAM │ │ │ │ │ │ │ │ ┌──────────────┐ ┌──────────────┐ │ │ │ │ │ edge-inference│ │ result- │ │ │ │ │ │ (AI推理服务) │ │ aggregator │ │ │ │ │ │ │ │ (聚合看板) │ │ │ │ │ │ • 缺陷检测 │ │ • 数据统计 │ │ │ │ │ │ • 置信度计算 │ │ • Web看板 │ │ │ │ │ │ • 特征提取 │ │ • 告警列表 │ │ │ │ │ └──────────────┘ └──────────────┘ │ │ │ │ ▲ │ │ │ │ 6443 │ │ │ │ └─────────┼──────────────────────────────────┘ │ │ │ K3s控制平面 │ │ │ │ │ ┌─────────▼──────────────────────────────────┐ │ │ │ Ubuntu 22.04 VM - Agent │ │ │ │ 1vCPU / 2GB RAM │ │ │ │ │ │ │ │ ┌──────────────────────────────────┐ │ │ │ │ │ camera-simulator │ │ │ │ │ │ (产线摄像头模拟器) │ │ │ │ │ │ │ │ │ │ │ │ • 生成产品图像(带缺陷模拟) │ │ │ │ │ │ • 定时发送推理请求 │ │ │ │ │ │ • 支持边缘自治(断网处理) │ │ │ │ │ └──────────────────────────────────┘ │ │ │ └──────────────────────────────────────────┘ │ │ │ │ 访问看板: http://<Server_IP>:30080 │ └─────────────────────────────────────────────────────┘
edge-factory-quality/ ├── edge-inference/ # AI推理服务 │ ├── main.py # Flask推理API(/infer, /batch_infer, /stats, /health) │ └── requirements.txt ├── camera-simulator/ # 产线摄像头模拟器 │ ├── main.py # 图像生成 + 推理请求发送 │ └── requirements.txt ├── result-aggregator/ # 结果聚合服务 │ ├── main.py # 数据聚合 + Web看板(端口8080) │ └── requirements.txt ├── dockerfiles/ # Docker镜像构建文件 │ ├── inference.Dockerfile │ ├── camera.Dockerfile │ └── aggregator.Dockerfile ├── k8s-manifests/ # K3s部署文件 │ ├── namespace.yaml │ ├── inference/ │ │ └── deployment.yaml │ ├── camera/ │ │ └── daemonset.yaml │ └── aggregator/ │ └── deployment.yaml ├── benchmark/ # 基准测试工具 │ ├── latency_test.py # 延迟/吞吐量测试 │ └── resource_monitor.py # 资源监控 ├── setup-vm.sh # VM环境配置脚本 └── build-and-deploy.sh # 一键构建+部署脚本
VMware设置:虚拟机设置 → 网络适配器 → 桥接模式(自动)
在每台 VM 上执行:
# 复制项目文件到VM(从Windows通过SCP或共享文件夹) # 然后在VM中: chmod +x setup-vm.sh # Server VM上: ./setup-vm.sh server # Agent VM上: ./setup-vm.sh agent # 然后输入Server IP和Token
在 Server VM 上执行:
cd edge-factory-quality/ chmod +x build-and-deploy.sh ./build-and-deploy.sh
# 查看所有Pod状态 sudo kubectl get pods -n edge-factory -o wide # 查看推理服务日志 sudo kubectl logs -n edge-factory -l app=edge-inference -f # 查看摄像头模拟器日志 sudo kubectl logs -n edge-factory -l app=camera-simulator -f # 打开监控看板(浏览器访问) # http://<Server_VM_IP>:30080
首次运行测试前,请先安装测试依赖:pip install -r benchmark/requirements.txt。
pip install -r benchmark/requirements.txt
# 端口转发推理服务到本地 sudo kubectl port-forward -n edge-factory svc/edge-inference 5000:5000 & # 运行延迟测试 python benchmark/latency_test.py --edge-url http://localhost:5000
# 实时监控Pod资源使用 python benchmark/resource_monitor.py --namespace edge-factory # 或查看当前快照 sudo kubectl top pods -n edge-factory
/health
/infer
/batch_infer
/stats
/
/report
/api/summary
/api/alerts
/api/timeseries
本项目适合作为”边缘计算框架调研及演示”大作业,包含:
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802047560号
智慧工厂边缘质量检测系统
基于 K3s 边缘计算框架的工业产品质量检测演示系统,纯 CPU 推理,适用于 AMD 9950 平台。
应用场景
模拟智慧工厂场景:产线边缘节点(智能摄像头)采集产品图像,在边缘数据中心进行 AI 缺陷检测,只上报检测结果到聚合服务。
体现边缘计算优势:
系统架构
代码结构
快速开始
1. 虚拟机配置
Server VM(控制平面)
Agent VM(边缘节点)
2. 环境配置
在每台 VM 上执行:
3. 构建与部署
在 Server VM 上执行:
4. 查看结果
基准测试
延迟测试
资源监控
边缘计算优势分析
API 接口说明
推理服务 (edge-inference:5000)
/health/infer/batch_infer/stats聚合服务 (result-aggregator:8080)
//health/report/api/summary/api/alerts/api/timeseries技术栈
提交说明
本项目适合作为”边缘计算框架调研及演示”大作业,包含: