Fix compatibility issues and improve error handling - Updated requirements.txt with specific version constraints - Enhanced system compatibility checker in app.py - Added install_dependencies.py script for easy setup - Updated README with troubleshooting guide - Improved .gitattributes for better file handling
fdbfc7f
| #!/usr/bin/env python3 | |
| """ | |
| Script para instalar y verificar dependencias del Space | |
| Optimizado para resolver problemas de compatibilidad | |
| """ | |
| import subprocess | |
| import sys | |
| import os | |
| def run_command(command): | |
| """Ejecuta un comando y retorna el resultado""" | |
| try: | |
| result = subprocess.run(command, shell=True, capture_output=True, text=True) | |
| return result.returncode == 0, result.stdout, result.stderr | |
| except Exception as e: | |
| return False, "", str(e) | |
| def install_dependencies(): | |
| """Instala las dependencias con versiones específicas""" | |
| print("🔧 Instalando dependencias...") | |
| # Lista de dependencias con versiones específicas | |
| dependencies = [ | |
| "gradio>=4.0.0,<4.50.0", | |
| "torch>=2.1.0,<3.0.0", | |
| "diffusers>=0.21.0,<0.25.0", | |
| "transformers>=4.25.0,<4.35.0", | |
| "accelerate>=0.20.0,<1.0.0", | |
| "Pillow>=9.0.0,<11.0.0", | |
| "numpy>=1.21.0,<2.0.0", | |
| "safetensors>=0.3.0,<1.0.0", | |
| "xformers>=0.0.20,<1.0.0" | |
| ] | |
| for dep in dependencies: | |
| print(f"📦 Instalando {dep}...") | |
| success, stdout, stderr = run_command(f"pip install {dep}") | |
| if success: | |
| print(f"✅ {dep} instalado correctamente") | |
| else: | |
| print(f"❌ Error instalando {dep}: {stderr}") | |
| print("\n🎉 Instalación completada!") | |
| def verify_installation(): | |
| """Verifica que todas las dependencias estén instaladas correctamente""" | |
| print("\n🔍 Verificando instalación...") | |
| try: | |
| import torch | |
| print(f"✅ PyTorch: {torch.__version__}") | |
| except ImportError: | |
| print("❌ PyTorch no está instalado") | |
| try: | |
| import diffusers | |
| print(f"✅ Diffusers: {diffusers.__version__}") | |
| except ImportError: | |
| print("❌ Diffusers no está instalado") | |
| try: | |
| import transformers | |
| print(f"✅ Transformers: {transformers.__version__}") | |
| except ImportError: | |
| print("❌ Transformers no está instalado") | |
| try: | |
| import accelerate | |
| print(f"✅ Accelerate: {accelerate.__version__}") | |
| except ImportError: | |
| print("❌ Accelerate no está instalado") | |
| try: | |
| import gradio | |
| print(f"✅ Gradio: {gradio.__version__}") | |
| except ImportError: | |
| print("❌ Gradio no está instalado") | |
| def main(): | |
| print("🚀 Script de instalación para Compatible AI Image Generator") | |
| print("=" * 60) | |
| # Instalar dependencias | |
| install_dependencies() | |
| # Verificar instalación | |
| verify_installation() | |
| print("\n📝 Para ejecutar la aplicación:") | |
| print("python app.py") | |
| print("\n📝 Para ejecutar en modo desarrollo:") | |
| print("python app.py --share") | |
| if __name__ == "__main__": | |
| main() |