Build Pixelcut

KINDAreplaces $10/mosaves $120/yrback to the verdict

0%0 of 17 items done

Saved on this device only. Tick prerequisites first, then work the phases in order · do not start one until the checks above it pass.

A product image pipeline where the difficult parts are the edges: hair and transparent objects need a real alpha matte rather than a hard mask, a cut-out with no shadow looks pasted on, and a replaced background changes the colour the product appears to be, which for a listing is a returns problem.

estimated effort multi-daythe files for this build are in the project pack

SegmentationA local matting model producing a soft alpha channelImagingA library with correct colour management and high bit depthCompositionShadow synthesis and edge decontaminationBatchA worker queue with per-image isolation and a manifestRuntimePython 3.12

Before step 1

Everything below is assumed from the first step. Tick each one when you actually have it, not when you plan to.

  1. installfree

    Why Runs the pipeline and the model.

    Get it python.org or your package manager, then a virtual environment.

    Verify python3 --version prints 3.12 or higher

  2. installfree for open models; needs a capable machine

    Why A binary segmentation model cannot represent hair, glass or motion blur, which is where every real product catalogue fails.

    Get it An open matting model with published weights you may use for your purpose. Check the licence covers commercial use if this is for a business.

    Verify It outputs a soft alpha channel rather than a binary mask

  3. installfree

    Why Compositing in the wrong colour space darkens edges in a way that looks like a bad cut-out rather than a bug, so it is never diagnosed.

    Get it A library supporting high bit depth and explicit colour space conversion.

    Verify A round trip through linear space and back is lossless at high bit depth

  4. have readyfree

    Why Anything succeeds on a shoe against white. The acceptance set decides whether the pipeline is usable.

    Get it Photograph or find: hair or fur, a glass or transparent object, a mesh fabric, something with motion blur, and a product on a background close to its own colour.

    Verify All five exist and each fails a naive binary mask

  5. have readythe price of a colour card, or free with a known product

    Why Measuring how far a composite moved the product's colour requires knowing what the colour was, and eyeballing it does not work.

    Get it A colour card in a few reference shots, or at minimum a known product whose true colour you can state.

    Verify At least three images have a known reference colour

Data model

Create these before the first phase that stores anything. Changing a table later is the expensive kind of change.

- images(id, path, width, height, colour_profile, content_hash, imported_at)
- mattes(image_id, alpha_path, model, refined, edge_quality) · alpha as a separate channel, kept
- compositions(id, image_id, background_kind, background_ref, shadow_params_json, output_path, at)
- reviews(composition_id, verdict, note, at) · verdict is accepted, needs_manual or rejected
- batches(id, started_at, ended_at, input_count, succeeded, failed, manifest_path)
- colour_checks(composition_id, delta_e, region) · how far the product's colour moved, measured rather than assumed
- The alpha matte is stored separately from any composition, because the expensive step should be reused when the background changes.

Environment variables

These go in a .env file the app reads at startup. The pack's .env.example is this table as a file · copy it, never commit the filled-in version.

VariableNeededExampleWhere the value comes from
INPUT_DIRrequired./inputSource images, opened read only.
OUTPUT_DIRrequired./outputComposites and manifests. Never the input directory.
MATTE_MODELrequired./models/matting.onnxThe matting model. Its licence matters if this is commercial work.
MATTE_QUALITY_THRESHOLDrequired0.75Below this an image goes to review rather than output.
COLOUR_SHIFT_WARN_DELTA_Erequired2.0How far the product's colour may move before warning. Small, because listings cause returns.
SHADOW_DEFAULTrequiredcontact_softNeutral by default. A dramatic angled shadow contradicting the lighting looks worse than none.

The build, in order

  1. An alpha matte, not a mask

    Hair and transparent edges survive the cut-out.

    1. Separately from any composite. It is the expensive step and it is reusable.

      Files src/matte.py

    2. Hair, glass, mesh, motion blur, similar-coloured background. Five real ones.

      Files fixtures/hard/

    3. A bad matte silently composited is worse than a flagged one.

      Files src/quality.py

    done when · tick each as it passes
    watch out
    • Judging segmentation on a shoe photographed on white makes every model look excellent, and then hair, glass, mesh and motion blur all fail in production. Assemble the hard cases first and treat them as the acceptance set, because a binary mask will pass the easy ones and cannot represent the hard ones at all.
  2. Edges that do not carry the old background

    A cut-out placed on a new background has no halo from the old one.

    1. Partially covered pixels carry the old background otherwise.

      Files src/decontaminate.py

    2. Convert, composite, convert back. Display-space compositing darkens edges.

      Files src/composite.pytests/test_linear.py

    3. An output with no profile is interpreted differently everywhere.

      Files src/colour.py

    done when · tick each as it passes
    watch out
    • Compositing in the display colour space rather than a linear one produces edges that are visibly too dark, and the effect is subtle enough to look like a slightly bad cut-out rather than a colour management bug, so it never gets diagnosed. Convert to linear, composite, convert back.
  3. Shadows, because floating objects look wrong

    A product on a new background looks like it is resting on something.

    1. The lower boundary of the subject. Soft and short beats dramatic.

      Files src/shadow.py

    2. A contradicting shadow is worse than none.

      Files src/lighting.py

    3. So a composition is reproducible rather than a one-off result.

      Files src/compositions.py

    done when · tick each as it passes
    watch out
    • A shadow whose direction contradicts the lighting visible on the product itself looks worse than no shadow at all, because the viewer cannot say why the image is wrong but can see that it is. Derive the direction from the product's own highlights where you can, and default to a neutral contact shadow rather than a dramatic angled one.
  4. Measuring what you did to the colour

    You know whether the product still looks like the product.

    1. A stated metric, per composition, recorded.

      Files src/colour_check.py

    2. A listing image that misrepresents colour causes returns.

      Files src/colour_check.py

    3. The product region is not yours to change.

      Files src/composite.pytests/test_product_untouched.py

    done when · tick each as it passes
    watch out
    • Adjusting brightness or white balance across the whole composite to make the product sit better on a new background changes the product's apparent colour, which for a clothing or paint listing produces returns and complaints that nobody traces back to the image pipeline. Measure the shift, warn on it, and apply adjustments to the background only.
what this build does not replace
after v1, if you want it

Need the files? The project pack on the verdict page hands your agent the whole brief · more generative media.