Install & Compatibility
Where this runs
tested against v0.0.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
build_error
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 11.0s · import 3.647s · 427MB
438MB installed
● package 438MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
DomainAdapter
✓ from qudida import DomainAdapter
This quickstart demonstrates how to use `qudida.DomainAdapter` to perform pixel-level domain adaptation. It initializes the adapter with a `scikit-learn` transformer (e.g., `PCA`) and a reference (target) image. It then applies the adaptation to a source image, returning the adapted image. Ensure `opencv-python-headless` and `scikit-learn` are installed as dependencies. The example includes creating dummy images to ensure the code is runnable without external files.
import cv2
from sklearn.decomposition import PCA
from qudida import DomainAdapter
import os
# Create dummy image files for demonstration if they don't exist
# In a real scenario, these would be your source and target images.
if not os.path.exists('source.png'):
dummy_img = (255 * (0.5 + 0.5 * (1 + 0.2 * (0.5 - 0.5 * (0.5 * (2 * 0.5 - 1) + 0.5)) + 0.5))) * 255
cv2.imwrite('source.png', dummy_img.astype('uint8'))
if not os.path.exists('target.png'):
dummy_img_target = (255 * (0.5 + 0.5 * (1 + 0.2 * (0.5 - 0.5 * (0.5 * (2 * 0.5 - 1) + 0.5)) + 0.5))) * 255
cv2.imwrite('target.png', dummy_img_target.astype('uint8'))
# Initialize the DomainAdapter with a scikit-learn transformer and a reference (target) image
# For simplicity, using a dummy image if actual images are not present
ref_img_path = 'target.png'
source_img_path = 'source.png'
# Ensure dummy images exist for the quickstart to run
if not os.path.exists(ref_img_path) or not os.path.exists(source_img_path):
# If dummy images were not created above (e.g., due to a previous run or error),
# create them directly here for robustness.
import numpy as np
dummy_source = np.full((100, 100, 3), [100, 50, 200], dtype=np.uint8) # BGR blue-ish
dummy_target = np.full((100, 100, 3), [50, 200, 100], dtype=np.uint8) # BGR green-ish
cv2.imwrite(source_img_path, dummy_source)
cv2.imwrite(ref_img_path, dummy_target)
adapter = DomainAdapter(transformer=PCA(n_components=3), ref_img=cv2.imread(ref_img_path))
# Load the source image
source = cv2.imread(source_img_path)
# Apply domain adaptation
result = adapter(source)
# Save the result (optional, for verification)
# cv2.imwrite('result_adapted.png', result)
print("Domain adaptation applied successfully. Result image shape:", result.shape)
# Clean up dummy files
os.remove(source_img_path)
os.remove(ref_img_path)
Upgrade
Version history
0.0.4latest on PyPI · released Aug 9, 2021
Audit
Dependencies
numpyrequiredNumerical operations, core dependency for image and array manipulation.
opencv-python-headlessrequiredImage loading, saving, and processing operations.
scikit-learnrequiredProvides the transformer interface for domain adaptation methods.
typing-extensionsrequiredType hinting support.