Image-to-Image
Diffusers
Safetensors
Core ML
StableDiffusionInpaintPipeline
clover-image
inpainting
stable-diffusion
Instructions to use neonforestmist/Clover-Image-Tiny-Inpaint with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use neonforestmist/Clover-Image-Tiny-Inpaint with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("neonforestmist/Clover-Image-Tiny-Inpaint", dtype=torch.bfloat16, device_map="cuda") prompt = "Turn this cat into a dog" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] - Notebooks
- Google Colab
- Kaggle
Clarify inpainting model card
Browse files
README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: diffusers
|
| 3 |
+
pipeline_tag: image-to-image
|
| 4 |
+
base_model: neonforestmist/Clover-Image-Tiny
|
| 5 |
+
license: creativeml-openrail-m
|
| 6 |
+
tags:
|
| 7 |
+
- clover-image
|
| 8 |
+
- inpainting
|
| 9 |
+
- stable-diffusion
|
| 10 |
+
- coreml
|
| 11 |
+
- iphone
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# Clover Image Tiny Inpaint 🍀
|
| 15 |
+
|
| 16 |
+
An inpainting adaptation of Clover Image Tiny for 512×512 local generation and
|
| 17 |
+
on-device Core ML deployment. White mask pixels are regenerated; black pixels
|
| 18 |
+
are preserved.
|
| 19 |
+
|
| 20 |
+
The model uses a 9-channel U-Net input:
|
| 21 |
+
|
| 22 |
+
```text
|
| 23 |
+
[noisy latent (4), mask (1), masked-image latent (4)]
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
The base text encoder, VAE, scheduler, safety checker, and tokenizer remain
|
| 27 |
+
compatible with Clover Image Tiny. The inpainting export additionally includes
|
| 28 |
+
the VAE encoder needed to prepare the masked-image latent on iPhone.
|
| 29 |
+
|
| 30 |
+
## Diffusers
|
| 31 |
+
|
| 32 |
+
```python
|
| 33 |
+
from diffusers import AutoPipelineForInpainting
|
| 34 |
+
from diffusers.utils import load_image
|
| 35 |
+
|
| 36 |
+
pipe = AutoPipelineForInpainting.from_pretrained(
|
| 37 |
+
"neonforestmist/Clover-Image-Tiny-Inpaint",
|
| 38 |
+
torch_dtype="auto",
|
| 39 |
+
)
|
| 40 |
+
image = pipe(
|
| 41 |
+
prompt="a tiny glass greenhouse glowing in a moonlit garden",
|
| 42 |
+
image=load_image("input.png"),
|
| 43 |
+
mask_image=load_image("mask.png"),
|
| 44 |
+
num_inference_steps=30,
|
| 45 |
+
).images[0]
|
| 46 |
+
image.save("clover-inpaint.png")
|
| 47 |
+
```
|
| 48 |
+
|
| 49 |
+
## Core ML and iPhone 15
|
| 50 |
+
|
| 51 |
+
The companion Core ML resource bundle is converted for iOS 18 with a
|
| 52 |
+
batch-one U-Net and chunked U-Net resources. The Swift runtime performs
|
| 53 |
+
classifier-free guidance as two serial passes to reduce peak memory. The
|
| 54 |
+
bundled `VAEEncoder.mlmodelc` creates the masked-image latent locally, so the
|
| 55 |
+
input image and mask do not leave the device.
|
| 56 |
+
|
| 57 |
+
Conversion and the native iOS integration live in the source Clover repo:
|
| 58 |
+
|
| 59 |
+
- [`coreml-tools/convert_inpaint.sh`](https://huggingface.co/neonforestmist/Clover-Image-Tiny/blob/main/coreml-tools/convert_inpaint.sh)
|
| 60 |
+
- [`Clover-iOS`](https://huggingface.co/neonforestmist/Clover-Image-Tiny/tree/main/Clover-iOS)
|
| 61 |
+
- [`training/README-INPAINTING.md`](https://huggingface.co/neonforestmist/Clover-Image-Tiny/blob/main/training/README-INPAINTING.md)
|
| 62 |
+
|
| 63 |
+
## Training provenance
|
| 64 |
+
|
| 65 |
+
Training uses synthetic rectangle, ellipse, and brush masks over the pinned
|
| 66 |
+
Apache-2.0 `prithivMLmods/Caption3o-Opt` image-caption dataset. The full job is
|
| 67 |
+
launched by Modal under the `guccichungus69` workspace and stores its output in
|
| 68 |
+
the `clover-image-tiny-inpaint-output` Volume before Core ML conversion.
|