How can I replace an object using a reference image while preserving its exact design?

How can I replace an object using a reference image while preserving its exact design and identity?

Hi everyone,

I’m working on an image generation problem and would appreciate some advice on the best approach.

I have three inputs:

  1. A source image — for example, a bedroom containing an existing bed.

  2. A mask — identifying the area of the bed that I want to replace.

  3. A reference image — containing a different target bed that I want to generate in the masked area.

My goal is to generate an output where the room and background remain unchanged, but the existing bed is replaced with the bed from the reference image.

The important part is that I don’t just want a bed with a similar style. I want the generated bed to preserve the actual design, structure, and identity of the reference bed as closely as possible.

The source image and reference image may also be taken from different camera angles. Ideally, the model should understand the target object from the reference and generate that same object naturally from the perspective required by the source image.

So the workflow is basically:

Source room image + object mask + reference image of target object → same room with the target object generated inside the masked area

I’ve experimented with SDXL inpainting, ControlNet, IP-Adapter, and a few other approaches/models, but the results haven’t been good enough. The model usually generates an object that looks somewhat similar to the reference, but it doesn’t reliably preserve the exact structure and design.

For example, with a bed, it may preserve the general color or style, but change the shape of the headboard, legs, proportions, or other important design details.

I’m looking for an open-source approach that can handle:

  • Object replacement using a mask

  • Strong preservation of the reference object’s identity/design

  • Different camera angles between the source and reference images

  • Natural perspective, lighting, and integration with the original scene

Has anyone worked on a similar problem?

Are there any models, techniques, or workflows you would recommend for preserving the identity of an object from a reference image while generating it from a different viewpoint?

I’ve been looking into approaches such as reference-based generation, image conditioning, IP-Adapter, LoRA/DreamBooth, Flux, and other image editing models, but I’m still trying to find the best direction.

I can also share the source image, mask, reference image, and my current generated result in the comments if that helps.

Thanks!

Hmm… I think this is one of those areas where there isn’t really a single definitive “this is the solution” answer:


Yes — there are methods much closer to what you want than ordinary inpainting, but I would separate the problem into a few controls rather than look for one stronger reference adapter.

The closest research terms are things like reference-based object insertion, identity-preserving object composition, and localized subject-driven editing. The difficult combination in your case is:

  • replace only a specified object/region,
  • preserve the actual product identity, not merely its category/style,
  • adapt it to a different viewpoint,
  • and still harmonize perspective, lighting, shadows, etc. with the original room.

There are now dedicated methods for this, for example Insert Anything, OSInsert, IMPRINT, ObjectMate, and CareCom.

But I would not expect any of them to guarantee:

one reference photo + a substantially different camera angle + exact unseen product geometry.

That last part is important. If the reference only shows the front/three-quarter view of a bed, the exact geometry of an unseen side or back simply is not present in the image. A model can generate a plausible novel view, but “plausible” is not necessarily “this exact manufactured product”.

Also, the approaches you already tried are not necessarily the wrong direction. They just control different pieces of the problem:

  • inpainting: mainly controls where regeneration happens;
  • ControlNet: is very useful if you already have the correct depth/edges/geometry to condition on;
  • IP-Adapter: supplies image-derived conditioning, but that conditioning is not a hard 3D product-geometry constraint (Diffusers IP-Adapter guide);
  • LoRA/DreamBooth: can help if this is a product you will reuse many times, especially when you have multiple reference views, but it does not by itself solve placement + viewpoint conversion + inpainting.

So before replacing the whole stack, I would try a very small set of controls.

What I would try first

For the same source/reference and the same seed:

1. Use a clean crop/cutout of the reference object.

2. If possible, try a reference view close to the required target view.

3. Compare:
   A. your current/tight mask
   B. a modestly expanded mask
   C. a larger bbox-like "placement region"

4. If you have more photographs of the same product,
   add a front / side / 3/4 reference rather than trying
   to recover everything from one image.

5. Judge the result by parts:
   - headboard shape
   - legs
   - proportions
   - frame structure
   - upholstery / pattern
   - logos/text if relevant

I would do those A/Bs before spending much time tuning CFG, adapter strength, prompts, or trying ten more models.

The mask test in particular can be surprisingly important. If your current mask tightly follows the silhouette of the old bed, that silhouette can become a geometric constraint when the new bed needs a different shape or viewpoint.

The official Insert Anything inference code, for example, does not simply take an arbitrary tight object mask and leave everything else unchanged: it preprocesses/crops the reference, expands the target region, and works on a larger local crop. Its README also explicitly says that the mask needs to fully cover the area to be edited.

OSInsert goes even further: its conservative path uses Insert Anything directly, while its aggressive path first adapts pose/viewpoint with ObjectStitch and then restores reference details with Insert Anything. In aggressive mode it even changes the mask strategy during denoising, from a SAM-derived object mask to a bbox-like mask.

That is quite close to the underlying conflict here:

preserve this exact object
versus
change this object’s geometry enough to fit this camera and scene.

A practical default route

If this is a one-off / zero-shot replacement, I would probably try:

  1. Insert Anything as the closest directly runnable baseline for background + target region + reference object.
  2. Same/near-view reference first.
  3. Tight vs expanded/bbox target region.
  4. Multiple reference views if available.
  5. Only then move to a more aggressive geometry-adaptation approach such as OSInsert.

If this is instead a catalog/production workflow where the same SKU will be inserted repeatedly, the economics change. Multi-view product photos plus product-specific tuning become much more attractive. The CareCom authors explicitly note that their pretrained model can be weak on rich-detail objects and suggest object-specific fine-tuning when several images of the object are available.

And if by “exact” you mean CAD-level geometry, including unseen sides/dimensions, I would switch branches entirely: use a known 3D/CAD asset, or reconstruct a 3D proxy, control the pose in 3D, then use the generative model mainly for harmonization/relighting. DIRECT is a recent example of this design: it separates appearance, geometry and scene context, using a reconstructed 3D proxy for explicit pose control.

A reconstructed proxy is still only an estimate if it came from one photograph, though. If you already have the manufacturer’s CAD/3D model, that is a much stronger source of geometric truth.

Why reference identity gets difficult when the viewpoint changes

There are really two different things hidden inside “preserve the reference”:

  1. preserve appearance/identity, and
  2. preserve or correctly transform geometry.

Those are not the same problem.

The current Diffusers documentation describes IP-Adapter as image-based guidance: an image encoder extracts features which are injected through additional cross-attention layers. It can be masked to particular output regions and combined with multiple image references, but that still means “apply these image features here”, not “this is a complete geometric specification of the object”.

That distinction becomes much more visible with large viewpoint changes.

IMPRINT explicitly separates identity-preserving representation learning from background alignment/harmonization. Its motivation is essentially that existing methods often trade identity fidelity against the geometric/color changes needed to fit the target scene.

ObjectMate frames the goal similarly:

  • preserve object identity,
  • while generating an appropriate pose,
  • lighting,
  • and composition.

One interesting part of ObjectMate is that it builds training supervision from multiple real views of the same recurring object, rather than assuming one view contains enough information about the complete object.

That is why I would regard additional product views as much more valuable than another round of prompt engineering if the failure only starts when the camera changes significantly.

A useful way to think about the requirement is:

"same product" can mean three different things:

1. recognizable as the same SKU
2. part-level exact
   (legs, headboard, proportions, logo, stitching, etc.)
3. geometrically exact
   (including unseen surfaces / CAD geometry)

Level 1 is increasingly practical with 2D generative editors.

Level 2 is still a hard identity-preservation problem, especially under pose/view changes.

Level 3 requires information that a single 2D reference may simply not contain.

Why I would A/B the mask before changing models

There are several different things people call a “mask” in these workflows:

  • an edit region: pixels that may change;
  • a placement region: approximately where the new object should go;
  • a shape constraint: what silhouette the result should follow;
  • an image-conditioning routing mask: where a reference embedding should influence generation.

Those have very different semantics.

If your mask is the exact silhouette of the old bed, but the new bed has:

  • a taller headboard,
  • different legs,
  • different proportions,
  • or a different projected silhouette because the camera angle changes,

then the requirements may conflict.

That does not mean “always use a huge mask”. Too much freedom can damage placement/background consistency.

I would simply run:

same source
same reference
same seed

A = current mask
B = slightly dilated mask
C = bbox-like placement region

Then compare the actual structural details.

This is also roughly consistent with how several dedicated compositing systems are designed.

OSInsert, for example, has:

  • a conservative mode using Insert Anything within a bbox;
  • an aggressive mode using ObjectStitch → SAM → Insert Anything;
  • a two-phase aggressive mask schedule, using a SAM mask first and a bbox mask later.

AnyDoor also treats shape/location control as something that can be made stronger or weaker rather than assuming one mask meaning for every edit.

So I would treat the mask as a first-class experimental variable, not just a preprocessing detail.

A small rigid-object sanity check

I also tried a small controlled sanity check because I was curious about this exact mask/viewpoint interaction.

I used a rigid sofa with multiple turntable views and kept the insertion model/seed fixed.

The conditions were approximately:

0° reference  + tight 0° sofa silhouette  -> insertion worked
15° reference + tight 0° sofa silhouette  -> insertion worked
60° reference + tight 0° sofa silhouette  -> insertion nearly failed
60° reference + loose placement region    -> insertion worked

The last two are the interesting pair: the reference was identical; only the target-region geometry changed.

That obviously does not diagnose your bed case, and it does not establish a magical angle threshold. The test also used a generated/public fixture rather than your source images.

But it did convince me that I would test the target mask before concluding that the reference-conditioning model itself is the whole problem.

It also showed the other side of the issue: even when insertion succeeded, the rigid object was still regenerated to fit the scene. It was not a pixel-perfect re-render of a known 3D product.

So I would distinguish:

identity-preserving generative insertion

from:

exact rigid-object reprojection.

They overlap, but they are not identical tasks.

Which approach I would try under different constraints

A compact decision tree might be more useful than a model ranking.

1. Do you want to keep the old object’s shape?

Yes — mostly transfer appearance/material/design cues

A shape-preserving reference-editing approach is more appropriate. For example, MimicBrush explicitly exposes a “keep original shape” style of control.

No — the new bed should have its own real geometry

Then I would avoid using the old bed silhouette as an unnecessarily hard constraint.


2. Is the desired target view close to the reference?

Yes

Start with the conservative route:

  • clean reference;
  • same/near view;
  • Insert Anything or another dedicated insertion model;
  • minimum geometry modification.

No

Then the problem includes actual viewpoint synthesis.

Try, in roughly this order:

  • extra views of the same product;
  • a method designed to adjust pose/viewpoint;
  • or an explicit 3D branch if geometry is important.

OSInsert is particularly interesting here because its aggressive path explicitly separates “make the foreground pose/view fit the background” from “restore the reference details”.


3. Do you have multiple photographs of the same product?

Yes

Use them.

ObjectMate is built around multiple recurring views of identical objects.

CareCom extends ObjectStitch to accept multiple reference images, and its maintainers explicitly say that more reference images generally help.

For repeated use of one rich-detail product, CareCom also documents a fine-tuning path using a few images of the object.


4. Is exact hidden geometry actually required?

No

Stay in the 2D generative branch. The output may be sufficient for visualization even if some unobserved geometry is inferred.

Yes

I would stop treating the image editor as the source of geometric truth.

If a CAD/3D product asset exists:

product CAD / 3D asset
        ↓
choose target camera / pose
        ↓
render geometry/depth/masks
        ↓
generative harmonization / relighting / cleanup

If no 3D asset exists, an image-to-3D proxy can still help control pose, but it should not be mistaken for ground-truth geometry.

DIRECT is a useful recent example. It reconstructs a 3D proxy, allows explicit 6-DoF pose control, and then injects decomposed geometry/appearance/context conditions into the image-generation stage.

There is also a broader family of “2D → 3D → 2D” editing work based on the same idea: rigidity and pose are much easier to define explicitly in 3D than to hope they emerge from a soft reference embedding.


5. Is this one image, or a repeated product workflow?

One/few images

Use the zero-shot/tuning-free branch first.

Same SKU across many scenes

At that point, multi-view capture and product-specific tuning can be worthwhile.

This is where LoRA/DreamBooth-style customization becomes much more attractive economically — but it still does not invent reliable hidden-side geometry that was never observed.

Current runnable/open-weight options I would keep on the shortlist

Insert Anything

Insert Anything is probably the closest directly runnable baseline I found for your input contract.

It supports object insertion/replacement from a reference and a target area. The project provides:

  • standard inference;
  • ComfyUI integration;
  • training code;
  • and a Nunchaku low-VRAM path documented for about 10 GB VRAM.

For a first specialized baseline, this is where I would start.


OSInsert

OSInsert is more interesting if the reference must change pose/viewpoint substantially.

Its two modes are conceptually useful even if you do not ultimately use the implementation:

conservative:
    preserve reference more directly

aggressive:
    first adapt pose/viewpoint to the scene
    then restore reference details

That is almost exactly the design trade-off in your question.

The aggressive stack is considerably heavier than running Insert Anything alone.


Qwen-Image-Edit-2511

Qwen-Image-Edit-2511 is also worth having as a modern general-editor baseline. Its official materials emphasize improved consistency, geometric reasoning, new-view generation and industrial-design use cases.

I would treat it as a different comparison branch, though, not as proof that the specialized mask/reference problem has been solved.

At the time of writing, current Diffusers QwenImage documentation exposes multi-image editing through QwenImageEditPlusPipeline, while hard-mask inpainting is handled by a separate inpainting pipeline. So I would not assume that “multi-reference + hard target mask” is one simple unified Plus call.


Research references rather than first installs

For understanding the problem itself, I would also keep:

as useful maps of the current design space.

Background preservation, evaluation, hardware, and licensing

“Keep the background unchanged” has two possible meanings

These are not quite the same:

  1. keep the room/furniture/walls unchanged semantically, or
  2. keep every pixel outside the object mask unchanged.

If a newly inserted bed should cast a different shadow, reflection, contact shadow or ambient occlusion, physically natural integration may require changing pixels outside the literal object silhouette.

If requirement (2) is strict, a safer architecture can be:

generate/edit a controlled local region
        ↓
explicitly composite only the allowed pixels back

but that also limits the model’s freedom to generate environmental effects.

So I would define that requirement before evaluating “background preservation”.


Evaluate product identity separately from overall image quality

A visually nice image can still contain the wrong product.

I would not rely on a single CLIP/DINO similarity score.

ObjectMate specifically discusses the difference between semantic similarity and true instance identity retrieval.

A recent product-focused benchmark, ProductConsistency, likewise evaluates product identity as its own problem and still shows substantial room for improvement in current editors including Qwen-Image-Edit-2511 and FLUX.1-Kontext-dev.

For your bed example I would make the manual checklist primary:

headboard shape
leg count / leg shape
overall proportions
frame thickness
upholstery / stitching
decorative parts
logo/text if present

Then evaluate perspective, placement, lighting and background preservation separately.


Hardware changes the practical recommendation

The model list changes a lot depending on available VRAM and whether cloud inference is acceptable.

For example, the current Insert Anything README documents:

  • a Nunchaku path for ~10 GB VRAM;
  • higher-memory regular paths.

I was able to run the Nunchaku route on a Colab T4 for a small test, so a high-end workstation is not necessarily required just to test the idea.

On the other hand, pipelines such as DIRECT are much heavier: its demo pulls DIRECT, FLUX.1-Fill-dev, TRELLIS-image-large, SigLIP2 and RMBG-2.0, and its environment includes compiled CUDA extensions.

So I would choose the conceptual branch first, then choose an implementation that fits the hardware budget — rather than the other way around.


One licensing detail worth checking

Some of the most useful public-code pipelines depend on FLUX.1 [dev] models.

For example, Insert Anything depends on FLUX.1-Fill-dev / Redux-dev.

The current FLUX.1 Fill dev license permits use of the model/derivatives for non-commercial/non-production purposes unless a separate commercial license is obtained.

It separately states that generated outputs may be used for commercial purposes, subject to its terms.

So if this is eventually a production/product-visualization pipeline, I would check the complete dependency/license chain rather than assuming that the GitHub repository’s source-code license automatically governs the underlying model weights.

So, for your exact case, my default path would currently be:

first:
    reference crop quality
    + same/near-view reference
    + tight-mask vs expanded-region A/B

then:
    Insert Anything as a direct specialized baseline

if viewpoint adaptation is the main failure:
    multi-view references
    and/or an OSInsert-style geometry-adaptation branch

if exact product geometry is non-negotiable:
    move geometry into CAD/3D,
    and use the image model for compositing/harmonization

If you post the source image, current mask, reference image, and current result you mentioned, those four images would probably make the next diagnosis much more concrete. In particular, the actual mask shape and the source/reference viewpoint difference should make it possible to tell whether you are mainly hitting identity conditioning, a geometry/mask conflict, novel-view ambiguity, or scene harmonization.

And GPU/VRAM (or whether cloud inference is acceptable) would help narrow down which implementation branch is practical.

So first image is source image, 2nd is target bed, 3rd i s mask and 4th is SDXL IP adaptor image generator , see how the bed it generate even i set 1.0 value to adaptor to follow the reference image strictly.

Thanks. With those images, a sample workflow would look roughly like this:


For this particular case, I would try OSInsert in aggressive mode before spending much more time tuning IP-Adapter strength alone.

The main reason is that your reference and target scene are asking for two different things at once:

  1. adapt the object’s pose/viewpoint/geometry to the room, and
  2. recover the reference object’s identity and fine structure afterward.

With your images, separating those two jobs worked much better than treating the reference image as one soft conditioning signal throughout the edit.

A rough version of the pipeline is:

reference bed
    ↓
foreground crop / mask
    ↓
ObjectStitch
    → adapt pose/viewpoint to the target room
    ↓
SAM
    → recover the adapted bed region
    ↓
blend with the original room
    ↓
Insert Anything
    + FLUX.1 Fill
    + FLUX.1 Redux reference conditioning
    ↓
OSInsert aggressive denoising
    SAM mask first → bbox mask later
    ↓
final composite

That is also essentially the division used by OSInsert itself: its aggressive mode is ObjectStitch → SAM → Insert Anything, with a two-phase mask schedule during the final Fill stage.

For comparison, ObjectStitch is aimed more at adapting viewpoint/geometry/color/shadow to the destination scene, while Insert Anything is aimed more directly at reference-based insertion with identity/detail preservation. OSInsert combines those ideas as a two-stage authenticity/fidelity trade-off.

I also made a runnable version using the images from your post:

The notebook defaults to your posted source/reference/mask images if no custom images are supplied.

For this particular image set, split_ratio=0.33 gave me the strongest balance among the three values I tried (0.33, 0.50, 0.67). I would treat 0.33 only as a starting point for these images, not as a generally optimal OSInsert setting.

The other important result was that neither cleaning the reference nor simply enlarging the edit mask solved the design drift by itself. The much larger improvement came after introducing the separate viewpoint-adaptation stage.

So I do not think the useful conclusion here is simply “your mask is too tight.” The mask matters, but it seems to be one part of a larger geometry/identity trade-off.

What changed when I tried your actual images

I first separated a few relatively cheap variables rather than changing models immediately.

Using the same source/reference and fixed seed, I compared roughly:

condition reference target region observation
B0 raw supplied tight mask reference character appears, but structural identity still drifts
B1 cleaner bed-focused reference supplied tight mask no clear structural-identity improvement over B0
B2 cleaner reference moderately dilated mask more freedom, but exact bed structure still not recovered
B3 cleaner reference bbox-like placement region much more regeneration freedom, but also more background change; exact identity still unresolved

The mean absolute change outside the original tight mask increased roughly:

B0  4.542
B1  4.622
B2  7.140
B3 15.357

I would not use those numbers as a perceptual-quality metric. They are only useful for showing the preservation side of the trade-off: more geometric freedom also lets the generator alter more of the surrounding scene.

The useful qualitative result was:

  • reference cleanup alone did not fix the bed structure;
  • mask widening alone did not fix the bed structure;
  • giving the model more room did increase geometric freedom;
  • but the reference still had to be reinterpreted from an oblique view into the almost-frontal destination view.

That pointed more strongly toward viewpoint adaptation before identity refinement.

When I inserted an ObjectStitch stage first:

  • ObjectStitch alone produced a much more plausible target-side pose/view, but its object details were relatively coarse;
  • refining that result with a restrictive SAM-derived region preserved the scene well but recovered less of the specific bed identity;
  • using a wider bbox-like refinement recovered substantially more of the reference-specific wooden frame / white padded headboard structure, but changed more of the surrounding area.

That is exactly the kind of conflict OSInsert’s dynamic schedule is intended to mediate.

Why the SAM → bbox schedule was useful here

In OSInsert aggressive mode, the final Fill denoising does not need to use the same mask for every timestep.

The repository supports:

early denoising: SAM object mask
later denoising: bbox / placement region

controlled by split_ratio.

On this one fixed-seed case I tried:

condition schedule outside original-mask MAE qualitative tendency
static SAM SAM throughout 5.610 strongest preservation, weakest recovery of reference structure
0.67 SAM 67% → bbox 7.120 preservation-oriented
0.50 SAM 50% → bbox 7.686 intermediate
0.33 SAM 33% → bbox 10.180 strongest reference structure among the three dynamic settings
static bbox bbox throughout 15.493 strongest regeneration freedom, largest surrounding change

For these particular images, 0.33 was a useful point between the two static extremes.

Visually, it retained considerably more of the reference-specific structure while avoiding some of the surrounding regeneration seen with bbox-only refinement.

Again, this is:

  • one image pair,
  • one fixed seed,
  • three sampled split ratios,

so I would not infer that 0.33 is universally best.

The more general observation is just that dividing the process into a relatively constrained phase and a freer reconstruction phase produced a meaningful preservation/fidelity trade-off here.

The relevant OSInsert implementation is in the OSInsert repository.

Why stronger IP-Adapter conditioning does not necessarily give exact product geometry

I think this distinction is important for the original problem.

IP-Adapter is an image-conditioning mechanism. Increasing its scale increases the influence of the reference image, but that is not the same thing as imposing a hard constraint such as:

this exact headboard geometry
this exact number and position of legs
this exact rail thickness
this exact unseen backside

The Diffusers IP-Adapter guide describes its scale as controlling image-prompt influence.

In your case, the reference bed is seen from a substantially oblique/elevated view while the destination bed is close to frontal. That means part of the requested result is effectively a novel-view reconstruction problem, not only an appearance-transfer problem.

The visible parts of the product can strongly constrain the result.

The hidden parts cannot.

A single oblique image does not uniquely specify things such as:

  • the exact geometry behind the visible headboard,
  • the far-side leg arrangement,
  • exact frame depth,
  • unseen joints,
  • the product’s geometry from a frontal camera.

A diffusion model can generate a plausible completion, but “plausible same product” and “catalog/CAD-exact same SKU from a new view” are different requirements.

That limitation remains even if the generated result looks very convincing.

If you want to stay with SDXL

I would not consider the SDXL route a dead end.

What I would change is the division of responsibilities.

Instead of asking one RGB proxy or one adapter to carry pose, geometry, appearance, and identity together, I would separate the controls:

original source image
        +
structural proxy
        ↓
ControlNet
        → pose / geometry guidance

reference product image
        ↓
IP-Adapter
        → identity / appearance guidance

This is a supported pattern conceptually as well: the Diffusers IP-Adapter documentation explicitly shows IP-Adapter combined with ControlNet for structural control, and the ControlNet guide covers Canny/depth/pose-style structural conditioning.

I tried the same decomposition on this case.

The useful detail was not to pass the ObjectStitch RGB result directly as the SDXL img2img initialization.

Doing that carries not only the desired pose geometry but also ObjectStitch’s coarse appearance into the next generator.

A cleaner separation was:

ObjectStitch pose proxy
    ↓
extract Canny / structural information only
    ↓
ControlNet

original room
    ↓
SDXL img2img init

reference bed
    ↓
IP-Adapter Plus

So the source image remains the source of room appearance, ControlNet receives structural information, and IP-Adapter receives reference identity/appearance.

That produced a more coherent behavior than mixing the coarse pose proxy directly into the RGB generation path.

So if you want to remain with SDXL, I would try this separation before concluding that the family cannot do the task.

I would still start with OSInsert for this specific pair of images, because the explicit pose/viewpoint-adaptation stage matched the failure mode better in my test.

A practical decision tree

The choice of method depends quite a lot on what “exact” needs to mean.

Is the viewpoint difference small?
│
├─ Yes
│  └─ Start with direct reference insertion:
│       Insert Anything / SDXL + IP-Adapter
│
└─ No
   │
   ├─ Is a recognizable, highly similar product sufficient?
   │  └─ Try OSInsert aggressive first
   │
   └─ Must the geometry be exact for that SKU?
      │
      ├─ Do you have a reference from a similar target angle?
      │  └─ Use it; this removes a large amount of ambiguity
      │
      ├─ Do you have multiple views of the same product?
      │  └─ Prefer a multi-view / multi-reference route
      │
      ├─ Do you have CAD / a 3D asset?
      │  └─ Use the geometry explicitly, then use generative
      │     editing mainly for lighting, harmonization, shadows, etc.
      │
      └─ Only one oblique photo exists
         └─ A 2D generative method can synthesize a plausible
            new view, but hidden exact geometry is underdetermined

There is another independent branch:

Must pixels outside the supplied mask remain exactly unchanged?
│
├─ Yes
│  └─ composite explicitly and keep the generative region hard-bounded
│
└─ No
   └─ allow a surrounding effects region for shadows,
      contact, illumination, and geometry adaptation

That distinction matters because a naturally inserted object may need to create a floor shadow, contact shadow, reflection, or ambient-occlusion change outside the object’s exact silhouette.

Relevant projects

A few projects that map fairly directly onto pieces of this problem:

  • Insert Anything / AAAI paper
    Reference-based image insertion with mask/text guidance and local adaptation. Its inference pipeline also preprocesses the reference object and expands the target working region rather than treating the raw inputs as immutable geometry.

  • OSInsert / paper
    Particularly relevant here because it explicitly separates high-authenticity pose/view adaptation from high-fidelity refinement.

  • ObjectStitch
    Useful for target-scene geometry/viewpoint adaptation, harmonization, and shadow generation.

  • IP-Adapter
    Useful for reference-image conditioning, but its image scale should not be interpreted as a hard product-geometry constraint.

  • ControlNet
    Useful when you can provide the target-side structure independently as Canny/depth/pose/etc.

For this exact example I would put OSInsert at the top of that list because it gives the viewpoint/identity separation explicitly instead of trying to force both through one conditioning pathway.

Notes about the runnable example

The sample notebook uses:

  • OSInsert’s aggressive-mode mechanism;
  • ObjectStitch + SAM;
  • FLUX.1 Redux reference embeddings;
  • FLUX.1 Fill for final insertion;
  • Insert Anything weights;
  • the OSInsert SAM → bbox dynamic mask schedule.

To fit the experiment on a T4, the Fill transformer is the Nunchaku INT4 FLUX.1-Fill-dev variant rather than the original unquantized Fill transformer, with a few compatibility adjustments for the current Colab stack.

So it is best described as a T4-compatible reproduction of the OSInsert aggressive mechanism, not as a byte-for-byte reproduction of the authors’ original environment.

The notebook also requires access to the FLUX dev components, including FLUX.1-Fill-dev. Check the model access conditions/license before using that stack for your intended application.

The T4 part is only how I ran this sample; it is not a requirement for your own pipeline.

So my default path for your current example would be:

  1. try the OSInsert aggressive decomposition rather than increasing reference strength alone;
  2. use split_ratio≈0.33 only as a first value to try for these particular images;
  3. if staying with SDXL, separate ControlNet geometry from IP-Adapter identity instead of feeding one intermediate RGB image into both jobs;
  4. if the requirement eventually becomes exact SKU geometry from a substantially different view, add same-product views or explicit 3D geometry rather than expecting a single oblique reference image to fully determine invisible structure.

The encouraging part is that the identity drift in this example was not all-or-nothing: once pose/view adaptation and detail restoration were separated, substantially more of the bed-specific structure survived while the room could still be kept reasonably stable.

Hi! First of all, thank you so much for taking the time to test my actual images and create the runnable notebook. I really appreciate the detailed explanation and the effort you put into comparing the different approaches. Your explanation about separating viewpoint/geometry adaptation from object identity recovery was especially helpful.

I went through the notebook and noticed that the final pipeline uses FLUX.1-Fill-dev and FLUX.1-Redux-dev. As far as I understand, these models use a non-commercial/dev license, while my goal is eventually to use this object-replacement pipeline in a commercial production application.

Because of that, I wanted to ask for your advice: is there another approach or commercially usable model that could replace the FLUX stages while keeping the same overall pipeline idea?

For example, could I keep:

ObjectStitch → SAM → viewpoint adaptation

and replace the final:

FLUX Redux + FLUX Fill + Insert Anything refinement

with something else, such as SDXL inpainting + ControlNet + IP-Adapter, or would you recommend a completely different approach?

My main goal is still the same: take a reference object, adapt it to the viewpoint of the target scene, and then preserve as much of the object’s specific identity and structure as possible during the final refinement.

I would really appreciate your recommendation on the best approach for a pipeline that can eventually be used commercially. Thanks again for all your help!

Hmm… if this is for commercial use, I think Qwen-Image-Edit is probably the most practical option, although it is fairly VRAM-hungry​:thinking::


Yes — I think you can keep the same overall decomposition, but I would change one part of the plan:

I would not try to replace only FLUX.1-Fill while keeping the rest of Insert Anything intact.

The public Insert Anything pipeline is fairly coupled to FLUX Fill + Redux + its LoRA, so for a commercial-friendly version I would treat this whole part as one replaceable block:

FLUX Redux
+ FLUX Fill
+ Insert Anything refinement

and replace that block with a different image editor.

At this point, my first candidate would be Qwen-Image-Edit-2511 rather than rebuilding the refinement stack from SDXL immediately.

The main reason is not just the Apache-2.0 license. Qwen-Image-Edit is already aimed at several pieces of this problem:

  • multi-image editing;
  • preserving an input subject while editing its context;
  • generating new viewpoints;
  • improved geometric reasoning;
  • industrial/product-oriented edits.

The official 2511 model card also explicitly shows new-viewpoint generation and industrial design examples, and the model itself is published under Apache-2.0.

So I would probably simplify the first commercial experiment to:

source room
+ reference bed
        ↓
Qwen-Image-Edit-2511
        ↓
check:
    product identity
    target viewpoint
    room preservation
        ↓
optional explicit compositing

before adding ObjectStitch back in.

That gives you an important baseline: can the newer editor already perform enough of the viewpoint transformation itself?

If yes, the commercial pipeline becomes much simpler.

If no, then I would bring the geometry/viewpoint stage back:

reference bed
    ↓
ObjectStitch
    → target-view / geometry proxy
    ↓
SAM / structural extraction

source room
+ original reference bed
+ target-view proxy
        ↓
Qwen-Image-Edit
        ↓
final refinement

The important part is that I would use the ObjectStitch result mainly as a geometry/view hint, not as the appearance truth for the final image.

That preserves the useful part of the previous OSInsert experiment:

first solve enough of the viewpoint problem, then ask the final editor to recover the product identity.

Why I would try Qwen before rebuilding this with SDXL

Your proposed SDXL route is valid:

original source RGB
        +
ControlNet
    ← geometry / edge / depth proxy
        +
IP-Adapter
    ← reference identity

and this separation behaved much better than mixing everything into one RGB conditioning path when I tested your images.

But it still leaves you with quite a few independently tuned pieces:

  • SDXL inpainting;
  • ControlNet;
  • IP-Adapter;
  • target crop;
  • structural-condition strength;
  • adapter strength;
  • mask expansion;
  • denoising strength;
  • final compositing.

Qwen gives you a much more integrated starting point for essentially the same problem.

2511 vs 2509: I would actually keep both on the shortlist

There is one slightly unusual reason I would keep the older Qwen-Image-Edit-2509 around as a comparator.

The official 2509 release specifically added:

  • multi-image editing;
  • improved product editing consistency;
  • native support for structural conditions such as depth, edges, keypoints and sketches.

The official notes are here:

Qwen-Image-Edit-2509 release notes

That maps surprisingly well onto this problem.

A possible 2509 branch would therefore be:

reference bed
    ↓
ObjectStitch
    ↓
edge/depth/structural proxy

source room
+ original reference bed
+ structural proxy
        ↓
Qwen-Image-Edit-2509

Conceptually, this is close to the SDXL + ControlNet + IP-Adapter decomposition, except the multi-image/identity/editing machinery is already part of the Qwen editor family.

For 2511, I would first try it without an external structural condition because 2511 itself advertises stronger geometric reasoning and direct novel-view generation.

So my rough distinction would be:

2511
    → first/default editor
    → newer consistency and viewpoint capability

2509
    → useful comparator
    → especially interesting when you want an explicit
      structural-control path

I would not assume without testing that every 2509 structural-control behavior is identically exposed in 2511.

One current API detail: multi-image editing and hard-mask inpainting are not quite the same interface

Current Diffusers QwenImage documentation has both relevant pieces:

  • QwenImageEditPlusPipeline for multiple reference images;
  • QwenImageEditInpaintPipeline for an explicit image + mask_image edit.

The inpainting mask follows the usual convention:

white = repaint
black = preserve

That is useful, but I would not currently describe the API as:

source
+ reference product
+ hard mask
+ structural ControlNet

all being one completely unified 2511 call.

Those capabilities exist in the family, but the exact integration path still deserves a small implementation test.

There is also a more fundamental mask issue that does not disappear when changing models.

For your bed:

old-bed silhouette

is not necessarily the same as:

allowed placement region for the new bed

and neither is necessarily the same as:

pixels that must remain bit-identical in the final output

I would keep those concepts separate:

placement region
    → enough room for the new geometry

object / structural region
    → guides the model

final preservation boundary
    → optionally enforced by explicit compositing

That same distinction was useful in the previous FLUX/OSInsert test, and I think it remains useful with Qwen.

If the room really must remain unchanged

For production, I would probably not rely solely on the model to preserve every background pixel.

If your contract is literally:

everything outside the approved region must remain identical,

then make that a pipeline guarantee rather than a model-quality hope:

generate local edited result
        ↓
approved final mask
        ↓
composite edited pixels onto original source

You can optionally keep a larger temporary region during generation for:

  • contact shadow;
  • floor interaction;
  • geometry adaptation;
  • lighting transition;

and then decide separately how much of that larger region is allowed into the final composite.

That makes the preservation behavior much easier to audit.

If Qwen preserves the scene but still changes the product too much

There is now some work specifically targeting product identity preservation rather than generic edit quality.

One relevant recent example is:

ProductConsistency: Improving Product Identity Preservation in Instruction-Based Image Editing via SFT and RL

The authors treat product consistency as its own problem and fine-tune Qwen-Image-Edit-2511 and FLUX.1-Kontext-dev using product-centric SFT/RL data.

Their evaluation separately looks at things such as product identity, text/OCR and perceptual quality.

That is useful evidence for a broader point:

if base Qwen is close but still changes important SKU-specific details, product-specific training/reward design is a realistic next step rather than immediately changing the whole architecture again.

There is also an Apache-2.0 Qwen-2511 adapter from that work:

FractalAIResearch/Kalaido-qwenedit-lora

Its model card specifically targets better background preservation and instruction following.

Another newer project is:

ReCoEdit

with the released:

ReCoEdit-RL adapter

It uses Qwen-Image-Edit-2511 as the base editor and trains for product-consistency reward.

This is very close conceptually to your eventual production problem:

change the scene
without changing the product

I would treat ReCoEdit as an interesting experimental branch rather than a proven production winner yet. Its repository currently reports a large improvement in its internal training reward, but independent benchmark/ablation material is still being filled in.

So I would test in this order:

base Qwen-Image-Edit-2511
        ↓
if identity is insufficient
        ↓
product-consistency LoRA / tuning
        ↓
if this is one SKU used repeatedly
        ↓
multi-view or SKU-specific training
VRAM / deployment is probably the main practical downside

This is the obvious downside of the Qwen route.

Qwen-Image-Edit is built on the large Qwen-Image family, so full-precision deployment is substantially heavier than SDXL.

I would therefore separate:

best architecture to test

from:

final serving configuration

Diffusers supports several generic memory-reduction mechanisms, including:

  • quantization;
  • model CPU offload;
  • sequential/group offload;
  • multi-GPU device maps.

The Diffusers quantization quickstart, for example, shows the base Qwen-Image model running with 4-bit quantization at about 14.9 GB of reported GPU memory in that particular example.

I would not copy that number directly to Qwen-Image-Edit-2511 — different pipeline, image count, resolution and implementation details can change the requirement — but it shows that the model family does have practical quantized deployment paths.

The trade-off is predictable:

more GPU memory
    → simpler / faster inference

quantization
    → lower memory

CPU or group offload
    → still lower GPU memory
    → more transfer overhead / latency

The Diffusers memory guide explicitly warns that aggressive CPU offloading can become very slow.

So for a production system I would benchmark:

quality
latency
GPU memory
throughput

together rather than choosing purely by “can it fit”.

Commercial-license boundary

For the model that would sit at the center of this alternative stack:

For the optional geometry/segmentation side:

The product-consistency adapters mentioned above are also published with permissive licenses:

That is much cleaner for this particular requirement than the FLUX [dev] branch.

I would still do a normal production dependency audit before shipping.

In other words:

check the license of every actual model/checkpoint/adapter you load, not only the GitHub repository containing the orchestration code.

That is especially worth doing if you add auxiliary vision encoders, third-party checkpoints, quantized redistributions or community LoRAs later.

This is just a technical dependency observation, not legal advice.

What I would try on your bed example

If I were converting the previous experiment into a commercially usable branch, I would now run the smallest sequence that tells us where the remaining difficulty actually is:

A. Qwen-Image-Edit-2511
   source room + reference bed

        ↓ if viewpoint is already good

   stop adding geometry machinery

        ↓ if viewpoint is weak

B. Qwen-Image-Edit-2511
   source room
   + reference bed
   + ObjectStitch target-view proxy

        ↓ if explicit structural control looks necessary

C. Qwen-Image-Edit-2509
   source room
   + reference bed
   + edge/depth-style target-view condition

        ↓ if product identity is still the weak part

D. Qwen-2511
   + product-consistency adapter / product-specific tuning

I would keep the SDXL branch as:

E. SDXL inpaint
   + ControlNet geometry
   + IP-Adapter identity

but I would now treat E as the composable fallback, not the default route.

The reason is mostly engineering cost: with SDXL you have to construct and tune the separation yourself, whereas Qwen is a much stronger integrated starting point for product/reference editing.

And the same limitation from the previous post still applies regardless of which commercial editor you choose:

one oblique product photo
    → can support a plausible and increasingly consistent novel view

multiple photos of the exact SKU
    → provide much stronger identity / geometry constraints

CAD / 3D
    → use this branch if unseen geometry must actually be exact

So if your target is “recognizably and structurally the same bed from the room’s viewpoint”, I would try the Qwen branch first.

If your target eventually becomes “the hidden geometry must match the manufactured SKU exactly”, I would still move that part of the problem into multi-view or explicit 3D geometry rather than asking any 2D editor to infer it from a single oblique photograph.