File size: 1,181 Bytes
8a29941
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/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)