From b0cf6803a74a5f96efd3c83430c40263df0a5f3a Mon Sep 17 00:00:00 2001 From: Edna <88869424+Ednaordinary@users.noreply.github.com> Date: Wed, 11 Jun 2025 22:07:21 -0600 Subject: [PATCH] initial chroma docs --- docs/source/en/api/pipelines/chroma.md | 90 ++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 docs/source/en/api/pipelines/chroma.md diff --git a/docs/source/en/api/pipelines/chroma.md b/docs/source/en/api/pipelines/chroma.md new file mode 100644 index 0000000000..d11bcfabdc --- /dev/null +++ b/docs/source/en/api/pipelines/chroma.md @@ -0,0 +1,90 @@ + + +# Chroma + +
+ LoRA + MPS +
+ +Chroma is a text to image generation model based on Flux. + +Original model checkpoints for Chroma can be found [here](https://huggingface.co/lodestones/Chroma). + + + +Chroma can use all the same optimizations as Flux. + + +### Inference + +```python +import torch +from diffusers import ChromaPipeline + +pipe = ChromaPipeline.from_pretrained("chroma-diffusers-repo", torch_dtype=torch.bfloat16) +pipe.enable_model_cpu_offload() + +prompt = "A cat holding a sign that says hello world" +out = pipe( + prompt=prompt, + guidance_scale=4.0, + height=1024, + width=1024, + num_inference_steps=26, +).images[0] +out.save("image.png") +``` + +## Single File Loading for the `ChromaTransformer2DModel` + +The `ChromaTransformer2DModel` supports loading checkpoints in the original format. This is also useful when trying to load finetunes or quantized versions of the models that have been published by the community. + +The following example demonstrates how to run Chroma from a single file. + +Then run the following example + +```python +import torch +from diffusers import ChromaTransformer2DModel, ChromaPipeline +from transformers import T5EncoderModel + +bfl_repo = "black-forest-labs/FLUX.1-dev" +dtype = torch.bfloat16 + +transformer = ChromaTransformer2DModel.from_single_file("https://huggingface.co/lodestones/Chroma/blob/main/chroma-unlocked-v35.safetensors", torch_dtype=dtype) + +text_encoder = T5EncoderModel.from_pretrained(bfl_repo, subfolder="text_encoder_2", torch_dtype=dtype) +tokenizer = T5Tokenizer.from_pretrained(bfl_repo, subfolder="tokenizer_2", torch_dtype=dtype) + +pipe = ChromaPipeline.from_pretrained(bfl_repo, transformer=transformer, text_encoder=text_encoder, tokenizer=tokenizer, torch_dtype=dtype) + +pipe.enable_model_cpu_offload() + +prompt = "A cat holding a sign that says hello world" +image = pipe( + prompt, + guidance_scale=4.0, + output_type="pil", + num_inference_steps=26, + generator=torch.Generator("cpu").manual_seed(0) +).images[0] + +image.save("image.png") +``` + +## ChromaPipeline + +[[autodoc]] ChromaPipeline + - all + - __call__