Image Harmonization¶
Image harmonization aims to adjust the foreground illumination and color in a composite image so that it is consistent with the background.
ImageHarmonizationModel now supports two backends:
PCTNet: fast pixel-wise color transformation, suitable for most regular harmonization tasks.
LBM: diffusion-based harmonization backend with controllable inference steps and resolution.
PCTNet:
Brief Method Summary¶

PCTNet takes in a downsampled image and outputs spatial-aware color transformation parameters, which are interpolated and applied to the foreground region of full-resolution composite image.
API¶
from libcom.image_harmonization import ImageHarmonizationModel
model = ImageHarmonizationModel(device=0, model_type='PCTNet')
result = model(composite_image, composite_mask)
Supported model_type¶
PCTNetLBM
LBM-specific inference kwargs¶
When model_type='LBM', you can pass extra parameters in __call__:
steps(int, default:4): diffusion sampling steps.resolution(int, default:1024): square inference size before resizing result back to original image size.
Example:
from libcom.image_harmonization import ImageHarmonizationModel
model = ImageHarmonizationModel(model_type='LBM')
result = model(composite_image, composite_mask, steps=4, resolution=1024)
Input / Output¶
Input
composite_image:strpath ornumpy.ndarray(BGR image).composite_mask:strpath ornumpy.ndarraymask indicating foreground region.
Output
Harmonized image in
numpy.ndarray(BGR format).