Metadata-Version: 2.5
Name: laidline-diffusers
Version: 1.0.1
Summary: `attach(pipe)` marks every image a diffusers pipeline returns (watermark, C2PA, evidence) and replaces the SDXL invisible watermarker
Project-URL: Homepage, https://laidline.com
Project-URL: Documentation, https://laidline.com/docs/quickstart
Project-URL: Changelog, https://laidline.com/docs/changelog
Author: Laidline LLC
License-Expression: LicenseRef-Laidline-Source-Available
License-File: LICENSE
Keywords: ai-act,c2pa,diffusers,provenance,watermark
Classifier: Development Status :: 5 - Production/Stable
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Multimedia
Classifier: Topic :: Security :: Cryptography
Requires-Python: >=3.12
Requires-Dist: laidline[image]<2,>=1.0
Requires-Dist: numpy>=1.26
Requires-Dist: pillow>=10
Provides-Extra: diffusers
Requires-Dist: diffusers<0.41,>=0.40; extra == 'diffusers'
Requires-Dist: torch>=2.5; extra == 'diffusers'
Requires-Dist: transformers>=4.46; extra == 'diffusers'
Description-Content-Type: text/markdown

# laidline-diffusers

`attach(pipe, marker)` marks every image a diffusers pipeline returns (TrustMark watermark, C2PA manifest, evidence
entry), exactly once per image, and replaces SDXL's artifact-prone invisible watermarker. `detach(pipe)` undoes it.

```python
from laidline import Marker
from laidline_diffusers import attach

pipe = attach(pipe, Marker.from_config("laidline.yaml"))
out = pipe(prompt="a lighthouse at dusk")
out.assets[0].save("lighthouse.png")   # the signed file: watermark and C2PA manifest
out.images[0]                           # the same pixels, watermark only (a manifest cannot live in pixels)
```

- `attach` swaps the pipeline's class for a cached subclass whose `__call__` runs the original and then marks the
  output; the class name, qualname and module are kept, so `type(pipe).__name__` and `save_pretrained` are unchanged.
- `out.images` carry the watermark only, in the original type, shape and dtype; `out.assets[i]` (`MarkedAsset`) holds
  the signed bytes (`data`, `asset_id`, `manifest_id`, `save(path)`). Store or serve `asset.data`.
- SDXL's `StableDiffusionXLWatermarker` is replaced (`pipe.watermark = None`; `replace_watermarker=False` keeps it).
- A marking failure raises `MarkError`: no unmarked image is returned.

Status: proven on diffusers 0.40.0 tiny random pipelines on CPU (`hf-internal-testing/tiny-stable-diffusion-torch`
and `hf-internal-testing/tiny-stable-diffusion-xl-pipe`); no production checkpoint was run. See
https://laidline.com/docs/integrations/diffusers.
