From 8ed2d16a23b8590c67717e81f8450d96ded97769 Mon Sep 17 00:00:00 2001 From: Victor Kuznetsov Date: Mon, 8 Jun 2026 20:47:26 -0700 Subject: [PATCH] fix(instantid): pass trust_remote_code=True for local custom_pipeline The img2img run silently produced an identity output because DiffusionPipeline.from_pretrained refused to load the local custom_pipeline .py without `trust_remote_code=True` (emits a single-line warning to stderr, then falls back to a default class). load_ip_adapter_instantid then AttributeError'd, our outer except logged + skipped, and the saved file was the un-restored cleaned image (exact byte size match against the no-restore baseline -- 250988 bytes). We fetch the file from a pinned raw.githubusercontent URL we control, so trust_remote_code is safe to opt in here. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/remove_ai_watermarks/instantid_restore.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/remove_ai_watermarks/instantid_restore.py b/src/remove_ai_watermarks/instantid_restore.py index 3287d3d..eea5eed 100644 --- a/src/remove_ai_watermarks/instantid_restore.py +++ b/src/remove_ai_watermarks/instantid_restore.py @@ -276,6 +276,13 @@ def _get_pipeline() -> Any: controlnet=controlnet, torch_dtype=dtype, custom_pipeline=str(_fetch_img2img_pipeline_file()), + # Custom_pipeline from a local .py file triggers diffusers' remote-code + # guard; the file is fetched from a pinned raw.githubusercontent URL + # we control, so opt in here. Without this the load silently falls + # back to a default pipeline (no img2img + no IP-Adapter cross-attn), + # the next call hits an AttributeError on load_ip_adapter_instantid, + # and our outer except logs but skips the whole restore. + trust_remote_code=True, ) pipe.to(device) # IP-Adapter weights that wire the ArcFace embedding into cross-attention.