Download faces/exceptions.py from Atomio/facerecog: direct link, hf CLI and curl.
- Browser
- Download file 2.96 kB
-
https://huggingface.co/spaces/Atomio/facerecog/resolve/main/faces/exceptions.py
- Command line
-
hf download hf://spaces/Atomio/facerecog/faces/exceptions.py
-
curl -L -o exceptions.py https://huggingface.co/spaces/Atomio/facerecog/resolve/main/faces/exceptions.py
2.96 kB
| """Face recognition domain exceptions.""" | |
| from typing import Any | |
| from exceptions import BadRequestError, NotFoundError, ValidationError | |
| class FaceNotDetectedError(ValidationError): | |
| """Exception raised when no face is detected in the image.""" | |
| def __init__( | |
| self, | |
| message: str = "No face detected in the image", | |
| details: dict[str, Any] | None = None, | |
| ) -> None: | |
| super().__init__(message=message, details=details) | |
| class MultipleFacesDetectedError(ValidationError): | |
| """Exception raised when multiple faces are detected in the image.""" | |
| def __init__( | |
| self, | |
| message: str = "Multiple faces detected in the image", | |
| details: dict[str, Any] | None = None, | |
| ) -> None: | |
| super().__init__(message=message, details=details) | |
| class InvalidImageFormatError(BadRequestError): | |
| """Exception raised when the image format is not supported.""" | |
| def __init__( | |
| self, | |
| message: str = "Invalid image format", | |
| details: dict[str, Any] | None = None, | |
| ) -> None: | |
| super().__init__(message=message, details=details) | |
| class InvalidVideoFormatError(BadRequestError): | |
| """Exception raised when the video format is not supported.""" | |
| def __init__( | |
| self, | |
| message: str = "Invalid video format", | |
| details: dict[str, Any] | None = None, | |
| ) -> None: | |
| super().__init__(message=message, details=details) | |
| class FileTooLargeError(BadRequestError): | |
| """Exception raised when the uploaded file is too large.""" | |
| def __init__( | |
| self, | |
| message: str = "File size exceeds maximum allowed size", | |
| details: dict[str, Any] | None = None, | |
| ) -> None: | |
| super().__init__(message=message, details=details) | |
| class FaceProcessingError(ValidationError): | |
| """Exception raised when face processing fails.""" | |
| def __init__( | |
| self, | |
| message: str = "Face processing failed", | |
| details: dict[str, Any] | None = None, | |
| ) -> None: | |
| super().__init__(message=message, details=details) | |
| class UserNotFoundError(NotFoundError): | |
| """Exception raised when a user is not found.""" | |
| def __init__( | |
| self, | |
| message: str = "User not found", | |
| details: dict[str, Any] | None = None, | |
| ) -> None: | |
| super().__init__(message=message, details=details) | |
| class FaceNotFoundError(NotFoundError): | |
| """Exception raised when a face is not found.""" | |
| def __init__( | |
| self, | |
| message: str = "Face not found", | |
| details: dict[str, Any] | None = None, | |
| ) -> None: | |
| super().__init__(message=message, details=details) | |
| class NoMatchFoundError(NotFoundError): | |
| """Exception raised when no matching face is found.""" | |
| def __init__( | |
| self, | |
| message: str = "No matching face found", | |
| details: dict[str, Any] | None = None, | |
| ) -> None: | |
| super().__init__(message=message, details=details) | |