mirror of
https://github.com/wiltodelta/remove-ai-watermarks.git
synced 2026-08-06 22:18:36 +02:00
erase_migan fed the whole frame to the ONNX model, so peak RSS scaled with the upload (~0.6 GB at 4 MP up to ~2.4 GB at 25 MP). Mirror erase_lama: crop a padded region around the mask (pad = max(256, 2*bbox)), feed only that crop (at native resolution -- MI-GAN accepts arbitrary dims, unlike LaMa's fixed 512 square), and paste only masked pixels back. Peak RSS is now bounded by the mark size (~0.6-0.9 GB), so a memory-tight host (a 1-2 GB web worker) can run MI-GAN on a 25 MP upload. Fill quality is unchanged: verified by eye on real Gemini/Doubao marks plus a ground-truth reconstruction sweep -- a tighter view if anything reduces the GAN's hallucination of large background structure. Extract the shared padded-crop-box math into _padded_crop_box (used by both erase_lama and erase_migan). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>