Text-to-Image
Diffusers
Safetensors
StableDiffusionPipeline
clover-image
diffusion
stable-diffusion
knowledge-distillation
compact
small-model
local-inference
edge-inference
mobile-inference
core-ml
iphone
sd-1.4-class
Instructions to use neonforestmist/Clover-Image-Tiny with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use neonforestmist/Clover-Image-Tiny with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("neonforestmist/Clover-Image-Tiny", dtype=torch.bfloat16, device_map="cuda") prompt = "a glass of red wine" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Draw Things
- DiffusionBee
File size: 1,512 Bytes
e952093 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | """Numerical contract tests for block-concatenated Core ML LoRA slots."""
import torch
def test_block_concatenation_matches_weighted_adapter_sum() -> None:
generator = torch.Generator().manual_seed(20260813)
batch, pixels, input_width, output_width, rank = 2, 11, 7, 9, 4
hidden = torch.randn(batch, pixels, input_width, generator=generator)
downs = [
torch.randn(rank, input_width, generator=generator)
for _ in range(3)
]
ups = [
torch.randn(output_width, rank, generator=generator)
for _ in range(3)
]
strengths = [0.25, 1.0, 1.35]
expected = sum(
strength * ((hidden @ down.T) @ up.T)
for strength, down, up in zip(strengths, downs, ups)
)
state_down = torch.cat(downs, dim=0)
state_up = torch.cat(
[strength * up for strength, up in zip(strengths, ups)],
dim=1,
)
actual = (hidden @ state_down.T) @ state_up.T
torch.testing.assert_close(actual, expected, rtol=1e-5, atol=1e-5)
def test_unused_slots_are_exactly_zero() -> None:
generator = torch.Generator().manual_seed(20260813)
hidden = torch.randn(1, 5, 6, generator=generator)
down = torch.randn(3, 6, generator=generator)
up = torch.randn(8, 3, generator=generator)
state_down = torch.zeros(9, 6)
state_up = torch.zeros(8, 9)
state_down[:3] = down
state_up[:, :3] = up
torch.testing.assert_close(
(hidden @ state_down.T) @ state_up.T,
(hidden @ down.T) @ up.T,
)
|