9094b5d9c0
The multi-level foreground colour estimation (pymatting estimate_foreground_ml) is the pipeline's CPU bottleneck (~7 s/image). pymatting ships a CuPy backend (estimate_foreground_ml_cupy) that runs the same multi-level solve on the GPU ~250x faster; verified visually identical to the float64 CPU result (opaque colours bit-close, the float32 edge delta is alpha-weighted away). Add ForegroundSettings.use_gpu (default True): with method "ml", try the CuPy backend when cupy + a CUDA device are present, otherwise transparently fall back to the CPU solver. pymatting only re-exports the cupy function when cupy is importable, so CPU-only deployments (no cupy) are unaffected. Requires cupy-cudaXXx matching the CUDA build on GPU boxes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>