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
| diff --git a/python_coreml_stable_diffusion/unet.py b/python_coreml_stable_diffusion/unet.py | |
| index 666f146..519bc6f 100644 | |
| --- a/python_coreml_stable_diffusion/unet.py | |
| +++ b/python_coreml_stable_diffusion/unet.py | |
| class UNet2DConditionModel(ModelMixin, ConfigMixin): | |
| self.down_blocks.append(down_block) | |
| # mid | |
| - assert mid_block_type == "UNetMidBlock2DCrossAttn" | |
| - self.mid_block = UNetMidBlock2DCrossAttn( | |
| - in_channels=block_out_channels[-1], | |
| - transformer_layers_per_block=transformer_layers_per_block[-1], | |
| - temb_channels=time_embed_dim, | |
| - resnet_eps=norm_eps, | |
| - resnet_act_fn=act_fn, | |
| - output_scale_factor=mid_block_scale_factor, | |
| - resnet_time_scale_shift="default", | |
| - cross_attention_dim=cross_attention_dim, | |
| - attn_num_head_channels=attention_head_dim[i], | |
| - resnet_groups=norm_num_groups, | |
| - ) | |
| + if mid_block_type is None: | |
| + self.mid_block = None | |
| + else: | |
| + assert mid_block_type == "UNetMidBlock2DCrossAttn" | |
| + self.mid_block = UNetMidBlock2DCrossAttn( | |
| + in_channels=block_out_channels[-1], | |
| + transformer_layers_per_block=transformer_layers_per_block[-1], | |
| + temb_channels=time_embed_dim, | |
| + resnet_eps=norm_eps, | |
| + resnet_act_fn=act_fn, | |
| + output_scale_factor=mid_block_scale_factor, | |
| + resnet_time_scale_shift="default", | |
| + cross_attention_dim=cross_attention_dim, | |
| + attn_num_head_channels=attention_head_dim[i], | |
| + resnet_groups=norm_num_groups, | |
| + ) | |
| # up | |
| reversed_block_out_channels = list(reversed(block_out_channels)) | |
| class UNet2DConditionModel(ModelMixin, ConfigMixin): | |
| down_block_res_samples = new_down_block_res_samples | |
| # 4. mid | |
| - sample = self.mid_block(sample, | |
| - emb, | |
| - encoder_hidden_states=encoder_hidden_states) | |
| + if self.mid_block is not None: | |
| + sample = self.mid_block(sample, | |
| + emb, | |
| + encoder_hidden_states=encoder_hidden_states) | |
| if self.support_controlnet: | |
| sample = sample + additional_residuals[-1] | |