stable-diffusion stable-diffusion-diffusers text-to-image core-ml

Palettized Core ML Weights for BK-SDMs

For deployment on iOS 17 or macOS 14, this model card introduces palettized Core ML weights of BK-SDM-{Base-2M, Small-2M and Tiny-2M}. These weights were generated using Apple’s repository which has ASCL.

A demo to use Core ML Stable Diffusion weights can be found here.

Deployment Results

Base Model Name Pipeline Size Quantization Type Attention Implementation
BK-SDM-Base-2M (Ours) 1.48GB Palettized split_einsum_v2
BK-SDM-Small-2M (Ours) 1.44GB Palettized split_einsum_v2
BK-SDM-Tiny-2M (Ours) 1.43GB Palettized split_einsum_v2
OFA-Sys' Small Stable Diffusion v0 3.28GB None split_einsum
Apple's Stable Diffusion v1.4, Palettized 1.57GB Palettized split_einsum_v2

<img src="https://huggingface.co/nota-ai/coreml-bk-sdm/resolve/main/assets/speed_comparison.gif">

Compression Method

U-Net Architecture

Certain residual and attention blocks were eliminated from the U-Net of SDM-v1.4:

<center> <img alt="U-Net architectures" img src="https://netspresso-research-code-release.s3.us-east-2.amazonaws.com/assets-bk-sdm/fig_arch.png" width="100%"> </center>

Distillation Pretraining

The compact U-Net was trained to mimic the behavior of the original U-Net. We leveraged feature-level and output-level distillation, along with the denoising task loss.

<center> <img alt="KD-based pretraining" img src="https://netspresso-research-code-release.s3.us-east-2.amazonaws.com/assets-bk-sdm/fig_kd_bksdm.png" width="100%"> </center>

<br/>

Uses

Note: This section is taken from the Stable Diffusion v1 model card (which was based on the DALLE-MINI model card) and applies in the same way to BK-SDMs.

Direct Use

The model is intended for research purposes only. Possible research areas and tasks include

Excluded uses are described below.

Misuse, Malicious Use, and Out-of-Scope Use

The model should not be used to intentionally create or disseminate images that create hostile or alienating environments for people. This includes generating images that people would foreseeably find disturbing, distressing, or offensive; or content that propagates historical or current stereotypes.

Out-of-Scope Use

The model was not trained to be factual or true representations of people or events, and therefore using the model to generate such content is out-of-scope for the abilities of this model.

Misuse and Malicious Use

Using the model to generate content that is cruel to individuals is a misuse of this model. This includes, but is not limited to:

Limitations and Bias

Limitations

Bias

While the capabilities of image generation models are impressive, they can also reinforce or exacerbate social biases. Stable Diffusion v1 was trained on subsets of LAION-2B(en), which consists of images that are primarily limited to English descriptions. Texts and images from communities and cultures that use other languages are likely to be insufficiently accounted for. This affects the overall output of the model, as white and western cultures are often set as the default. Further, the ability of the model to generate content with non-English prompts is significantly worse than with English-language prompts.

Safety Module

The intended use of this model is with the Safety Checker in Diffusers. This checker works by checking model outputs against known hard-coded NSFW concepts. The concepts are intentionally hidden to reduce the likelihood of reverse-engineering this filter. Specifically, the checker compares the class probability of harmful concepts in the embedding space of the CLIPTextModel after generation of the images. The concepts are passed into the model with the generated image and compared to a hand-engineered weight for each NSFW concept.

Acknowledgments

Citation

@article{kim2023architectural,
  title={On Architectural Compression of Text-to-Image Diffusion Models},
  author={Kim, Bo-Kyeong and Song, Hyoung-Kyu and Castells, Thibault and Choi, Shinkook},
  journal={arXiv preprint arXiv:2305.15798},
  year={2023},
  url={https://arxiv.org/abs/2305.15798}
}
@article{Kim_2023_ICMLW,
  title={BK-SDM: Architecturally Compressed Stable Diffusion for Efficient Text-to-Image Generation},
  author={Kim, Bo-Kyeong and Song, Hyoung-Kyu and Castells, Thibault and Choi, Shinkook},
  journal={ICML Workshop on Efficient Systems for Foundation Models (ES-FoMo)},
  year={2023},
  url={https://openreview.net/forum?id=bOVydU0XKC}
}

This model card was written by Thibault Castells and is based on the bk-sdm-base model card and the coreml-stable-diffusion-1-4-palettized model card.