Hi everyone
I’m working on a project where I need to generate a flat image from a button photo — basically an image with the same color and pattern as the button, but without any holes, lighting, or shadows.
The goal is simple:
Take a photo of a button (which has holes and curved reflections), and create a flat version of it where the area inside the holes is intelligently filled with matching pattern and color.
What I’ve tried so far
-
OpenCV Inpainting:
It fills the holes, but produces blurry or uneven color results. -
Hugging Face Stable Diffusion Inpainting:
Tried using therunwayml/stable-diffusion-inpainting
model, but it often generates unrelated textures or random background. -
Prompt-based approach:
Even with prompts like “fill the button hole intelligently and make it flat,” the output doesn’t match the original pattern.
What I’m looking for
-
A model or technique that can fill small areas with the same texture or pattern as the surrounding region.
-
Whether this can be done using Diffusers, ControlNet, or texture synthesis models.
-
Any working examples, prompts, or notebooks that can help me achieve this flat output image.
My Setup
-
Language: Python
-
Libraries: Diffusers, OpenCV
-
System: macOS M1
-
Torch Backend: MPS (Metal)
from diffusers import StableDiffusionInpaintPipeline
from PIL import Image
import torch
pipe = StableDiffusionInpaintPipeline.from_pretrained(
"runwayml/stable-diffusion-inpainting",
torch_dtype=torch.float16
).to("mps")
result = pipe(
prompt="create a flat version of this button image, fill the holes with same color and pattern, realistic surface",
image=Image.open("button.png"),
mask_image=Image.open("mask.png")
).images[0]
result.save("flat_button.png")
Example
I’ll attach a few button images for reference — each has small holes and patterns that need to be filled seamlessly.
Any help appreciated
If you know of a specific model, technique, or prompt strategy that could handle this better, please let me know.
Your suggestions will help me move this project forward.
Thanks in advance!