File size: 1,256 Bytes
df4a21a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | """
Custom exceptions and error handling for the application.
"""
from typing import Any, Dict, Optional
class DeepFakeDetectorError(Exception):
"""Base exception for DeepFake Detector application."""
def __init__(
self,
message: str,
details: Optional[Dict[str, Any]] = None
):
self.message = message
self.details = details or {}
super().__init__(self.message)
class ModelNotLoadedError(DeepFakeDetectorError):
"""Raised when attempting to use a model that hasn't been loaded."""
pass
class ModelNotFoundError(DeepFakeDetectorError):
"""Raised when a requested model is not found in the registry."""
pass
class HuggingFaceDownloadError(DeepFakeDetectorError):
"""Raised when downloading from Hugging Face fails."""
pass
class ImageProcessingError(DeepFakeDetectorError):
"""Raised when image processing/decoding fails."""
pass
class InferenceError(DeepFakeDetectorError):
"""Raised when model inference fails."""
pass
class FusionError(DeepFakeDetectorError):
"""Raised when fusion prediction fails."""
pass
class ConfigurationError(DeepFakeDetectorError):
"""Raised when configuration is invalid or missing."""
pass
|