Tools

Porting Moebius 0.2B Inpainting Model to the Browser via ONNX and Claude Code

A developer adapted the Moebius 0.2B image inpainting model—originally requiring PyTorch and NVIDIA CUDA—to run in browser using ONNX Runtime Web on WebGPU, with agent assistance from Claude Code.

Porting Moebius 0.2B Inpainting Model to the Browser via ONNX and Claude Code

This morning a developer ported the Moebius: 0.2B Lightweight Image Inpainting Framework with 10B-Level Performance model to run in the browser. The original model required PyTorch and NVIDIA CUDA; the goal was to convert it to ONNX and run it with ONNX Runtime Web on WebGPU so the model could execute directly in a browser. A live demo is available at simonw.github.io/moebius-web/.

How the work started

The developer cloned the Moebius source and the model weights into a local working directory (/tmp/Moebius), and used Claude (Claude Opus 4.8 and Claude Code) to assist with the port. Steps included:

  • Cloning the Moebius repository from GitHub (https://github.com/hustvl/Moebius).
  • Obtaining model weights from Hugging Face (hustvl/Moebius) using GIT_LFS_SKIP_SMUDGE=0.
  • Cloning supporting projects such as transformers.js and microsoft/onnxruntime.

The developer created a moebius-web subdirectory, initialized a git repo there, and prompted Claude Code to convert the model to ONNX and build a web frontend, keeping notes and a plan file under version control.

Technical choices and process

Claude suggested using ONNX Runtime Web with a WebGPU backend — a lower-level layer than transformers.js. The project uses an opset of 18 for ONNX export; export_onnx.py in the repository demonstrates torch.onnx.export usage.

The converted ONNX weights were published to Hugging Face under simonw/Moebius-ONNX, totaling about 1.24 GB of uploaded ONNX files. The web frontend was hosted via GitHub Pages at simonw.github.io/moebius-web/.

How the finished tool works

On the web UI the user can open any image (non-square images are letterboxed), mark regions to remove, and click the "Run inpaint" button; the model fills in the selected areas. The developer tested the demo in Chrome, Firefox and Safari.

Caching and performance

The browser needs to download a sizeable amount of model data — the developer observed roughly a 1.3 GB download when reloading the page. To mitigate repeated downloads they added CacheStorage API usage (caches.open("transformers-cache")), taking cues from an existing Whisper Web demo. There remained concerns that Hugging Face redirects might prevent optimal browser caching in some cases.

Lessons learned

  • Claude Opus 4.8 and Claude Code can orchestrate converting a PyTorch model to ONNX, publishing the results to Hugging Face, and assembling a web application that loads and executes the model.
  • Modern browsers are capable of running these models via WebGPU/ONNX Runtime Web.
  • The CacheStorage API works with large model files (~1.3 GB), making client-only inpainting feasible if users accept the large initial download.

Documentation and extras

The developer published the full Claude Code transcript and created notes.md and understanding.md files in the repo. The understanding.md explains ONNX: an .onnx file bundles a computation graph (nodes/operators like Conv, MatMul, Softmax, etc.) and the learned parameter tensors. ONNX describes what to compute abstractly, independent of specific hardware, and the operator set is governed by an opset number (this repo uses opset 18).

Conclusion

The result is a working browser-hosted inpainting demo that demonstrates small-scale models (0.2B) can run client-side using ONNX and ONNX Runtime Web on WebGPU. The main practical constraint remains the large model downloads and ensuring reliable browser caching across hosting configurations.