The problem
A homeowner wants to see a new roof on their own house before paying for it. Image models can draw a convincing roof, but they also quietly change things nobody asked them to: a window moves, the brick changes colour, a tree disappears.
The opportunity
Let the model do the creative part and let ordinary code do the exact part, so the only pixels that can change are the roof.
My approach
- 01
Find the roof
The model marks up the photo to show where the roof is.
- 02
Make a precise mask
Code turns that markup into an exact mask of the roof, plane by plane.
- 03
Paint only inside it
The model generates the new roof. Only the area inside the mask is kept.
- 04
Correct and blend
Code corrects the colour on each roof plane to match the chosen product colour, then blends the result onto the original, untouched photo.
Architectural decisions
- The house can't change
- Everything outside the mask comes from the original photo. That is a property of the pipeline, not an instruction the model might ignore.
- Colour is measured, not asked for
- The colour correction happens in L*a*b* colour space, plane by plane, because a model asked for a named colour gets close but not right.
- Give the model a ruler
- Roof courses came out several times too large until the prompt pointed the model at things in the photo with a known size, like bricks and windows.
- A public version that defends itself
- The public version checks for bots, limits how often it can be used, and stores only hashed identifiers.
Capability status
Completed, experimental and planned capabilities, kept separate on purpose.
Live5
- Roof replacement on an uploaded photo
- Code-derived roof mask
- Per-plane colour correction
- Public embeddable version with bot checks and rate limits
- Daily limits and recorded cost per render
Results & current status
- In production, including a public version on a marketing website.
- The image pipeline is covered by automated tests on the server.