le-yolo/run_app.sh

50 lines
1.1 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# 创建虚拟环境并且运行app.py的脚本
echo "开始设置YOLO项目环境..."
# 检查Python3是否安装
if ! command -v python3 &> /dev/null; then
echo "错误: Python3 未安装请先安装Python3"
exit 1
fi
# 创建虚拟环境
echo "创建虚拟环境..."
python3 -m venv venv
# 激活虚拟环境
echo "激活虚拟环境..."
source venv/bin/activate
# 升级pip
echo "升级pip..."
pip install --upgrade pip
# 安装依赖
echo "安装项目依赖..."
pip install -r requirements.txt
# 检查测试视频文件是否存在
if [ ! -f "res/test.mp4" ]; then
echo "❌ 错误: res/test.mp4 文件不存在!"
echo ""
echo "请按以下步骤操作:"
echo "1. 在 res/ 目录中放置一个视频文件"
echo "2. 将视频文件重命名为 test.mp4"
echo "3. 重新运行此脚本"
echo ""
echo "支持的视频格式: .mp4, .avi, .mov, .mkv 等"
echo "脚本已停止运行。"
exit 1
fi
echo "✅ 找到测试视频文件: res/test.mp4"
# 运行应用
echo "运行应用..."
cd src
python app.py
echo "✅ 应用运行完成!检测结果已保存在 runs/detect/ 目录中"