Albucore

raw JSON →
0.1.5 verified Fri Apr 24 auth: no python

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.

pip install albucore
error ModuleNotFoundError: No module named 'albucore'
cause The 'albucore' library is not installed in the Python environment.
fix
Install the library using pip: 'pip install albucore'.
error ImportError: cannot import name 'multiply' from 'albucore'
cause The 'multiply' function is not available in the 'albucore' module, possibly due to an outdated version.
fix
Ensure you have the latest version of 'albucore' installed: 'pip install --upgrade albucore'.
error TypeError: multiply() missing 1 required positional argument: 'factor'
cause The 'multiply' function was called without the required 'factor' argument.
fix
Provide the 'factor' argument when calling 'multiply': 'result = albucore.multiply(image, factor)'.
error ValueError: Input image must have 3 dimensions (H, W, C)
cause The input image does not have the required shape with three dimensions (Height, Width, Channels).
fix
Ensure the input image has the shape (H, W, C), adding a channel dimension if necessary: 'image = np.expand_dims(image, axis=-1)'.
error AttributeError: module 'albucore' has no attribute 'rotate'
cause The 'rotate' function is not implemented in the 'albucore' library.
fix
Use an alternative function or library for rotation, such as OpenCV's 'cv2.rotate'.
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).
fix Always reshape grayscale images to `(H, W, 1)` using `np.expand_dims(image, axis=-1)` or ensure they are created with this shape. For batches, ensure shapes like `(N, 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.
fix Ensure input images are converted to `np.uint8` or `np.float32` before passing them to Albucore functions. For float images, normalize pixel values to the expected range (e.g., [0, 1] or [0, 255]) as appropriate for the operation.
pip install albucore[headless]
pip install albucore[gui]
pip install albucore[contrib]
pip install albucore[contrib-headless]
runtime variant status import time mem disk
3.10-alpine default
3.10-alpine contrib-headless
3.10-alpine contrib
3.10-alpine gui
3.10-alpine headless
3.10-slim default
3.10-slim contrib-headless 0.37s 12.2MB 307M
3.10-slim contrib
3.10-slim gui
3.10-slim headless 0.33s 11.2MB 294M
3.11-alpine default
3.11-alpine contrib-headless
3.11-alpine contrib
3.11-alpine gui
3.11-alpine headless
3.11-slim default
3.11-slim contrib-headless 0.46s 13.1MB 314M
3.11-slim contrib
3.11-slim gui
3.11-slim headless 0.48s 12.2MB 301M
3.12-alpine default
3.12-alpine contrib-headless
3.12-alpine contrib
3.12-alpine gui
3.12-alpine headless
3.12-slim default
3.12-slim contrib-headless 0.53s 12.8MB 302M
3.12-slim contrib
3.12-slim gui
3.12-slim headless 0.56s 11.9MB 289M
3.13-alpine default
3.13-alpine contrib-headless
3.13-alpine contrib
3.13-alpine gui
3.13-alpine headless
3.13-slim default
3.13-slim contrib-headless 0.45s 13.2MB 302M
3.13-slim contrib
3.13-slim gui
3.13-slim headless 0.56s 11.8MB 289M
3.9-alpine default
3.9-alpine contrib-headless
3.9-alpine contrib
3.9-alpine gui
3.9-alpine headless
3.9-slim default 0.40s 11.3MB 263M
3.9-slim contrib-headless 0.39s 11.3MB 263M
3.9-slim contrib 0.30s 11.3MB 263M
3.9-slim gui 0.31s 11.3MB 263M
3.9-slim headless 0.35s 11.3MB 263M

This quickstart demonstrates how to import and use a basic image processing function (`multiply` and `add`) from Albucore. It highlights the crucial image shape convention by providing examples for both RGB and grayscale images, ensuring the channel dimension is always present.

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}")