Darveht commited on
Commit
2457274
·
verified ·
1 Parent(s): 1243e78

Upload install.sh with huggingface_hub

Browse files
Files changed (1) hide show
  1. install.sh +223 -0
install.sh ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # ZenVision AI Subtitle Generator - Installation Script
4
+ # Instala todas las dependencias y modelos necesarios
5
+
6
+ set -e
7
+
8
+ echo "🚀 Instalando ZenVision AI Subtitle Generator..."
9
+ echo "=================================================="
10
+
11
+ # Colors for output
12
+ RED='\033[0;31m'
13
+ GREEN='\033[0;32m'
14
+ YELLOW='\033[1;33m'
15
+ BLUE='\033[0;34m'
16
+ NC='\033[0m' # No Color
17
+
18
+ # Function to print colored output
19
+ print_status() {
20
+ echo -e "${BLUE}[INFO]${NC} $1"
21
+ }
22
+
23
+ print_success() {
24
+ echo -e "${GREEN}[SUCCESS]${NC} $1"
25
+ }
26
+
27
+ print_warning() {
28
+ echo -e "${YELLOW}[WARNING]${NC} $1"
29
+ }
30
+
31
+ print_error() {
32
+ echo -e "${RED}[ERROR]${NC} $1"
33
+ }
34
+
35
+ # Check Python version
36
+ print_status "Verificando versión de Python..."
37
+ python_version=$(python3 --version 2>&1 | awk '{print $2}' | cut -d. -f1,2)
38
+ required_version="3.8"
39
+
40
+ if [ "$(printf '%s\n' "$required_version" "$python_version" | sort -V | head -n1)" = "$required_version" ]; then
41
+ print_success "Python $python_version encontrado"
42
+ else
43
+ print_error "Python $required_version o superior requerido. Encontrado: $python_version"
44
+ exit 1
45
+ fi
46
+
47
+ # Check if running on supported OS
48
+ print_status "Detectando sistema operativo..."
49
+ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
50
+ OS="linux"
51
+ print_success "Sistema Linux detectado"
52
+ elif [[ "$OSTYPE" == "darwin"* ]]; then
53
+ OS="macos"
54
+ print_success "Sistema macOS detectado"
55
+ elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then
56
+ OS="windows"
57
+ print_success "Sistema Windows detectado"
58
+ else
59
+ print_warning "Sistema operativo no reconocido: $OSTYPE"
60
+ OS="unknown"
61
+ fi
62
+
63
+ # Install system dependencies
64
+ print_status "Instalando dependencias del sistema..."
65
+
66
+ if [[ "$OS" == "linux" ]]; then
67
+ if command -v apt-get &> /dev/null; then
68
+ sudo apt-get update
69
+ sudo apt-get install -y ffmpeg python3-dev python3-pip build-essential
70
+ print_success "Dependencias de Ubuntu/Debian instaladas"
71
+ elif command -v yum &> /dev/null; then
72
+ sudo yum install -y ffmpeg python3-devel python3-pip gcc gcc-c++
73
+ print_success "Dependencias de CentOS/RHEL instaladas"
74
+ elif command -v pacman &> /dev/null; then
75
+ sudo pacman -S --noconfirm ffmpeg python python-pip base-devel
76
+ print_success "Dependencias de Arch Linux instaladas"
77
+ else
78
+ print_warning "Gestor de paquetes no reconocido. Instala manualmente: ffmpeg, python3-dev"
79
+ fi
80
+ elif [[ "$OS" == "macos" ]]; then
81
+ if command -v brew &> /dev/null; then
82
+ brew install ffmpeg
83
+ print_success "FFmpeg instalado via Homebrew"
84
+ else
85
+ print_warning "Homebrew no encontrado. Instala FFmpeg manualmente"
86
+ fi
87
+ fi
88
+
89
+ # Create virtual environment
90
+ print_status "Creando entorno virtual..."
91
+ if [ ! -d "venv" ]; then
92
+ python3 -m venv venv
93
+ print_success "Entorno virtual creado"
94
+ else
95
+ print_warning "Entorno virtual ya existe"
96
+ fi
97
+
98
+ # Activate virtual environment
99
+ print_status "Activando entorno virtual..."
100
+ source venv/bin/activate
101
+ print_success "Entorno virtual activado"
102
+
103
+ # Upgrade pip
104
+ print_status "Actualizando pip..."
105
+ pip install --upgrade pip setuptools wheel
106
+
107
+ # Install PyTorch with CUDA support if available
108
+ print_status "Detectando soporte CUDA..."
109
+ if command -v nvidia-smi &> /dev/null; then
110
+ print_success "NVIDIA GPU detectada, instalando PyTorch con CUDA"
111
+ pip install torch torchaudio --index-url https://download.pytorch.org/whl/cu118
112
+ else
113
+ print_warning "No se detectó GPU NVIDIA, instalando PyTorch CPU"
114
+ pip install torch torchaudio --index-url https://download.pytorch.org/whl/cpu
115
+ fi
116
+
117
+ # Install Python dependencies
118
+ print_status "Instalando dependencias de Python..."
119
+ pip install -r requirements.txt
120
+ print_success "Dependencias de Python instaladas"
121
+
122
+ # Download spaCy models
123
+ print_status "Descargando modelos de spaCy..."
124
+ python -m spacy download en_core_web_sm
125
+ python -m spacy download es_core_news_sm
126
+
127
+ # Try to download additional language models
128
+ for lang in fr de it pt; do
129
+ print_status "Intentando descargar modelo de spaCy para $lang..."
130
+ python -m spacy download ${lang}_core_news_sm || print_warning "Modelo $lang no disponible"
131
+ done
132
+
133
+ print_success "Modelos de spaCy descargados"
134
+
135
+ # Download NLTK data
136
+ print_status "Descargando datos de NLTK..."
137
+ python -c "
138
+ import nltk
139
+ nltk.download('punkt')
140
+ nltk.download('stopwords')
141
+ nltk.download('vader_lexicon')
142
+ print('Datos de NLTK descargados')
143
+ "
144
+
145
+ # Create necessary directories
146
+ print_status "Creando directorios necesarios..."
147
+ mkdir -p ~/.zenvision/cache
148
+ mkdir -p ~/.zenvision/models
149
+ mkdir -p /tmp/zenvision
150
+ print_success "Directorios creados"
151
+
152
+ # Test installation
153
+ print_status "Probando instalación..."
154
+ python -c "
155
+ import torch
156
+ import whisper
157
+ import transformers
158
+ import gradio
159
+ import moviepy
160
+ import librosa
161
+ import cv2
162
+ import spacy
163
+ print('✅ Todas las librerías principales importadas correctamente')
164
+
165
+ # Test CUDA availability
166
+ if torch.cuda.is_available():
167
+ print(f'✅ CUDA disponible: {torch.cuda.get_device_name(0)}')
168
+ else:
169
+ print('⚠️ CUDA no disponible, usando CPU')
170
+
171
+ # Test Whisper
172
+ try:
173
+ model = whisper.load_model('tiny')
174
+ print('✅ Whisper cargado correctamente')
175
+ except Exception as e:
176
+ print(f'❌ Error cargando Whisper: {e}')
177
+ "
178
+
179
+ # Create launcher script
180
+ print_status "Creando script de lanzamiento..."
181
+ cat > run_zenvision.sh << 'EOF'
182
+ #!/bin/bash
183
+ cd "$(dirname "$0")"
184
+ source venv/bin/activate
185
+ python app.py
186
+ EOF
187
+
188
+ chmod +x run_zenvision.sh
189
+ print_success "Script de lanzamiento creado: ./run_zenvision.sh"
190
+
191
+ # Display system information
192
+ print_status "Información del sistema:"
193
+ echo " - Python: $(python --version)"
194
+ echo " - PyTorch: $(python -c 'import torch; print(torch.__version__)')"
195
+ echo " - CUDA disponible: $(python -c 'import torch; print(torch.cuda.is_available())')"
196
+ echo " - Dispositivos CUDA: $(python -c 'import torch; print(torch.cuda.device_count())')"
197
+
198
+ # Calculate approximate model size
199
+ print_status "Calculando tamaño aproximado de modelos..."
200
+ echo " - Whisper large-v2: ~1.5 GB"
201
+ echo " - BERT multilingual: ~400 MB"
202
+ echo " - RoBERTa sentiment: ~200 MB"
203
+ echo " - DistilRoBERTa emotion: ~300 MB"
204
+ echo " - Modelos de traducción: ~500 MB"
205
+ echo " - Otros modelos: ~300 MB"
206
+ echo " - TOTAL APROXIMADO: ~3.2 GB"
207
+
208
+ print_success "¡Instalación completada!"
209
+ echo ""
210
+ echo "=================================================="
211
+ echo "🎬 ZenVision AI Subtitle Generator está listo!"
212
+ echo "=================================================="
213
+ echo ""
214
+ echo "Para ejecutar la aplicación:"
215
+ echo " 1. Activar entorno virtual: source venv/bin/activate"
216
+ echo " 2. Ejecutar aplicación: python app.py"
217
+ echo " 3. O usar el script: ./run_zenvision.sh"
218
+ echo ""
219
+ echo "La aplicación estará disponible en: http://localhost:7860"
220
+ echo ""
221
+ echo "Para más información, consulta el README.md"
222
+ echo ""
223
+ print_success "¡Disfruta usando ZenVision! 🚀"