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 1 |
"""
|
| 2 |
+
Utils Package for BackgroundFX Pro
|
| 3 |
+
=================================
|
| 4 |
+
|
| 5 |
+
This package provides utility modules for device management, logging,
|
| 6 |
+
configuration, and shared utilities.
|
| 7 |
+
|
| 8 |
+
Author: BackgroundFX Pro Team
|
| 9 |
+
License: MIT
|
| 10 |
"""
|
| 11 |
|
| 12 |
+
# Import your existing utilities first
|
| 13 |
from .utilities import *
|
| 14 |
|
| 15 |
+
# Import new utility modules
|
| 16 |
+
from .device import (
|
| 17 |
+
DeviceManager,
|
| 18 |
+
get_device_manager,
|
| 19 |
+
get_optimal_device,
|
| 20 |
+
fix_cuda_compatibility,
|
| 21 |
+
setup_optimal_threading,
|
| 22 |
+
get_system_diagnostics
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
from .logger import (
|
| 26 |
+
BackgroundFXLogger,
|
| 27 |
+
setup_logging,
|
| 28 |
+
get_logger,
|
| 29 |
+
log_function_call,
|
| 30 |
+
log_processing_pipeline,
|
| 31 |
+
log_info,
|
| 32 |
+
log_error,
|
| 33 |
+
log_warning,
|
| 34 |
+
log_debug
|
| 35 |
+
)
|
| 36 |
+
|
| 37 |
+
from .config import (
|
| 38 |
+
ConfigManager,
|
| 39 |
+
ModelConfig,
|
| 40 |
+
QualityConfig,
|
| 41 |
+
ProcessingConfig,
|
| 42 |
+
VideoConfig,
|
| 43 |
+
get_config,
|
| 44 |
+
load_config,
|
| 45 |
+
get_model_config,
|
| 46 |
+
is_model_enabled,
|
| 47 |
+
get_quality_thresholds,
|
| 48 |
+
get_processing_config
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
from .utils import (
|
| 52 |
+
ProgressTracker,
|
| 53 |
+
FileManager,
|
| 54 |
+
VideoUtils,
|
| 55 |
+
ImageUtils,
|
| 56 |
+
ValidationUtils,
|
| 57 |
+
PerformanceUtils,
|
| 58 |
+
temporary_directory,
|
| 59 |
+
error_handler,
|
| 60 |
+
retry_on_failure,
|
| 61 |
+
batch_process,
|
| 62 |
+
format_duration,
|
| 63 |
+
get_system_info,
|
| 64 |
+
ConfigurationError,
|
| 65 |
+
ValidationError,
|
| 66 |
+
ProcessingError,
|
| 67 |
+
safe_division,
|
| 68 |
+
clamp,
|
| 69 |
+
interpolate,
|
| 70 |
+
moving_average
|
| 71 |
+
)
|
| 72 |
+
|
| 73 |
+
# Package metadata
|
| 74 |
+
__version__ = "1.0.0"
|
| 75 |
+
__author__ = "BackgroundFX Pro Team"
|
| 76 |
+
__all__ = [
|
| 77 |
+
# Device management
|
| 78 |
+
'DeviceManager',
|
| 79 |
+
'get_device_manager',
|
| 80 |
+
'get_optimal_device',
|
| 81 |
+
'fix_cuda_compatibility',
|
| 82 |
+
'setup_optimal_threading',
|
| 83 |
+
'get_system_diagnostics',
|
| 84 |
+
|
| 85 |
+
# Logging
|
| 86 |
+
'BackgroundFXLogger',
|
| 87 |
+
'setup_logging',
|
| 88 |
+
'get_logger',
|
| 89 |
+
'log_function_call',
|
| 90 |
+
'log_processing_pipeline',
|
| 91 |
+
'log_info',
|
| 92 |
+
'log_error',
|
| 93 |
+
'log_warning',
|
| 94 |
+
'log_debug',
|
| 95 |
+
|
| 96 |
+
# Configuration
|
| 97 |
+
'ConfigManager',
|
| 98 |
+
'ModelConfig',
|
| 99 |
+
'QualityConfig',
|
| 100 |
+
'ProcessingConfig',
|
| 101 |
+
'VideoConfig',
|
| 102 |
+
'get_config',
|
| 103 |
+
'load_config',
|
| 104 |
+
'get_model_config',
|
| 105 |
+
'is_model_enabled',
|
| 106 |
+
'get_quality_thresholds',
|
| 107 |
+
'get_processing_config',
|
| 108 |
+
|
| 109 |
+
# Utilities
|
| 110 |
+
'ProgressTracker',
|
| 111 |
+
'FileManager',
|
| 112 |
+
'VideoUtils',
|
| 113 |
+
'ImageUtils',
|
| 114 |
+
'ValidationUtils',
|
| 115 |
+
'PerformanceUtils',
|
| 116 |
+
'temporary_directory',
|
| 117 |
+
'error_handler',
|
| 118 |
+
'retry_on_failure',
|
| 119 |
+
'batch_process',
|
| 120 |
+
'format_duration',
|
| 121 |
+
'get_system_info',
|
| 122 |
+
'ConfigurationError',
|
| 123 |
+
'ValidationError',
|
| 124 |
+
'ProcessingError',
|
| 125 |
+
'safe_division',
|
| 126 |
+
'clamp',
|
| 127 |
+
'interpolate',
|
| 128 |
+
'moving_average'
|
| 129 |
+
]
|
| 130 |
+
|
| 131 |
+
# Initialize logging and device management on import
|
| 132 |
+
try:
|
| 133 |
+
# Setup logging with LOGS directory
|
| 134 |
+
_logger = setup_logging(logs_dir="LOGS")
|
| 135 |
+
_logger.info("✅ BackgroundFX Pro Utils package initialized")
|
| 136 |
+
|
| 137 |
+
# Initialize device manager
|
| 138 |
+
_device_manager = get_device_manager()
|
| 139 |
+
|
| 140 |
+
# Load configuration
|
| 141 |
+
_config = get_config(checkpoints_dir="checkpoints")
|
| 142 |
+
|
| 143 |
+
_logger.info("🚀 Utils package ready for BackgroundFX Pro")
|
| 144 |
+
|
| 145 |
+
except Exception as e:
|
| 146 |
+
print(f"⚠️ Utils package initialization warning: {e}")
|