Downloads · 30 days
0
KUNIN/single-mouse-webrtc-pose
single-mouse-webrtc-pose is a machine learning model from KUNIN. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
这是一个基于YOLOv8的单鼠姿态检测WebRTC实时处理系统,支持8个关键点检测,提供完整的WebSocket和REST API接口,专为实时视频流处理和前端集成设计。
Downloads · 30 days
0
Access
Public
Updated Jun 5, 2025
Repo size
15.1 MB
Likes
1
Public
Click a slice to open those files.
.engine8.2 MB · 54%
From the Hugging Face model README
这是一个基于YOLOv8的单鼠姿态检测WebRTC实时处理系统,支持8个关键点检测,提供完整的WebSocket和REST API接口,专为实时视频流处理和前端集成设计。
single_mouse_webrtc_project/
├── README.md # 项目主文档
├── API对接文档.md # 详细API对接文档
├── README_Gradio_WebRTC.md # WebRTC技术文档
├── PROJECT_CHECKLIST.md # 部署检查清单
├── requirements_gradio_webrtc.txt # Python依赖文件
├── deploy.sh # 自动部署脚本
├── start_gradio_webrtc.py # 服务启动管理器
├── gradio_webrtc_server.py # Gradio WebRTC服务器
├── gradio_webrtc_api.py # FastAPI REST服务器
├── test_gradio_webrtc_client.py # 完整测试客户端
├── check_model.py # 模型检查脚本
├── inspect_model.py # 模型详细检查脚本
├── create_test_image.py # 测试图像生成脚本
├── test_mouse.jpg # 测试用小鼠图像
└── models/ # 模型文件目录
└── kunin-mice-pose.v0.1.5n.pt # YOLOv8姿态检测模型
# 进入项目目录
cd single_mouse_webrtc_project
# 运行自动部署脚本
./deploy.sh
# 1. 创建Python虚拟环境
conda create -n mouse-webrtc python=3.11
conda activate mouse-webrtc
# 2. 安装依赖
pip install -r requirements_gradio_webrtc.txt
# 3. 检查模型
python check_model.py
# 4. 启动服务
python start_gradio_webrtc.py
启动成功后,您将看到以下服务地址:
# 运行完整测试套件
python test_gradio_webrtc_client.py
const ws = new WebSocket('ws://localhost:8765/ws/stream');
ws.onopen = () => console.log('WebSocket连接成功');
// 发送图像帧
function sendFrame(imageBase64) {
const frameData = {
image: imageBase64,
conf_threshold: 0.3,
frame_id: Date.now(),
timestamp: Date.now() / 1000
};
ws.send(JSON.stringify(frameData));
}
// 接收检测结果
ws.onmessage = (event) => {
const result = JSON.parse(event.data);
if (result.success && result.mouse_detected) {
console.log('检测到小鼠:', result.keypoints.length, '个关键点');
// 处理检测结果...
}
};
// 处理单张图像
fetch('http://localhost:8765/api/process_frame', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
image: imageBase64,
conf_threshold: 0.3
})
})
.then(response => response.json())
.then(result => {
console.log('检测结果:', result);
});
系统检测8个关键点:
| 索引 | 名称 | 描述 |
|---|---|---|
| 0 | nose | 鼻子 |
| 1 | left_ear | 左耳 |
| 2 | right_ear | 右耳 |
| 3 | torso | 躯干 |
| 4 | left_leg | 左腿 |
| 5 | right_leg | 右腿 |
| 6 | tail_base | 尾巴根部 |
| 7 | tail_tip | 尾巴尖 |
模型加载失败
# 检查模型文件
ls -la models/
python check_model.py
端口占用
# 检查端口使用情况
lsof -i :7860
lsof -i :8765
依赖缺失
# 重新安装依赖
pip install -r requirements_gradio_webrtc.txt
GPU不可用
# 检查CUDA环境
python -c "import torch; print(torch.cuda.is_available())"
# 启用详细日志
export LOG_LEVEL=DEBUG
python start_gradio_webrtc.py
本系统专为前端集成设计,支持:
详细集成示例请参考 API对接文档.md。
websockets库连接ws模块本项目为内部使用,请确保模型文件和代码的合规使用。
如遇到问题或需要技术支持,请:
项目版本: 1.0.0
最后更新: 2025-06-05
兼容性: Python 3.11+, 支持GPU/CPU