Update models/loaders/matanyone_loader.py
Browse files
models/loaders/matanyone_loader.py
CHANGED
|
@@ -50,10 +50,10 @@ def _select_device(self, pref: str) -> str:
|
|
| 50 |
return "cpu"
|
| 51 |
return "cuda" if torch.cuda.is_available() else "cpu"
|
| 52 |
|
| 53 |
-
def load(self) -
|
| 54 |
"""Load MatAnyone using official InferenceCore API."""
|
| 55 |
if self.loaded:
|
| 56 |
-
return True
|
| 57 |
|
| 58 |
logger.info(f"Loading MatAnyone from HF: {self.model_id} (device={self.device})")
|
| 59 |
t0 = time.time()
|
|
@@ -69,18 +69,18 @@ def load(self) -> bool:
|
|
| 69 |
self.loaded = True
|
| 70 |
self.load_time = time.time() - t0
|
| 71 |
logger.info(f"MatAnyone loaded successfully via InferenceCore API in {self.load_time:.2f}s")
|
| 72 |
-
return True
|
| 73 |
|
| 74 |
except ImportError as e:
|
| 75 |
self.load_error = f"MatAnyone not installed: {e}"
|
| 76 |
logger.error(f"Failed to import MatAnyone. Install with: pip install git+https://github.com/pq-yang/MatAnyone.git@main")
|
| 77 |
-
return
|
| 78 |
|
| 79 |
except Exception as e:
|
| 80 |
self.load_error = str(e)
|
| 81 |
logger.error(f"Failed to load MatAnyone: {e}")
|
| 82 |
logger.debug(traceback.format_exc())
|
| 83 |
-
return
|
| 84 |
|
| 85 |
def process_video(self, video_path: str, mask_path: str, output_dir: Optional[str] = None,
|
| 86 |
max_size: int = 720, save_frames: bool = False) -> Tuple[Optional[str], Optional[str]]:
|
|
|
|
| 50 |
return "cpu"
|
| 51 |
return "cuda" if torch.cuda.is_available() else "cpu"
|
| 52 |
|
| 53 |
+
def load(self): # <-- CHANGED: No return type hint, returns processor
|
| 54 |
"""Load MatAnyone using official InferenceCore API."""
|
| 55 |
if self.loaded:
|
| 56 |
+
return self.processor # <-- CHANGED: Return processor, not True
|
| 57 |
|
| 58 |
logger.info(f"Loading MatAnyone from HF: {self.model_id} (device={self.device})")
|
| 59 |
t0 = time.time()
|
|
|
|
| 69 |
self.loaded = True
|
| 70 |
self.load_time = time.time() - t0
|
| 71 |
logger.info(f"MatAnyone loaded successfully via InferenceCore API in {self.load_time:.2f}s")
|
| 72 |
+
return self.processor # <-- CHANGED: Return processor, not True
|
| 73 |
|
| 74 |
except ImportError as e:
|
| 75 |
self.load_error = f"MatAnyone not installed: {e}"
|
| 76 |
logger.error(f"Failed to import MatAnyone. Install with: pip install git+https://github.com/pq-yang/MatAnyone.git@main")
|
| 77 |
+
return None # <-- CHANGED: Return None on failure
|
| 78 |
|
| 79 |
except Exception as e:
|
| 80 |
self.load_error = str(e)
|
| 81 |
logger.error(f"Failed to load MatAnyone: {e}")
|
| 82 |
logger.debug(traceback.format_exc())
|
| 83 |
+
return None # <-- CHANGED: Return None on failure
|
| 84 |
|
| 85 |
def process_video(self, video_path: str, mask_path: str, output_dir: Optional[str] = None,
|
| 86 |
max_size: int = 720, save_frames: bool = False) -> Tuple[Optional[str], Optional[str]]:
|