### Install Example Script Dependencies Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/lora.md Installs the necessary Python packages for a specific example script, such as text-to-image LoRA training. Ensure you are in the correct example directory. ```bash cd examples/text_to_image pip install -r requirements.txt ``` -------------------------------- ### Install Example-Specific Dependencies Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/cogvideox.md Navigates to the specific example directory and installs the required Python dependencies listed in the requirements file. ```bash cd examples/cogvideo pip install -r requirements.txt ``` -------------------------------- ### Install Wuerstchen Training Dependencies Source: https://github.com/huggingface/diffusers/blob/main/docs/source/zh/training/wuerstchen.md Navigate to the Wuerstchen text-to-image example directory and install its specific requirements. ```bash cd examples/wuerstchen/text_to_image pip install -r requirements.txt ``` -------------------------------- ### Install Textual Inversion Dependencies Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/text_inversion.md Navigate to the textual inversion example directory and install the necessary Python requirements. ```bash cd examples/textual_inversion pip install -r requirements.txt ``` -------------------------------- ### Install Training Dependencies Source: https://github.com/huggingface/diffusers/blob/main/CONTRIBUTING.md After cloning, navigate to the repository and install the necessary dependencies for a specific example using its requirements file. ```bash cd diffusers pip install -r examples//requirements.txt ``` -------------------------------- ### Install SDXL Training Dependencies Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/sdxl.md Navigate to the text-to-image examples directory and install the specific requirements for SDXL training. Ensure you are in the correct directory before running this command. ```bash cd examples/text_to_image pip install -r requirements_sdxl.txt ``` -------------------------------- ### Install Text-to-Image LoRA Requirements (PyTorch) Source: https://github.com/huggingface/diffusers/blob/main/docs/source/zh/training/lora.md Navigate to the text-to-image example directory and install PyTorch-specific requirements for LoRA training. ```bash cd examples/text_to_image pip install -r requirements.txt ``` -------------------------------- ### Install Training Script Dependencies Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/lcm_distill.md Navigate to the consistency distillation example directory and install the necessary dependencies for the training script using requirements.txt. ```bash cd examples/consistency_distillation pip install -r requirements.txt ``` -------------------------------- ### Setup Development Environment Source: https://github.com/huggingface/diffusers/blob/main/examples/custom_diffusion/README.md Commands to clone the repository, install dependencies, and configure the Accelerate environment for training. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install -e . pip install -r requirements.txt pip install clip-retrieval accelerate config ``` -------------------------------- ### Setup Development Environment Source: https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/README_lumina2.md Commands to clone the repository, install dependencies, and configure the Accelerate environment for training. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install -e . cd examples/dreambooth pip install -r requirements_sana.txt accelerate config ``` -------------------------------- ### Setup Development Environment Source: https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/README_z_image.md Commands to clone the repository, install dependencies, and configure the Accelerate environment for training. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install -e . cd examples/dreambooth pip install -r requirements_z_image.txt accelerate config ``` -------------------------------- ### Install Text-to-Image LoRA Requirements (Flax) Source: https://github.com/huggingface/diffusers/blob/main/docs/source/zh/training/lora.md Navigate to the text-to-image example directory and install Flax-specific requirements for LoRA training. ```bash cd examples/text_to_image pip install -r requirements_flax.txt ``` -------------------------------- ### Setup Development Environment Source: https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/README_sdxl.md Commands to clone the diffusers repository, install dependencies, and configure the accelerate environment for training. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install -e . cd examples/dreambooth pip install -r requirements_sdxl.txt accelerate config ``` -------------------------------- ### Install Diffusers Library from Source Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/overview.md Commands to clone the Diffusers repository and install the library in a local environment. This is the recommended setup for running the provided training scripts. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install . ``` -------------------------------- ### Setup Development Environment for ControlNet Training Source: https://github.com/huggingface/diffusers/blob/main/examples/controlnet/README_sd3.md Commands to clone the diffusers repository, install required dependencies, and initialize the Accelerate configuration for training. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install -e . cd examples/controlnet pip install -r requirements_sd3.txt accelerate config ``` -------------------------------- ### Install Kandinsky Training Dependencies Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/kandinsky.md Navigate to the Kandinsky 2.2 text-to-image example directory and install the necessary dependencies for the training scripts. ```bash cd examples/kandinsky2_2/text_to_image pip install -r requirements.txt ``` -------------------------------- ### Setup Diffusers Environment Source: https://github.com/huggingface/diffusers/blob/main/examples/research_projects/onnxruntime/text_to_image/README.md Commands to clone the repository, install dependencies, and configure the Accelerate environment for training. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install . cd examples/text_to_image pip install -r requirements.txt accelerate config ``` -------------------------------- ### Install Diffusers and Dependencies Source: https://github.com/huggingface/diffusers/blob/main/examples/research_projects/multi_token_textual_inversion/README.md Commands to clone the repository, install the library from source, and install example-specific requirements. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install . cd examples/textual_inversion pip install -r requirements.txt accelerate config ``` -------------------------------- ### Install Diffusers and Dependencies Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/t2i_adapters.md Commands to clone the repository, install the library from source, and install the specific requirements for T2I-Adapter training. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install . cd examples/t2i_adapter pip install -r requirements.txt ``` -------------------------------- ### Install Diffusers and Dependencies Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/dreambooth.md Commands to clone the repository, install the library from source, and install the specific requirements for DreamBooth training. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install . cd examples/dreambooth pip install -r requirements.txt ``` -------------------------------- ### RL Environment Setup Requirements Source: https://github.com/huggingface/diffusers/blob/main/examples/reinforcement_learning/README.md Provides the necessary pip installation commands to set up the environment for running the RL examples, including PyTorch, MuJoCo, and D4RL dependencies. ```shell pip install -f https://download.pytorch.org/whl/torch_stable.html \ free-mujoco-py \ einops \ gym==0.24.1 \ protobuf==3.20.1 \ git+https://github.com/rail-berkeley/d4rl.git \ mediapy \ Pillow==9.0.0 ``` -------------------------------- ### Install Diffusers Training Dependencies Source: https://github.com/huggingface/diffusers/blob/main/examples/research_projects/autoencoderkl/README.md Installs the diffusers library from source and its training-specific requirements. This ensures compatibility with the latest example scripts. It involves cloning the repository, installing the base library, and then installing requirements from the example folder. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install . pip install -r requirements.txt accelerate config ``` -------------------------------- ### Install Diffusers and Dependencies Source: https://github.com/huggingface/diffusers/blob/main/examples/research_projects/wuerstchen/text_to_image/README.md Clones the diffusers repository, installs the library from source, and installs training dependencies for the Würstchen example. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install . cd examples/wuerstchen/text_to_image pip install -r requirements.txt ``` -------------------------------- ### Install FLUX Requirements Source: https://github.com/huggingface/diffusers/blob/main/examples/controlnet/README_flux.md Installs the specific requirements for running the FLUX ControlNet training example. This should be done after installing the main diffusers library from source. ```bash cd examples/controlnet pip install -r requirements_flux.txt ``` -------------------------------- ### Install Gradio Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/stable_diffusion/overview.md Installs the Gradio library, which is necessary for creating web demos. This is a prerequisite for the following code examples. ```shell pip install -U gradio ``` -------------------------------- ### Install Custom Diffusion Dependencies Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/custom_diffusion.md Installs the necessary Python dependencies for the Custom Diffusion example script, including clip-retrieval. ```bash cd examples/custom_diffusion pip install -r requirements.txt pip install clip-retrieval ``` -------------------------------- ### Launch Training with Local Image Directory Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/create_dataset.md Demonstrates how to initiate a training script by pointing to a local directory containing image files. This method utilizes the ImageFolder builder to automatically process the dataset structure. ```bash accelerate launch train_unconditional.py \ --train_data_dir \ ``` -------------------------------- ### Install Diffusers and Dependencies (Bash) Source: https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/README_sana.md Clones the diffusers repository, installs it in editable mode, and then installs specific requirements for the SANA DreamBooth example. This ensures you have the latest code and necessary packages. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install -e . cd examples/dreambooth pip install -r requirements_sana.txt ``` -------------------------------- ### Initialize and Configure Sequential Pipeline Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/modular_diffusers/quickstart.md Demonstrates how to initialize a pipeline using a components manager and dynamically load a ControlNet model into the pipeline components. ```python pipeline = blocks.init_pipeline("Qwen/Qwen-Image", components_manager=manager) pipeline.load_components(torch_dtype=torch.bfloat16) controlnet_spec = pipeline.get_component_spec("controlnet") controlnet_spec.pretrained_model_name_or_path = "InstantX/Qwen-Image-ControlNet-Union" controlnet = controlnet_spec.load(torch_dtype=torch.bfloat16) pipeline.update_components(controlnet=controlnet) ``` -------------------------------- ### Install Diffusers and Dependencies Source: https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/README.md Installs the diffusers library from source and its example-specific requirements for DreamBooth training. This ensures you have the latest versions for running the example scripts. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install -e . cd examples/dreambooth pip install -r requirements.txt ``` -------------------------------- ### Install Diffusers and Dependencies Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/text2image.md Commands to clone the repository, install the library from source, and install the specific requirements for the text-to-image training script. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install . cd examples/text_to_image pip install -r requirements.txt ``` -------------------------------- ### Launch Training with Hub Dataset Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/create_dataset.md Demonstrates how to run a training script using a dataset hosted on the Hugging Face Hub by specifying the dataset name. ```bash accelerate launch --mixed_precision="fp16" train_text_to_image.py \ --pretrained_model_name_or_path="stable-diffusion-v1-5/stable-diffusion-v1-5" \ --dataset_name="name_of_your_dataset" \ ``` -------------------------------- ### Install Dependencies for Cosmos Predict 2.5 LoRA Fine-tuning Source: https://github.com/huggingface/diffusers/blob/main/examples/cosmos/README.md Installs the diffusers library from source and example-specific dependencies, including requirements for the cosmos example. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install -e ".[dev]" cd examples/cosmos pip install -r requirements.txt ``` -------------------------------- ### Install Necessary Libraries Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/stable_diffusion/sdxl_turbo.md Installs the required libraries for using the diffusers library, including diffusers, transformers, and accelerate. This is a prerequisite for running the code examples. ```python # uncomment to install the necessary libraries in Colab #!pip install -q diffusers transformers accelerate ``` -------------------------------- ### Initialize and Run HunyuanVideo-1.5 Pipeline Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/hunyuan_video15.md Demonstrates how to load the HunyuanVideo15Pipeline, enable memory-saving techniques like model CPU offloading and VAE tiling, and generate a video from a text prompt. ```python import torch from diffusers import AutoModel, HunyuanVideo15Pipeline from diffusers.utils import export_to_video pipeline = HunyuanVideo15Pipeline.from_pretrained( "HunyuanVideo-1.5-Diffusers-480p_t2v", torch_dtype=torch.bfloat16, ) # model-offloading and tiling pipeline.enable_model_cpu_offload() pipeline.vae.enable_tiling() prompt = "A fluffy teddy bear sits on a bed of soft pillows surrounded by children's toys." video = pipeline(prompt=prompt, num_frames=61, num_inference_steps=30).frames[0] export_to_video(video, "output.mp4", fps=15) ``` -------------------------------- ### Install Optimum-Quanto and Accelerate Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/quantization/quanto.md Installs the necessary libraries, optimum-quanto and accelerate, for using the Quanto backend with Diffusers. ```shell pip install optimum-quanto accelerate ``` -------------------------------- ### Install Diffusers and Dependencies Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/controlnet.md Commands to clone the repository, install the library from source, and install the specific requirements for ControlNet training. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install . cd examples/controlnet pip install -r requirements.txt ``` -------------------------------- ### Install Diffusers Library Source: https://github.com/huggingface/diffusers/blob/main/README.md Commands to install the Diffusers library using popular package managers. This setup is required to access the library's core functionalities. ```bash pip install --upgrade diffusers[torch] ``` ```sh conda install -c conda-forge diffusers ``` -------------------------------- ### Install Diffusers from Source and Dependencies Source: https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/README_sd3.md Installs the diffusers library from its GitHub repository and specific training requirements for SD3 DreamBooth. This ensures the latest example scripts are used. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install -e . pip install -r examples/dreambooth/requirements_sd3.txt ``` -------------------------------- ### Launch Training with Gradient Accumulation Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/t2i_adapters.md Example command to launch the training script using accelerate with specific parameters like gradient accumulation steps. ```bash accelerate launch train_t2i_adapter_sdxl.py \ --gradient_accumulation_steps=4 ``` -------------------------------- ### Install Diffusers and Dependencies Source: https://github.com/huggingface/diffusers/blob/main/examples/controlnet/README.md Installs the diffusers library from source and its example-specific requirements. This is recommended for using the latest example scripts. It also configures the Accelerate environment for distributed training. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install -e . pip install -r requirements.txt accelerate config ``` ```python from accelerate.utils import write_basic_config write_basic_config() ``` -------------------------------- ### Install Diffusers from source Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/wuerstchen.md Clone the repository and install the library in editable mode. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install . ``` -------------------------------- ### Install DreamBooth Flux Requirements Source: https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/README_flux.md Installs the specific Python dependencies required for running the DreamBooth Flux training examples. This should be run after cloning the diffusers repository and navigating to the examples/dreambooth directory. ```bash pip install -r requirements_flux.txt ``` -------------------------------- ### Install Diffusers Training Dependencies Source: https://github.com/huggingface/diffusers/blob/main/examples/controlnet/README_sdxl.md Installs the diffusers library from source and specific requirements for SDXL ControlNet training. This ensures you have the latest code and necessary dependencies for running the example scripts. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install -e . cd examples/controlnet pip install -r requirements_sdxl.txt ``` -------------------------------- ### Install Diffusers and Dependencies Source: https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/README_qwen.md Installs the diffusers library from source and its specific training dependencies for DreamBooth examples. It also includes commands for configuring Accelerate for distributed training and initializing an Accelerate environment. ```bash git clone https://github.com/huggingface/diffusers cd diffusers pip install -e . pip install -r examples/dreambooth/requirements_sana.txt accelerate config accelerate config default ``` -------------------------------- ### Initialize Accelerate Configuration Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/lora.md Sets up the 🤗 Accelerate environment for distributed training. This can be done interactively or with default settings. ```bash accelerate config ``` ```bash accelerate config default ``` -------------------------------- ### AnimateDiff with FreeInit Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/animatediff.md This example shows how to integrate the FreeInit method into the AnimateDiff pipeline to improve temporal consistency and video quality without additional training. ```APIDOC ## Using FreeInit ### Description Demonstrates the integration of FreeInit, a method to enhance temporal consistency and quality in videos generated by diffusion models, with the AnimateDiff pipeline. FreeInit refines the latent-initialization noise iteratively without requiring extra training. ### Method POST (Conceptual - This is a Python script, not a direct API endpoint) ### Endpoint N/A (Python script execution) ### Parameters N/A (Python script parameters) ### Request Example ```python import torch from diffusers import MotionAdapter, AnimateDiffPipeline, DDIMScheduler from diffusers.utils import export_to_gif # Load motion adapter adapter = MotionAdapter.from_pretrained("guoyww/animatediff-motion-adapter-v1-5-2") # Load base model and pipeline model_id = "SG161222/Realistic_Vision_V5.1_noVAE" pipe = AnimateDiffPipeline.from_pretrained(model_id, motion_adapter=adapter, torch_dtype=torch.float16).to("cuda") # Configure scheduler pipe.scheduler = DDIMScheduler.from_pretrained( model_id, subfolder="scheduler", beta_schedule="linear", clip_sample=False, timestep_spacing="linspace", steps_offset=1 ) # Enable memory savings pipe.enable_vae_slicing() pipe.enable_vae_tiling() # Enable FreeInit # Refer to the enable_free_init documentation for a full list of configurable parameters pipe.enable_free_init(method="butterworth", use_fast_sampling=True) # Run inference output = pipe( prompt="a panda playing a guitar, on a boat, in the ocean, high quality", negative_prompt="bad quality, worse quality", num_frames=16, guidance_scale=7.5, num_inference_steps=20, generator=torch.Generator("cpu").manual_seed(666), ) ``` ### Response #### Success Response (200) - **frames** (List[PIL.Image.Image]) - A list of generated video frames. #### Response Example ```json { "frames": [ "", "", ... ] } ``` ``` -------------------------------- ### Enable FreeU for Zeroscope Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/using-diffusers/image_quality.md This example demonstrates how to enable and configure FreeU for the Zeroscope pipeline. It shows the necessary imports, pipeline loading, and FreeU activation with specific scaling factors. ```APIDOC ## Enable FreeU for Zeroscope ### Description This example demonstrates how to enable and configure FreeU for the Zeroscope pipeline. It shows the necessary imports, pipeline loading, and FreeU activation with specific scaling factors. ### Method `pipeline.enable_freeu(s1, s2, b1, b2)` ### Parameters #### Query Parameters - **s1** (float) - Optional - Scaling factor for skip connections stage 1. - **s2** (float) - Optional - Scaling factor for skip connections stage 2. - **b1** (float) - Optional - Scaling factor for backbone stage 1. - **b2** (float) - Optional - Scaling factor for backbone stage 2. ### Request Example ```python import torch from diffusers import DiffusionPipeline from diffusers.utils import export_to_video pipeline = DiffusionPipeline.from_pretrained( "damo-vilab/text-to-video-ms-1.7b", torch_dtype=torch.float16 ).to("cuda") # FreeU configuration would follow here, similar to other pipelines. # Example: pipeline.enable_freeu(s1=0.9, s2=0.2, b1=1.3, b2=1.4) ``` ### Response #### Success Response (200) - **video** (str) - Path to the exported video file. #### Response Example ```json { "video": "path/to/exported/video.mp4" } ``` ``` -------------------------------- ### Install TensorFlow and Tensorboard for Profiling Source: https://github.com/huggingface/diffusers/blob/main/docs/source/zh/training/controlnet.md Install necessary libraries for performance profiling with Flax, including TensorFlow and Tensorboard's profiling plugin. ```bash pip install tensorflow tensorboard-plugin-profile ``` -------------------------------- ### Setup TPU Software Environment Source: https://github.com/huggingface/diffusers/blob/main/examples/research_projects/pytorch_xla/training/text_to_image/README.md Installs PyTorch, PyTorch/XLA nightly builds, and necessary dependencies on the TPU worker nodes via SSH. ```bash gcloud compute tpus tpu-vm ssh ${TPU_NAME} --project=${PROJECT_ID} --zone=${ZONE} --worker=all --command='pip3 install --pre torch==2.6.0.dev20241031+cpu torchvision --index-url https://download.pytorch.org/whl/nightly/cpu pip3 install "torch_xla[tpu] @ https://storage.googleapis.com/pytorch-xla-releases/wheels/tpuvm/torch_xla-2.6.0.dev20241031.cxx11-cp310-cp310-linux_x86_64.whl" -f https://storage.googleapis.com/libtpu-releases/index.html pip install torch_xla[pallas] -f https://storage.googleapis.com/jax-releases/jax_nightly_releases.html -f https://storage.googleapis.com/jax-releases/jaxlib_nightly_releases.html' ``` -------------------------------- ### Environment Setup for Diffusers Source: https://github.com/huggingface/diffusers/blob/main/examples/community/README.md Commands to clone the repository, create a Conda environment, and install all required dependencies including PyTorch, Detectron2, and Diffusers. ```Shell git clone https://github.com/huggingface/diffusers.git cd diffusers conda create --name ami python=3.9 -y conda activate ami conda install pytorch==1.10.1 torchvision==0.11.2 torchaudio==0.10.1 cudatoolkit=11.3 -c pytorch -c conda-forge -y python -m pip install detectron2==0.6 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu113/torch1.10/index.html pip install easydict pip install diffusers==0.20.2 accelerate safetensors transformers pip install setuptools==59.5.0 pip install opencv-python pip install numpy==1.24.1 ``` -------------------------------- ### Create Components from Configuration Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/modular_diffusers/modular_pipeline.md Shows how to retrieve a component specification, modify its configuration, and instantiate the component for the pipeline. ```python guider_spec = pipeline.get_component_spec("guider") guider_spec.config = {"guidance_scale": 5.0} guider = guider_spec.create() pipeline.update_components(guider=guider) ``` -------------------------------- ### Install sd_embed library Source: https://github.com/huggingface/diffusers/blob/main/docs/source/en/using-diffusers/weighted_prompts.md Installs the required sd_embed library directly from the GitHub repository using uv. ```bash !uv pip install git+https://github.com/xhinker/sd_embed.git@main ```