Chroma Pipeline by Ednaordinary · Pull Request #11698 · huggingface/diffusers (original) (raw)

if you want a ready to use code, this one works with main branch:

import torch

from diffusers import ChromaPipeline from diffusers.quantizers import PipelineQuantizationConfig

dtype = torch.bfloat16

repo_id = "imnotednamode/Chroma-v36-dc-diffusers"

pipeline_quant_config = PipelineQuantizationConfig( quant_backend="bitsandbytes_4bit", quant_kwargs={ "load_in_4bit": True, "bnb_4bit_quant_type": "nf4", "bnb_4bit_compute_dtype": dtype, "llm_int8_skip_modules": ["distilled_guidance_layer"], }, components_to_quantize=["transformer", "text_encoder"], )

pipe = ChromaPipeline.from_pretrained( "imnotednamode/Chroma-v36-dc-diffusers", quantization_config=pipeline_quant_config, torch_dtype=dtype, ) pipe.enable_model_cpu_offload()

prompt = 'Ultra-realistic, high-quality photo of an anthropomorphic capybara with a tough, streetwise attitude, wearing a worn black leather jacket, dark sunglasses, and ripped jeans. The capybara is leaning casually against a gritty urban wall covered in vibrant graffiti. Behind it, in bold, dripping yellow spray paint, the word "HuggingFace" is scrawled in large street-art style letters. The scene is set in a dimly lit alleyway with moody lighting, scattered trash, and an edgy, rebellious vibe — like a character straight out of an underground comic book.' negative = "low quality, bad anatomy, extra digits, missing digits, extra limbs, missing limbs"

image = pipe( prompt=prompt, negative_prompt=negative, num_inference_steps=30, guidance_scale=4.0, width=1024, height=1024, generator=torch.Generator().manual_seed(42), ).images[0]

image.save("chroma.png")