MusicGen / app.py
OnyxMunk's picture
Upload app.py with huggingface_hub
8a29941 verified
#!/usr/bin/env python3
# Entry point for Hugging Face Space
# This file imports and runs the MusicGen Gradio app
import sys
import os
import logging
from pathlib import Path
# Set up logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Add the demos directory to the path
demos_path = Path(__file__).parent / "demos"
sys.path.insert(0, str(demos_path))
logger.info(f"Python path: {sys.path}")
logger.info(f"Demos path: {demos_path}")
logger.info(f"Demos path exists: {demos_path.exists()}")
# Import the musicgen app
try:
from musicgen_app import ui_full, ui_batched, IS_BATCHED
logger.info(f"Successfully imported musicgen_app. IS_BATCHED={IS_BATCHED}")
except Exception as e:
logger.error(f"Failed to import musicgen_app: {e}")
raise
# Default launch configuration for Hugging Face Spaces
launch_kwargs = {
'server_name': '0.0.0.0',
'server_port': 7860,
'share': False
}
logger.info(f"Launching with kwargs: {launch_kwargs}")
# Launch the appropriate UI
if IS_BATCHED:
logger.info("Launching batched UI")
ui_batched(launch_kwargs)
else:
logger.info("Launching full UI")
ui_full(launch_kwargs)