Dev.to
7/24/2026

Removing a Photo's Background in the Browser, With No Upload: AI Licenses, ONNX Models, and a Frozen Tab
Short summary
A developer shares a detailed build log for a 100% client-side browser background-removal tool using Transformers.js and ONNX Runtime Web. Key lessons: avoid AGPL-licensed libraries in commercial projects, prefer lightweight CNN architectures over transformers for WASM inference to avoid memory crashes, and post-process alpha mattes with a smoothstep curve to eliminate color halos around cutouts.
- •AGPL-licensed ML libraries are risky for closed-source commercial web apps; switch to permissively licensed alternatives like Transformers.js with Apache-2.0 models
- •CNN-based segmentation models run reliably in WASM while transformer-based ones crash from memory exhaustion at photo resolution
- •Post-processing the soft alpha matte with a smoothstep threshold eliminates residual color halos without needing a second model
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



