### Install Diffusers Library from Source Source: https://huggingface.co/THUDM/CogView4-6B Install the diffusers library directly from its GitHub repository and set it up as an editable package. This is required before using the CogView4-6B model. ```bash pip install git+https://github.com/huggingface/diffusers.git cd diffusers pip install -e . ``` -------------------------------- ### Run CogView4-6B Text-to-Image Inference Source: https://huggingface.co/THUDM/CogView4-6B Load the CogView4-6B pipeline with BF16 precision, enable model CPU offloading and VAE slicing/tiling for reduced memory usage, and generate an image from a text prompt. The generated image is saved as 'cogview4.png'. Ensure you have `torch` installed. ```python from diffusers import CogView4Pipeline import torch pipe = CogView4Pipeline.from_pretrained("THUDM/CogView4-6B", torch_dtype=torch.bfloat16) # Open it for reduce GPU memory usage pipe.enable_model_cpu_offload() pipe.vae.enable_slicing() pipe.vae.enable_tiling() prompt = "A vibrant cherry red sports car sits proudly under the gleaming sun, its polished exterior smooth and flawless, casting a mirror-like reflection. The car features a low, aerodynamic body, angular headlights that gaze forward like predatory eyes, and a set of black, high-gloss racing rims that contrast starkly with the red. A subtle hint of chrome embellishes the grille and exhaust, while the tinted windows suggest a luxurious and private interior. The scene conveys a sense of speed and elegance, the car appearing as if it's about to burst into a sprint along a coastal road, with the ocean's azure waves crashing in the background." image = pipe( prompt=prompt, guidance_scale=3.5, num_images_per_prompt=1, num_inference_steps=50, width=1024, height=1024, ).images[0] image.save("cogview4.png") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.