-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ps1
More file actions
130 lines (116 loc) · 3.8 KB
/
Copy pathsetup.ps1
File metadata and controls
130 lines (116 loc) · 3.8 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# CVFit Setup Script for Windows
# This script sets up all required dependencies and launches CVFit
function Write-ColorOutput($ForegroundColor) {
$fc = $host.UI.RawUI.ForegroundColor
$host.UI.RawUI.ForegroundColor = $ForegroundColor
if ($args) {
Write-Output $args
}
else {
$input | Write-Output
}
$host.UI.RawUI.ForegroundColor = $fc
}
function Write-Title($message) {
Write-Output "==========================================================="
Write-ColorOutput Green " $message"
Write-Output "==========================================================="
}
Write-Title "Setting up CVFit - Fitness Tracker"
try {
$pythonVersion = (python --version 2>&1)
if (!($pythonVersion -match "Python 3\.(\d+)")) {
Write-ColorOutput Red "❌ Python 3.8 or higher is required."
Write-Output "Please install Python from https://www.python.org/downloads/"
exit 1
}
$minorVersion = [int]$Matches[1]
if ($minorVersion -lt 8) {
Write-ColorOutput Red "❌ Python 3.8 or higher is required. You have $pythonVersion"
Write-Output "Please install a newer version from https://www.python.org/downloads/"
exit 1
}
Write-ColorOutput Green "✅ Found $pythonVersion"
}
catch {
Write-ColorOutput Red "❌ Python not found or error checking version."
Write-Output "Please install Python 3.8+ from https://www.python.org/downloads/"
Write-Output "Make sure to check 'Add Python to PATH' during installation."
exit 1
}
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
Set-Location -Path $scriptDir
if (!(Test-Path -Path "env")) {
Write-Output "Creating virtual environment..."
try {
python -m venv env
if (!$?) {
Write-ColorOutput Red "❌ Failed to create virtual environment."
exit 1
}
Write-ColorOutput Green "✅ Virtual environment created successfully"
}
catch {
Write-ColorOutput Red "❌ Error creating virtual environment: $_"
exit 1
}
}
else {
Write-ColorOutput Green "✅ Virtual environment already exists"
}
Write-Output "Activating virtual environment..."
try {
& .\env\Scripts\Activate.ps1
if (!$?) {
Write-ColorOutput Red "❌ Failed to activate virtual environment."
exit 1
}
}
catch {
Write-ColorOutput Red "❌ Error activating virtual environment."
Write-Output "You may need to run PowerShell as Administrator or enable script execution policy."
Write-Output "Try running: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser"
exit 1
}
Write-Output "Installing required packages (this may take a few minutes)..."
try {
pip install --upgrade pip
pip install -r requirements.txt
if (!$?) {
Write-ColorOutput Red "❌ Failed to install required packages."
Write-Output "Check your internet connection and try again."
exit 1
}
Write-ColorOutput Green "✅ Packages installed successfully"
}
catch {
Write-ColorOutput Red "❌ Error installing packages: $_"
exit 1
}
if (!(Test-Path -Path "yolov8n-pose.pt")) {
Write-Output "Downloading pose detection model..."
try {
python -c "from ultralytics import YOLO; YOLO('yolov8n-pose.pt')"
if (!$?) {
Write-ColorOutput Red "❌ Failed to download pose model."
exit 1
}
Write-ColorOutput Green "✅ Pose model downloaded successfully"
}
catch {
Write-ColorOutput Red "❌ Error downloading pose model: $_"
exit 1
}
}
else {
Write-ColorOutput Green "✅ Pose model already exists"
}
Write-Title "🎉 Setup completed successfully! Launching CVFit..."
try {
python cvfit.py
}
catch {
Write-ColorOutput Red "❌ Error launching CVFit: $_"
exit 1
}
deactivate