Define preprocessing pipelines using nested callable functions and parameter grids for them.
Project description
Auto-Preprocessing for Computer Vision
This Python module helps you automate the selection of the best preprocessing pipeline for your computer vision tasks. It uses a combination of parameter grid search, interactive visualization, and caching to efficiently find and apply optimal preprocessing steps to your images.
Features
- Define Multiple Pipelines: Create and store multiple preprocessing pipelines, each with different sequences of cv2 functions and a range of parameter values.
- Grid Search: The module performs an exhaustive grid search across all defined pipelines and parameter combinations.
- Interactive Visualization: A user-friendly image selector allows you to visually compare the results of different preprocessing steps and choose the best one.
- Caching: The module caches the results of the search process, so repeated runs with the same pipelines and image will be much faster.
- Preprocessor Construction: Once the best pipeline is selected, the module automatically constructs a
Preprocessorobject that you can use to apply the optimal preprocessing to new images.
Installation
-
Git Clone: Clone this repository into your working directory:
git clone https://github.com/Kalmy8/auto_preprocessing
-
Requirements: Make sure you have the required libraries installed:
pip install -r requirements.txt
Alternatively:
- Install as package using pip:
pip install prepCV
Usage
-
Define Pipelines: Create
PipelineDescriptionobjects to define your preprocessing pipelines.import cv2 from prepCV import PipelineDescription, PipelineManager pipeline1 = PipelineDescription({ cv2.cvtColor: {'code': [cv2.COLOR_BGR2GRAY]}, cv2.adaptiveThreshold: { 'maxValue': [255], 'adaptiveMethod': [cv2.ADAPTIVE_THRESH_MEAN_C], # ... other parameters ... }, # ... other cv2 functions ... }) pipeline2 = PipelineDescription({ # ... define another pipeline ... })
-
Add Pipelines to Manager:
pipeline_manage = PipelineManager() pipeline_manage.add_pipeline(pipeline1) pipeline_manage.add_pipeline(pipeline2)
-
Run Search:
# Load your image image = cv2.imread('your_image.jpg') # Run the search and select the best preprocessor pipeline_manage.run_search(image, 'GridSearch') # Get the best preprocessor best_preprocessor = pipeline_manage.get_best_preprocessor()
-
Save Search Results to cache:
from prepCV import CacheManager
# Restore previous search result
pipeline_manage = PipelineManager()
pipeline_manage.load_from_cache()
# Degine some new pipeline
pipeline3 = PipelineDescription({
# ... define another pipeline ...
})
# Add pipelines to PipelineManager
pipeline_manage.add_pipeline(pipeline1)
pipeline_manage.add_pipeline(pipeline2)
pipeline_manage.add_pipeline(pipeline3)
# This search will only compare new pipeline3 to previous best seen pipeline
pipeline_manage.run_search(image, 'GridSearch')
# Save results to cache
pipeline_manage.save_to_cache()
-
Use the Preprocessor:
processed_image = best_preprocessor.process(new_image) # Now you can use the `processed_image` for your tasks.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prepcv-2.1.0.tar.gz.
File metadata
- Download URL: prepcv-2.1.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20c2d6d4d4a6f9598865fddeb958371301a595c22eb9c8432dea294493b3ee7c
|
|
| MD5 |
557d979e1dee4e04a6717ab4b12905c0
|
|
| BLAKE2b-256 |
fe019fe3b869534572e90a3e83fa7afd97c4d69e65b400991c7219df0b70f35d
|
File details
Details for the file prepcv-2.1.0-py3-none-any.whl.
File metadata
- Download URL: prepcv-2.1.0-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d80752a80f8c0b44186a4043ef5926fa19cc6b1c6406d0c049856e37d32058f8
|
|
| MD5 |
7d2be44173c411f2b3570e4e6aff4d31
|
|
| BLAKE2b-256 |
7ca9246ace3a2a761bb8279b60546fad626638f5e7d2bd3575b87faadf672743
|