refactor: move hardcoded preprocessing values to config and add config loader#253
refactor: move hardcoded preprocessing values to config and add config loader#253Hasan-8326 wants to merge 1 commit into
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||
Udayraj123
left a comment
There was a problem hiding this comment.
there seem to abruptly high number of changes now. The need of a yaml file and parser seems like an extra step, we're fine with keeping the hardcodings in a single file for readability
Let me know once the PR is ready for review, mark as draft for now.
User description
This PR removes hardcoded preprocessing values and replaces them with a centralized configuration system.
✅ Summary of Changes
Introduced a YAML-based configuration file: config/default_config.yaml
Added a new config loader module: config/config_loader.py
Updated core processing modules to use config values instead of hardcoded constants:
src/constants/image_processing.py
src/defaults/config.py
src/processors/CropPage.py
src/processors/CropOnMarkers.py
Added safe fallbacks to ensure the system works even if config keys are missing
Improved flexibility by allowing configuration overrides without modifying code
🧠 Why This Change?
Previously, threshold values, kernel sizes, and other preprocessing parameters were hardcoded across the codebase, making it difficult to:
Tune OMR performance for different scanning qualities
Adjust thresholds for different sheet templates
Adapt the system for diverse lighting or contrast environments
This PR solves that by enabling external config-driven control, improving maintainability and user flexibility.
PR Type
Enhancement, Refactoring
Description
Introduced YAML-based configuration system with centralized config loader
Migrated hardcoded preprocessing values to external config file
Updated image processing modules to use config values with fallbacks
Simplified CropPage and CropOnMarkers classes to use config-driven parameters
Diagram Walkthrough
File Walkthrough
config_loader.py
New config loader module for YAML parsingconfig/config_loader.py
image_processing.py
Migrate constants to config-driven valuessrc/constants/image_processing.py
PAGE_THRESHOLD_PARAMS
with config fallbacks
default_config.yaml
New centralized YAML configuration fileconfig/default_config.yaml
config.py
Refactor defaults config with YAML integrationsrc/defaults/config.py
logging, and cli sections
CropOnMarkers.py
Refactor CropOnMarkers with config integrationsrc/processors/CropOnMarkers.py
ImagePreprocessor
parameters
settings
threshold computation
CropPage.py
Refactor CropPage with config-driven parameterssrc/processors/CropPage.py
ImagePreprocessor
parameters
contour validation