Abstract
Many people search for foreground objects to use when editing images. While existing methods can retrieve candidates to aid in this, they are constrained to returning objects that belong to a pre-specified semantic class. We instead propose a novel problem of unconstrained foreground object (UFO) search and introduce a solution that supports efficient search by encoding the background image in the same latent space as the candidate foreground objects. A key contribution of our work is a cost-free, scalable approach for creating a large-scale training dataset with a variety of foreground objects of differing semantic categories per image location. Quantitative and human-perception experiments with two diverse datasets demonstrate the advantage of our UFO search solution over related baselines.
Introduction
In modern image editing, users frequently seek to add new elements to a scene or fill gaps left by object removal. Traditional image retrieval tools are inherently constrained, requiring the user to specify a target category (e.g., "find a chair"). However, users often lack a specific object in mind or wish to explore creative possibilities that fit the scene's context.
We introduce the problem of Unconstrained Foreground Object (UFO) search. The goal is to retrieve objects that are semantically compatible with a given background without requiring pre-specified labels. This task is challenging because compatibility is subjective and context-dependent. Furthermore, creating a large-scale dataset of "what fits where" is traditionally labor-intensive and expensive.
The UFO Search Framework
To enable efficient and semantically aware retrieval, we propose a dual-encoder architecture that maps backgrounds and foreground objects into a shared latent space.
The system utilizes two VGG-19 based encoders. The background encoder processes an image with a designated "hole," while the foreground encoder processes candidate objects. By training these encoders to project compatible pairs into nearby regions of the latent space, we can perform retrieval using an efficient nearest-neighbor search (e.g., via Faiss). This "decoupled" approach allows for sub-0.1 second search times across tens of thousands of objects, representing a 3000x speedup over "coupled" methods that must evaluate every object-background combination individually.
Scalable Training Data Generation
A primary contribution of this work is a cost-free pipeline for generating training data. Since no large-scale dataset for unconstrained compatibility existed, we developed a "teacher" discriminator to automate the process.
The discriminator is trained to determine if an object "looks right" when overlaid on a background. We then use this discriminator to scan millions of potential pairs, identifying "noisy" but effective positive and negative samples. These samples are used to train the main encoders via a triplet loss function, which minimizes the distance between backgrounds and compatible objects while maximizing the distance from incompatible ones. To accelerate this process, we employ heuristics—such as sampling objects from similar scenes—resulting in a 20x speedup in data generation.
Experimental Results
We evaluated UFO Search on two diverse datasets: CAIS (focused on compositing) and MS-COCO (re-purposed for unconstrained variety).
- Semantic Accuracy: On the CAIS dataset, UFO Search achieved a mean Average Precision (mAP) of 32.17%, significantly outperforming baselines like RealismCNN (7.14%) and shape-based retrieval (7.82%).
- Human Perception: In user studies using MS-COCO, the top 5 results returned by our system were deemed compatible by humans 41.83% of the time, surpassing all ablated versions of the model.
- Diversity of Results: Unlike constrained search, UFO Search provides a diverse range of suggestions. For a table background, the system might suggest cakes, fruit, or beverages, demonstrating its ability to capture semantic "vibes" rather than just low-level pixel matches.
Conclusion and Future Work
UFO Search represents a significant step toward more intuitive and creative image editing tools. By focusing on semantic compatibility and leveraging a shared latent space, we achieve high-speed, unconstrained retrieval.
However, the current model has limitations regarding spatial awareness. It may suggest semantically relevant objects (like a chair for a dining room) but place them in physically implausible locations (like on top of a table). Future work will focus on integrating 3D spatial relationships to ensure that retrieved objects are not only semantically appropriate but also physically plausible within the scene's geometry.
Summary updated