-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·155 lines (135 loc) · 5.2 KB
/
setup.sh
File metadata and controls
executable file
·155 lines (135 loc) · 5.2 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/bash
echo "Setting up Depth Surge 3D..."
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check for Python 3
if ! command_exists python3; then
echo "[ERROR] Python 3 is not installed. Please install Python 3.9 or later."
exit 1
fi
# Check Python version
python_version=$(python3 -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
required_version="3.9"
if [ "$(printf '%s\n' "$required_version" "$python_version" | sort -V | head -n1)" != "$required_version" ]; then
echo "[ERROR] Python $required_version or later is required. Found: $python_version"
exit 1
fi
echo "[OK] Python $python_version found"
# Check for uv package manager
if command_exists uv; then
echo "[OK] uv package manager found - using for fast setup"
use_uv=true
if [[ -d "/usr/lib/wsl" ]]; then
export UV_LINK_MODE=copy
fi
else
echo "[INFO] uv not found - using pip (consider installing uv for faster setup: curl -LsSf https://astral.sh/uv/install.sh | sh)"
use_uv=false
fi
# Setup virtual environment and dependencies
if [ "$use_uv" = true ]; then
echo "Setting up environment with uv..."
uv sync
else
echo "Setting up environment with pip..."
if [ ! -d "venv" ]; then
python3 -m venv venv
fi
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
if [[ -f "nvidia-smi" || -f "/usr/lib/wsl/lib/nvidia-smi" ]]; then
echo "Installing Cuda pytorch"
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu130
elif [[ -f "rocminfo" ]]; then
echo "Installing ROC pytorch"
pip install torch torchvision --index-url https://download.pytorch.org/whl/rocm6.4
fi
fi
# Download Video-Depth-Anything repository if not present (to vendor directory)
if [ ! -d "vendor/Video-Depth-Anything" ]; then
echo "Downloading Video-Depth-Anything repository to vendor directory..."
mkdir -p vendor
git clone https://github.com/DepthAnything/Video-Depth-Anything.git vendor/Video-Depth-Anything
if [ $? -eq 0 ]; then
echo "[OK] Video-Depth-Anything repository downloaded successfully"
else
echo "[ERROR] Failed to download Video-Depth-Anything repository"
exit 1
fi
else
echo "[OK] Video-Depth-Anything repository already exists"
fi
# Create models directory if not present
mkdir -p models
# Download Video-Depth-Anything-Large model if not present
model_path="models/Video-Depth-Anything-Large/video_depth_anything_vitl.pth"
if [ ! -f "$model_path" ]; then
echo "Downloading Video-Depth-Anything-Large model (~1.3GB, this may take a while)..."
mkdir -p "models/Video-Depth-Anything-Large"
# Try using curl first, then wget as fallback
if command_exists curl; then
curl -L "https://huggingface.co/depth-anything/Video-Depth-Anything-Large/resolve/main/video_depth_anything_vitl.pth" \
-o "$model_path" --progress-bar
elif command_exists wget; then
wget "https://huggingface.co/depth-anything/Video-Depth-Anything-Large/resolve/main/video_depth_anything_vitl.pth" \
-O "$model_path" --progress=bar
else
echo "[ERROR] Neither curl nor wget found. Please install one of them to download the model."
echo " You can manually download the model from:"
echo " https://huggingface.co/depth-anything/Video-Depth-Anything-Large/resolve/main/video_depth_anything_vitl.pth"
echo " and place it at: $model_path"
exit 1
fi
if [ -f "$model_path" ]; then
echo "[OK] Model downloaded successfully"
echo "[INFO] Model size: $(du -h "$model_path" | cut -f1)"
else
echo "[ERROR] Failed to download model"
exit 1
fi
else
echo "[OK] Video-Depth-Anything-Large model already exists"
echo "[INFO] Model size: $(du -h "$model_path" | cut -f1)"
fi
# Check if FFmpeg is available
if command_exists ffmpeg; then
echo "[OK] FFmpeg found"
else
echo "[WARN] FFmpeg not found - install it for video processing:"
if command_exists apt-get; then
echo " sudo apt-get install ffmpeg"
elif command_exists brew; then
echo " brew install ffmpeg"
elif command_exists dnf; then
echo " sudo dnf install ffmpeg"
else
echo " Please install FFmpeg for your system"
fi
fi
echo ""
echo "Setup complete!"
echo ""
echo "Quick start:"
echo " # Start the web interface (recommended for most users):"
echo " ./run_ui.sh"
echo ""
echo " # Or use command line directly:"
echo " python depth_surge_3d.py --help"
echo " python depth_surge_3d.py input_video.mp4"
echo ""
echo "Available models:"
echo " - Video-Depth-Anything-Large (335M params) - Downloaded"
echo ""
echo "Additional models available (optional):"
echo " ./scripts/download_models.sh small # Video-Depth-Anything-Small (24.8M params, fastest)"
echo " ./scripts/download_models.sh base # Video-Depth-Anything-Base (97.5M params, balanced)"
echo ""
echo "Tips:"
echo " - Use --vr-resolution 16x9-720p for quick tests"
echo " - Use --processing-mode batch for faster processing"
echo " - Try custom resolutions: --vr-resolution custom:1920x1080"
echo ""
echo "Output will be saved to ./output/ directory"