Albucore
Albucore is a high-performance Python library offering optimized atomic functions for image processing in deep learning and computer vision. It serves as a foundational component for the AlbumentationsX library, automatically selecting the fastest implementation for operations using backends like NumPy and OpenCV. Currently at version 0.1.5, the library is actively maintained with frequent updates and performance enhancements.
Warnings
- gotcha Albucore strictly expects images to follow specific shape conventions, always including a channel dimension. For grayscale images, this means a shape of (H, W, 1) (Height, Width, 1 Channel), not (H, W). For RGB, it's (H, W, C).
- gotcha Albucore functions primarily support `uint8` and `float32` dtypes for optimal performance. Using other dtypes may lead to errors or significantly degraded performance as the library might fall back to less optimized paths or raise exceptions.
Install
-
pip install albucore -
pip install albucore[headless] -
pip install albucore[gui] -
pip install albucore[contrib] -
pip install albucore[contrib-headless]
Imports
- multiply
from albucore import multiply
- all_functions
from albucore import *
Quickstart
import numpy as np
import albucore
# Create a sample RGB image (H, W, C) - uint8 is a supported dtype
image_rgb = np.random.randint(0, 256, (100, 100, 3), dtype=np.uint8)
# Create a sample grayscale image (H, W, 1) - explicit channel dimension is required
image_gray = np.random.randint(0, 256, (100, 100, 1), dtype=np.uint8)
# Apply a function, e.g., multiply by a constant
result_rgb = albucore.multiply(image_rgb, 1.5)
result_gray = albucore.add(image_gray, 50)
print(f"Original RGB shape: {image_rgb.shape}, dtype: {image_rgb.dtype}")
print(f"Result RGB shape: {result_rgb.shape}, dtype: {result_rgb.dtype}")
print(f"Original Grayscale shape: {image_gray.shape}, dtype: {image_gray.dtype}")
print(f"Result Grayscale shape: {result_gray.shape}, dtype: {result_gray.dtype}")