diff --git a/commonforms/config.py b/commonforms/config.py index 59b406d..6df71f4 100644 --- a/commonforms/config.py +++ b/commonforms/config.py @@ -65,3 +65,4 @@ # Minimum valid image size IMAGE_SIZE_MIN: int = 32 +IMAGE_SIZE_MAX: int = 4096 diff --git a/commonforms/exceptions.py b/commonforms/exceptions.py index 77fabc0..8df1b27 100644 --- a/commonforms/exceptions.py +++ b/commonforms/exceptions.py @@ -66,5 +66,5 @@ class InvalidImageSizeError(InvalidInputError): def __init__(self, image_size: int): self.image_size = image_size - self.message = f"Image size must be a positive integer, got: {image_size}" + self.message = f"Image size must be between 32 and 4096, got: {image_size}" super().__init__(self.message) diff --git a/commonforms/inference.py b/commonforms/inference.py index 527925f..6a19bfb 100644 --- a/commonforms/inference.py +++ b/commonforms/inference.py @@ -22,6 +22,7 @@ CONFIDENCE_MIN, CONFIDENCE_MAX, IMAGE_SIZE_MIN, + IMAGE_SIZE_MAX, ) import formalpdf @@ -257,7 +258,7 @@ def _validate_inputs( raise InvalidConfidenceError(confidence) # Validate image size - if image_size < IMAGE_SIZE_MIN: + if not (IMAGE_SIZE_MIN <= image_size <= IMAGE_SIZE_MAX): raise InvalidImageSizeError(image_size) diff --git a/dataset/split_dataset.py b/dataset/split_dataset.py index 5ceaed0..90bec92 100755 --- a/dataset/split_dataset.py +++ b/dataset/split_dataset.py @@ -74,7 +74,7 @@ def main(): json_dir = coco_dir / 'json' if not images_dir.exists() or not json_dir.exists(): - print(f"Error: Directory must contain 'images' and 'json' subdirectories") + print("Error: Directory must contain 'images' and 'json' subdirectories") return 1 # Read CSV files