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.6.tar.gz (421.7 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.6-py3-none-manylinux1_x86_64.whl (515.9 kB view details)

Uploaded Python 3

File details

Details for the file libcom-0.1.6.tar.gz.

File metadata

  • Download URL: libcom-0.1.6.tar.gz
  • Upload date:
  • Size: 421.7 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.6.tar.gz
Algorithm Hash digest
SHA256 f7cb91a4b5513de356be47d5faebd6c4832da5980512cd820f5280f82b4a677b
MD5 82105d9c9861ae74729c9356af0f595f
BLAKE2b-256 5d4d53e7cad939d64b8dae42ad6506bb484e5a0cc372dc22337e9dc4d55e691c

See more details on using hashes here.

File details

Details for the file libcom-0.1.6-py3-none-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for libcom-0.1.6-py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c2d10c1150198ff4fd8dfd9114876ad106f16e1938b82b3e45742a160ec2ac1e
MD5 3c05ad23941fabbe1ddd1255c34d96dd
BLAKE2b-256 8f39e80e08bfc55afbb4c955286cc4b0879348ff7bea8db4ab7eb97860bf3fa7

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