Rename model_loader.py to models/loaders/model_loader.py
Browse files
model_loader.py → models/loaders/model_loader.py
RENAMED
|
@@ -22,10 +22,10 @@
|
|
| 22 |
import gradio as gr
|
| 23 |
from omegaconf import DictConfig, OmegaConf
|
| 24 |
|
| 25 |
-
# Import modular components
|
| 26 |
-
import
|
| 27 |
-
import
|
| 28 |
-
import
|
| 29 |
|
| 30 |
logger = logging.getLogger(__name__)
|
| 31 |
|
|
@@ -204,7 +204,7 @@ class ModelLoader:
|
|
| 204 |
Handles automatic config detection, multiple fallback strategies, and memory management
|
| 205 |
"""
|
| 206 |
|
| 207 |
-
def __init__(self, device_mgr:
|
| 208 |
self.device_manager = device_mgr
|
| 209 |
self.memory_manager = memory_mgr
|
| 210 |
self.device = self.device_manager.get_optimal_device()
|
|
@@ -288,7 +288,7 @@ def load_all_models(self, progress_callback: Optional[callable] = None, cancel_e
|
|
| 288 |
self.sam2_predictor = self._load_sam2_predictor(progress_callback)
|
| 289 |
|
| 290 |
if self.sam2_predictor is None:
|
| 291 |
-
raise
|
| 292 |
|
| 293 |
sam2_time = time.time() - start_time
|
| 294 |
self.loading_stats['sam2_load_time'] = sam2_time
|
|
@@ -304,7 +304,7 @@ def load_all_models(self, progress_callback: Optional[callable] = None, cancel_e
|
|
| 304 |
self.matanyone_model, self.matanyone_core = self._load_matanyone_model(progress_callback)
|
| 305 |
|
| 306 |
if self.matanyone_model is None:
|
| 307 |
-
raise
|
| 308 |
|
| 309 |
matanyone_time = time.time() - matanyone_start
|
| 310 |
self.loading_stats['matanyone_load_time'] = matanyone_time
|
|
|
|
| 22 |
import gradio as gr
|
| 23 |
from omegaconf import DictConfig, OmegaConf
|
| 24 |
|
| 25 |
+
# Import modular components - Updated paths for BackgroundFX Pro structure
|
| 26 |
+
from core.exceptions import ModelLoadingError # Updated import
|
| 27 |
+
from utils.hardware.device_manager import DeviceManager # Updated import
|
| 28 |
+
from utils.system.memory_manager import MemoryManager # Updated import
|
| 29 |
|
| 30 |
logger = logging.getLogger(__name__)
|
| 31 |
|
|
|
|
| 204 |
Handles automatic config detection, multiple fallback strategies, and memory management
|
| 205 |
"""
|
| 206 |
|
| 207 |
+
def __init__(self, device_mgr: DeviceManager, memory_mgr: MemoryManager):
|
| 208 |
self.device_manager = device_mgr
|
| 209 |
self.memory_manager = memory_mgr
|
| 210 |
self.device = self.device_manager.get_optimal_device()
|
|
|
|
| 288 |
self.sam2_predictor = self._load_sam2_predictor(progress_callback)
|
| 289 |
|
| 290 |
if self.sam2_predictor is None:
|
| 291 |
+
raise ModelLoadingError("SAM2", "Failed to load SAM2 predictor")
|
| 292 |
|
| 293 |
sam2_time = time.time() - start_time
|
| 294 |
self.loading_stats['sam2_load_time'] = sam2_time
|
|
|
|
| 304 |
self.matanyone_model, self.matanyone_core = self._load_matanyone_model(progress_callback)
|
| 305 |
|
| 306 |
if self.matanyone_model is None:
|
| 307 |
+
raise ModelLoadingError("MatAnyone", "Failed to load MatAnyone model")
|
| 308 |
|
| 309 |
matanyone_time = time.time() - matanyone_start
|
| 310 |
self.loading_stats['matanyone_load_time'] = matanyone_time
|