Repository navigation
Expand file tree
/
Copy pathrun.bat
More file actions
61 lines (56 loc) · 1.84 KB
/
Copy pathrun.bat
File metadata and controls
61 lines (56 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
@echo off
TITLE Helmet Detection & Road Safety Analyzer
echo ========================================================
echo Starting Helmet Detection & Road Safety Analyzer
echo Streamlit + YOLOv8 Deep Learning + ByteTrack
echo ========================================================
cd /d "%~dp0"
if not exist ".venv\Scripts\activate.bat" (
echo [INFO] Virtual environment not found. Creating .venv...
python -m venv .venv
if errorlevel 1 (
echo [ERROR] Failed to create virtual environment. Ensure Python 3.10+ is installed.
pause
exit /b 1
)
call .venv\Scripts\activate.bat
echo [INFO] Upgrading pip and installing requirements...
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
if errorlevel 1 (
echo [ERROR] Failed to install dependencies from requirements.txt.
pause
exit /b 1
)
) else (
call .venv\Scripts\activate.bat
)
if not exist ".venv\Scripts\streamlit.exe" (
echo [WARNING] Streamlit not detected in .venv. Installing dependencies...
python -m pip install -r requirements.txt
if errorlevel 1 (
echo [ERROR] Dependency installation failed.
pause
exit /b 1
)
)
echo [INFO] Model checkpoint check...
if exist "models\best.pt" (
echo [INFO] Model found at models\best.pt
) else if exist "runs\train\helmet_detector2\weights\best.pt" (
echo [INFO] Model found at legacy path runs\train\...
) else (
echo [ERROR] Trained weights file not found!
echo Expected: models\best.pt
echo Legacy: runs\train\helmet_detector2\weights\best.pt
pause
exit /b 1
)
echo [INFO] Launching Streamlit application on default port 8501...
python -m streamlit run app.py
if errorlevel 1 (
echo [ERROR] Application failed to launch or exited with an error.
pause
exit /b 1
)
pause