Skip to main content

Image Composition Toolbox

Project description


libcom: everything about image composition


PyPI Downloads Hits Static Badge Static Badge Static Badge Static Badge


Introduction

libcom (the library of image composition) is an image composition toolbox. The goal of image composition (object insertion) is inserting one foreground into a background image to get a realistic composite image, by addressing the inconsistencies (appearance, geometry, and semantic inconsistency) between foreground and background. Generally speaking, image composition could be used to combine the visual elements from different images.


libcom covers a diversity of related tasks in the field of image composition, including image blending, standard/painterly image harmonization, shadow generation, reflection generation, object placement, generative composition, quality evaluation, etc. For each task, we integrate one or two selected methods considering both efficiency and effectiveness. The selected methods will be continuously updated upon the emergence of better methods.

The ultimate goal of this library is solving all the problems related to image composition with simple import libcom. Welcome to follow WeChat public account "Newly AIGCer" or Zhihu Column "Newly CVer" to get the latest information about image composition!

We compare the performance of Libcom and Banana Pro across various image composition tasks and write a brief summary in English/Chinese.

Online Workbench

We have built the image composition workbench based on our Libcom toolbox. The interface is as follows:


![]

Main Functions

  • get_composite_image generates composite images using naive copy-and-paste followed by image blending.
  • OPAScoreModel [OPA] evaluates the rationality of foreground object placement in a composite image.
  • FOPAHeatMapModel [FOPA] can predict the rationality scores for all locations/scales given a background-foreground pair, and output the composite image with optimal location/scale.
  • color_transfer adjusts the foreground color to match the background using traditional color transfer method.
  • ImageHarmonizationModel [PCTNet] [LBM] adjusts the foreground illumination to be compatible the background given photorealistic background and photorealistic foreground.
  • PainterlyHarmonizationModel [PHDNet] [PHDiffusion] adjusts the foreground style to be compatible with the background given artistic background and photorealistic foreground.
  • HarmonyScoreModel [BargainNet] evaluates the harmony level between foreground and background in a composite image.
  • InharmoniousLocalizationModel [MadisNet] localizes the inharmonious region in a synthetic image.
  • FOSScoreModel [DiscoFOS] evaluates the compatibility between foreground and background in a composite image in terms of geometry and semantics.
  • ShadowGenerationModel [GPSDiffusion] generates plausible shadow for the inserted object in a composite image.
  • ReflectionGenerationModel [RGDiffusion] generates plausible reflection for the inserted object in a composite image.
  • KontextBlendingHarmonizationModel [FluxKontext] is a generative image composition model which inserts foreground into the specified bounding box in the background. The pose and view of foreground stay unchanged. The "blending" mode does not adjust the foreground illumination, while the "harmonization" mode adjusts the foreground illumination to make the composite image harmonious.
  • OSInsertModel [OSInsert] is a generative image composition model which inserts foreground into the specified bounding box in the background. The "conservative" mode has weak ability to adjust the pose and view of foreground according to the background. The "aggressive" mode has stronger ability to adjust the pose and view of foreground according to the background.

For the detailed method descriptions, code examples, visualization results, and performance comments, please refer to our [documents]. If the model performance is not satisfactory, you can finetune the pretrained model on your own dataset using the source repository and replace the original model.

Requirements

The main branch is built on the Linux system with Python 3.10 and PyTorch>=2.6. For other dependencies, please refer to [requirements].

Get Started

Please refer to [Installation] for installation instructions and [documents] for user guidance.

Contributors

License

This project is released under the Apache 2.0 license.

Bibtex

If you use our toolbox, please cite our survey paper using the following BibTeX [arxiv]:

@article{niu2021making,
  title={Making images real again: A comprehensive survey on deep image composition},
  author={Niu, Li and Cong, Wenyan and Liu, Liu and Hong, Yan and Zhang, Bo and Liang, Jing and Zhang, Liqing},
  journal={arXiv preprint arXiv:2106.14490},
  year={2021}
}

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

libcom-0.1.5.post1.tar.gz (421.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

libcom-0.1.5.post1-py3-none-manylinux1_x86_64.whl (516.0 kB view details)

Uploaded Python 3

File details

Details for the file libcom-0.1.5.post1.tar.gz.

File metadata

  • Download URL: libcom-0.1.5.post1.tar.gz
  • Upload date:
  • Size: 421.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.20

File hashes

Hashes for libcom-0.1.5.post1.tar.gz
Algorithm Hash digest
SHA256 57abd5bf1b63ccf45c15e09960a6e009ac77802130f2d1a37f437318b60e8572
MD5 28b1368fa2e281191b48710f28a3d9e1
BLAKE2b-256 cb72c63c7d1591bd800083aae8d0cb8bcbf50eeade7c7e4d249e68944d705a88

See more details on using hashes here.

File details

Details for the file libcom-0.1.5.post1-py3-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for libcom-0.1.5.post1-py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7c5ff9520e1ffb0b25a92464d5abddeaa78e177b8dac1e008fd0a8e4fc6d52b0
MD5 9642ca2971392ee8a20b8ebe57fc2ce2
BLAKE2b-256 1b3a00050675cb17ecc6575150a107b0d51c39bb5ba1d85e3a14308d8895d753

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page