Update utils/__init__.py
Browse files- utils/__init__.py +76 -67
utils/__init__.py
CHANGED
|
@@ -9,17 +9,21 @@
|
|
| 9 |
License: MIT
|
| 10 |
"""
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
|
|
|
|
|
|
|
| 14 |
DeviceManager,
|
| 15 |
get_device_manager,
|
| 16 |
get_optimal_device,
|
| 17 |
fix_cuda_compatibility,
|
| 18 |
setup_optimal_threading,
|
| 19 |
-
get_system_diagnostics
|
| 20 |
)
|
| 21 |
|
| 22 |
-
#
|
|
|
|
|
|
|
| 23 |
from .logger import (
|
| 24 |
BackgroundFXLogger,
|
| 25 |
setup_logging,
|
|
@@ -29,10 +33,12 @@
|
|
| 29 |
log_info,
|
| 30 |
log_error,
|
| 31 |
log_warning,
|
| 32 |
-
log_debug
|
| 33 |
)
|
| 34 |
|
| 35 |
-
#
|
|
|
|
|
|
|
| 36 |
from .config import (
|
| 37 |
ConfigManager,
|
| 38 |
ModelConfig,
|
|
@@ -44,13 +50,17 @@
|
|
| 44 |
get_model_config,
|
| 45 |
is_model_enabled,
|
| 46 |
get_quality_thresholds,
|
| 47 |
-
get_processing_config
|
| 48 |
)
|
| 49 |
|
| 50 |
-
#
|
|
|
|
|
|
|
| 51 |
from .monitoring.progress_tracker import ProgressTracker
|
| 52 |
|
| 53 |
-
#
|
|
|
|
|
|
|
| 54 |
from .utils import (
|
| 55 |
FileManager,
|
| 56 |
VideoUtils,
|
|
@@ -69,83 +79,82 @@
|
|
| 69 |
safe_division,
|
| 70 |
clamp,
|
| 71 |
interpolate,
|
| 72 |
-
moving_average
|
| 73 |
)
|
| 74 |
|
|
|
|
| 75 |
# Package metadata
|
|
|
|
| 76 |
__version__ = "1.0.0"
|
| 77 |
__author__ = "BackgroundFX Pro Team"
|
| 78 |
|
| 79 |
__all__ = [
|
| 80 |
# Device management
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
# Logging
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
# Configuration
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
# Monitoring
|
| 113 |
-
|
| 114 |
-
|
| 115 |
# Utilities
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
]
|
| 135 |
|
| 136 |
-
#
|
|
|
|
|
|
|
| 137 |
try:
|
| 138 |
-
# Setup logging with LOGS directory
|
| 139 |
_logger = setup_logging(logs_dir="LOGS")
|
| 140 |
_logger.info("✅ BackgroundFX Pro Utils package initialized")
|
| 141 |
-
|
| 142 |
-
# Initialize device manager
|
| 143 |
_device_manager = get_device_manager()
|
| 144 |
-
|
| 145 |
-
# Load configuration
|
| 146 |
_config = get_config(checkpoints_dir="checkpoints")
|
| 147 |
-
|
| 148 |
_logger.info("🚀 Utils package ready for BackgroundFX Pro")
|
| 149 |
-
|
| 150 |
except Exception as e:
|
| 151 |
print(f"⚠️ Utils package initialization warning: {e}")
|
|
|
|
| 9 |
License: MIT
|
| 10 |
"""
|
| 11 |
|
| 12 |
+
# -----------------------------------------------------------------------------
|
| 13 |
+
# Device management (moved under utils/hardware/)
|
| 14 |
+
# -----------------------------------------------------------------------------
|
| 15 |
+
from .hardware.device_manager import (
|
| 16 |
DeviceManager,
|
| 17 |
get_device_manager,
|
| 18 |
get_optimal_device,
|
| 19 |
fix_cuda_compatibility,
|
| 20 |
setup_optimal_threading,
|
| 21 |
+
get_system_diagnostics,
|
| 22 |
)
|
| 23 |
|
| 24 |
+
# -----------------------------------------------------------------------------
|
| 25 |
+
# Logging (still in utils/logger.py)
|
| 26 |
+
# -----------------------------------------------------------------------------
|
| 27 |
from .logger import (
|
| 28 |
BackgroundFXLogger,
|
| 29 |
setup_logging,
|
|
|
|
| 33 |
log_info,
|
| 34 |
log_error,
|
| 35 |
log_warning,
|
| 36 |
+
log_debug,
|
| 37 |
)
|
| 38 |
|
| 39 |
+
# -----------------------------------------------------------------------------
|
| 40 |
+
# Configuration (assuming utils/config.py exists)
|
| 41 |
+
# -----------------------------------------------------------------------------
|
| 42 |
from .config import (
|
| 43 |
ConfigManager,
|
| 44 |
ModelConfig,
|
|
|
|
| 50 |
get_model_config,
|
| 51 |
is_model_enabled,
|
| 52 |
get_quality_thresholds,
|
| 53 |
+
get_processing_config,
|
| 54 |
)
|
| 55 |
|
| 56 |
+
# -----------------------------------------------------------------------------
|
| 57 |
+
# Monitoring / Progress tracking (utils/monitoring/)
|
| 58 |
+
# -----------------------------------------------------------------------------
|
| 59 |
from .monitoring.progress_tracker import ProgressTracker
|
| 60 |
|
| 61 |
+
# -----------------------------------------------------------------------------
|
| 62 |
+
# Shared utilities (from your utilities file at utils/utils.py)
|
| 63 |
+
# -----------------------------------------------------------------------------
|
| 64 |
from .utils import (
|
| 65 |
FileManager,
|
| 66 |
VideoUtils,
|
|
|
|
| 79 |
safe_division,
|
| 80 |
clamp,
|
| 81 |
interpolate,
|
| 82 |
+
moving_average,
|
| 83 |
)
|
| 84 |
|
| 85 |
+
# -----------------------------------------------------------------------------
|
| 86 |
# Package metadata
|
| 87 |
+
# -----------------------------------------------------------------------------
|
| 88 |
__version__ = "1.0.0"
|
| 89 |
__author__ = "BackgroundFX Pro Team"
|
| 90 |
|
| 91 |
__all__ = [
|
| 92 |
# Device management
|
| 93 |
+
"DeviceManager",
|
| 94 |
+
"get_device_manager",
|
| 95 |
+
"get_optimal_device",
|
| 96 |
+
"fix_cuda_compatibility",
|
| 97 |
+
"setup_optimal_threading",
|
| 98 |
+
"get_system_diagnostics",
|
| 99 |
+
|
| 100 |
# Logging
|
| 101 |
+
"BackgroundFXLogger",
|
| 102 |
+
"setup_logging",
|
| 103 |
+
"get_logger",
|
| 104 |
+
"log_function_call",
|
| 105 |
+
"log_processing_pipeline",
|
| 106 |
+
"log_info",
|
| 107 |
+
"log_error",
|
| 108 |
+
"log_warning",
|
| 109 |
+
"log_debug",
|
| 110 |
+
|
| 111 |
# Configuration
|
| 112 |
+
"ConfigManager",
|
| 113 |
+
"ModelConfig",
|
| 114 |
+
"QualityConfig",
|
| 115 |
+
"ProcessingConfig",
|
| 116 |
+
"VideoConfig",
|
| 117 |
+
"get_config",
|
| 118 |
+
"load_config",
|
| 119 |
+
"get_model_config",
|
| 120 |
+
"is_model_enabled",
|
| 121 |
+
"get_quality_thresholds",
|
| 122 |
+
"get_processing_config",
|
| 123 |
+
|
| 124 |
# Monitoring
|
| 125 |
+
"ProgressTracker",
|
| 126 |
+
|
| 127 |
# Utilities
|
| 128 |
+
"FileManager",
|
| 129 |
+
"VideoUtils",
|
| 130 |
+
"ImageUtils",
|
| 131 |
+
"ValidationUtils",
|
| 132 |
+
"PerformanceUtils",
|
| 133 |
+
"temporary_directory",
|
| 134 |
+
"error_handler",
|
| 135 |
+
"retry_on_failure",
|
| 136 |
+
"batch_process",
|
| 137 |
+
"format_duration",
|
| 138 |
+
"get_system_info",
|
| 139 |
+
"ConfigurationError",
|
| 140 |
+
"ValidationError",
|
| 141 |
+
"ProcessingError",
|
| 142 |
+
"safe_division",
|
| 143 |
+
"clamp",
|
| 144 |
+
"interpolate",
|
| 145 |
+
"moving_average",
|
| 146 |
]
|
| 147 |
|
| 148 |
+
# -----------------------------------------------------------------------------
|
| 149 |
+
# Auto‐initialize logging, device manager, and config on import
|
| 150 |
+
# -----------------------------------------------------------------------------
|
| 151 |
try:
|
|
|
|
| 152 |
_logger = setup_logging(logs_dir="LOGS")
|
| 153 |
_logger.info("✅ BackgroundFX Pro Utils package initialized")
|
| 154 |
+
|
|
|
|
| 155 |
_device_manager = get_device_manager()
|
|
|
|
|
|
|
| 156 |
_config = get_config(checkpoints_dir="checkpoints")
|
| 157 |
+
|
| 158 |
_logger.info("🚀 Utils package ready for BackgroundFX Pro")
|
|
|
|
| 159 |
except Exception as e:
|
| 160 |
print(f"⚠️ Utils package initialization warning: {e}")
|