mimo-1.0 / app.py
minhho's picture
Clean deployment: All fixes without binary files
6f2c7f0
#!/usr/bin/env python3
"""
MIMO - HuggingFace Spaces Entry Point
Clean version with all dependencies pre-installed during build
"""
# CRITICAL: Import spaces FIRST before any CUDA initialization
# This must be the very first import to avoid CUDA initialization conflicts
try:
import spaces
HAS_SPACES = True
print("βœ… HF Spaces GPU support available")
except ImportError:
HAS_SPACES = False
print("⚠️ spaces package not available")
import os
import sys
import gradio as gr
print("πŸš€ MIMO HuggingFace Spaces starting...")
print(f"πŸ“ Python: {sys.version}")
print(f"πŸ“‚ Working dir: {os.getcwd()}")
# Import the complete MIMO implementation
try:
from app_hf_spaces import CompleteMIMO, gradio_interface
print("βœ… Successfully imported MIMO modules")
except ImportError as e:
print(f"❌ Import error: {e}")
import traceback
traceback.print_exc()
raise
# HuggingFace Spaces GPU decorator
if HAS_SPACES:
@spaces.GPU(duration=120)
def warmup():
"""GPU warmup for HF Spaces detection"""
import torch
if torch.cuda.is_available():
x = torch.randn(1, device='cuda')
return f"GPU: {torch.cuda.get_device_name()}"
return "CPU mode"
else:
warmup = lambda: "CPU mode"
# Launch the Gradio interface
if __name__ == "__main__":
print("🎬 Creating MIMO interface...")
# Create the interface
demo = gradio_interface()
print("🌐 Launching web server...")
demo.queue(max_size=20)
demo.launch(
server_name="0.0.0.0",
server_port=7860,
share=False,
show_error=True
)