abhaypratapsingh111 commited on
Commit
0a9ce4b
·
verified ·
1 Parent(s): 87d7b49

Optimize for HuggingFace Spaces deployment

Browse files
Files changed (1) hide show
  1. config/settings.py +5 -3
config/settings.py CHANGED
@@ -39,8 +39,10 @@ DATABRICKS_CONFIG = {
39
  # Select configuration based on environment
40
  CONFIG = DATABRICKS_CONFIG if IS_DATABRICKS else LOCAL_CONFIG
41
 
42
- # Device configuration - defaults to CUDA with automatic CPU fallback
43
- DEVICE = os.environ.get('DEVICE', 'cuda') # 'cuda' (with CPU fallback), 'cpu', or 'auto'
 
 
44
 
45
  # Logging configuration
46
  LOG_LEVEL = os.environ.get('LOG_LEVEL', 'INFO' if not CONFIG['debug'] else 'DEBUG')
@@ -59,7 +61,7 @@ def setup_directories():
59
 
60
  # Model configuration
61
  MODEL_CONFIG = {
62
- 'warmup_enabled': True,
63
  'warmup_length': 100,
64
  'warmup_horizon': 10,
65
  'cache_enabled': True,
 
39
  # Select configuration based on environment
40
  CONFIG = DATABRICKS_CONFIG if IS_DATABRICKS else LOCAL_CONFIG
41
 
42
+ # Device configuration - defaults to CPU for HuggingFace Spaces, CUDA for others
43
+ IS_HUGGINGFACE_SPACE = os.environ.get('SPACE_ID') is not None
44
+ default_device = 'cpu' if IS_HUGGINGFACE_SPACE else 'cuda'
45
+ DEVICE = os.environ.get('DEVICE', default_device) # 'cuda' (with CPU fallback), 'cpu', or 'auto'
46
 
47
  # Logging configuration
48
  LOG_LEVEL = os.environ.get('LOG_LEVEL', 'INFO' if not CONFIG['debug'] else 'DEBUG')
 
61
 
62
  # Model configuration
63
  MODEL_CONFIG = {
64
+ 'warmup_enabled': os.environ.get('MODEL_WARMUP', 'true').lower() == 'true',
65
  'warmup_length': 100,
66
  'warmup_horizon': 10,
67
  'cache_enabled': True,