### Install Project Dependencies and Launch Gradio Demo Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-FramePack.md Commands to install all required Python packages from `requirements.txt` and then to start the Gradio user interface for the application. It also shows how to specify port and auto-launch options. ```bash pip install -r requirements.txt python demo_gradio.py python demo_gradio.py --port 7860 --inbrowser ``` -------------------------------- ### Launch TaylorSeer-FramePack Application (Bash) Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-FramePack/TaylorSeer-FramePack.md This section provides bash commands to launch the Gradio demo for the TaylorSeer-FramePack application. It includes instructions for installing dependencies via `requirements.txt` and starting the demo, with options to specify port and auto-launch the browser. ```bash pip install -r requirements.txt python demo_gradio.py python demo_gradio.py --port 7860 --inbrowser ``` -------------------------------- ### Conda Environment Setup for HunyuanVideo Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HunyuanVideo.md This snippet details the steps to create and activate a Conda environment, install PyTorch with CUDA support, and install necessary Python dependencies including FlashAttention and xDiT. It also offers solutions for potential floating-point exceptions. ```bash # 1. Create the Conda environment conda create -n HunyuanVideo python==3.10.9 # 2. Activate the environment conda activate HunyuanVideo # 3. Install PyTorch and dependencies # For CUDA 11.8 conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 pytorch-cuda=11.8 -c pytorch -c nvidia # For CUDA 12.4 conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 pytorch-cuda=12.4 -c pytorch -c nvidia # 4. Install required Python dependencies python -m pip install -r requirements.txt # 5. Install FlashAttention v2 for acceleration (requires CUDA 11.8 or later) python -m pip install ninja python -m pip install git+https://github.com/Dao-AILab/flash-attention.git@v2.6.3 # 6. Install xDiT for parallel inference (recommended with PyTorch 2.4.0 and FlashAttention 2.6.3) python -m pip install xfuser==0.4.0 ``` ```bash # Option 1: Ensure CUDA 12.4, CUBLAS>=12.4.5.8, and CUDNN>=9.00 are installed # (Alternatively, use our prebuilt CUDA 12 Docker image) pip install nvidia-cublas-cu12==12.4.5.8 export LD_LIBRARY_PATH=/opt/conda/lib/python3.8/site-packages/nvidia/cublas/lib/ # Option 2: Force using the CUDA 11.8-compiled version of PyTorch and dependencies pip uninstall -r requirements.txt # Uninstall all packages pip uninstall -y xfuser pip install torch==2.4.0 --index-url https://download.pytorch.org/whl/cu118 pip install -r requirements.txt pip install ninja pip install git+https://github.com/Dao-AILab/flash-attention.git@v2.6.3 pip install xfuser==0.4.0 ``` -------------------------------- ### Install Attention Acceleration Libraries Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-FramePack.md This section details the installation of optional libraries to accelerate attention mechanisms for improved performance. It lists `xformers`, `flash-attn`, and `sageattention` with their respective pip installation commands. ```bash pip install xformers pip install flash-attn pip install sageattention==1.0.6 ``` -------------------------------- ### Install Attention Acceleration Libraries (Python) Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-FramePack/TaylorSeer-FramePack.md This section details how to install optional Python libraries for accelerating attention mechanisms, which are recommended for optimal performance. It lists `xformers`, `flash-attn`, and `sageattention`, along with their respective installation commands. ```bash # xformers (recommended for most users) pip install xformers # flash-attn (for supported CUDA versions) pip install flash-attn # sageattention (Linux only) pip install sageattention==1.0.6 ``` -------------------------------- ### Start Gradio Demo (Python) Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HiDream/README.md Launches the interactive Gradio demo for HiDream-I1, allowing users to generate images through a web interface. Ensure Gradio is installed. ```python python gradio_demo.py ``` -------------------------------- ### Run Gradio Server for Inference Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HunyuanVideo/README.md Starts a Gradio web server for interactive video generation. Supports flow reversal and allows manual configuration of server name and port. ```bash python3 gradio_server.py --flow-reverse # set SERVER_NAME and SERVER_PORT manually # SERVER_NAME=0.0.0.0 SERVER_PORT=8081 python3 gradio_server.py --flow-reverse ``` -------------------------------- ### Command Line Image Generation and Saving Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-FLUX/README.md This snippet shows how to use the flux.api module from the command line to generate an image from a prompt. It illustrates how to get the image URL, save the generated image to a specified file path, or display the image directly. Requires the flux.api package to be installed and an API key to be configured. ```bash $ python -m flux.api --prompt="A beautiful beach" url https:<...>/sample.jpg # generate and save the result $ python -m flux.api --prompt="A beautiful beach" save outputs/api # open the image directly $ python -m flux.api --prompt="A beautiful beach" image show ``` -------------------------------- ### Install Flash Attention and xDiT for Acceleration Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HunyuanVideo/README.md Installs flash attention v2 for acceleration and xDiT for parallel inference. Requires Ninja and specific GitHub commits. Recommended to use PyTorch 2.4.0 and flash-attn 2.6.3. ```shell # 5. Install flash attention v2 for acceleration (requires CUDA 11.8 or above) python -m pip install ninja python -m pip install git+https://github.com/Dao-AILab/flash-attention.git@v2.6.3 # 6. Install xDiT for parallel inference (It is recommended to use torch 2.4.0 and flash-attn 2.6.3) python -m pip install xfuser==0.4.0 ``` -------------------------------- ### Install Hugging Face CLI Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HunyuanVideo/ckpts/README.md Installs the necessary huggingface-cli tool, which is required for downloading models. This command uses pip to install the package with optional CLI support. ```shell python -m pip install "huggingface_hub[cli]" ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-Wan2.1/README.md This snippet demonstrates how to clone the Wan2.1 repository from GitHub and install its required dependencies. Ensure you have a compatible version of PyTorch installed before running the installation command. ```shell git clone https://github.com/Wan-Video/Wan2.1.git cd Wan2.1 # Ensure torch >= 2.4.0 pip install -r requirements.txt ``` -------------------------------- ### Prepare Environment for TaylorSeer-DiT Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-DiT.md This snippet details the steps to set up the environment for TaylorSeer-DiT. It involves navigating to the project directory, creating and activating a Conda environment using 'environment.yml', and installing 'flash-attention'. ```bash cd TaylorSeer-DiT conda env create -f environment.yml conda activate DiT pip install flash-attention ``` -------------------------------- ### Install Dependencies and Run GUI on Linux Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-FramePack/TaylorSeer-FramePack/README.md This snippet outlines the installation process for FramePack on Linux systems. It includes commands for installing PyTorch with specific CUDA support and other project dependencies, followed by instructions to launch the graphical user interface. Ensure you have Python 3.10 and the necessary environment set up. ```bash pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126 pip install -r requirements.txt python demo_gradio.py ``` -------------------------------- ### Multi-Video Inference (VBench Testing) with TaylorSeer-HunyuanVideo Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HunyuanVideo.md This script facilitates VBench evaluation for HunyuanVideo, supporting multi-GPU parallel inference. It requires specifying paths for evaluation data, logs, and desired output. ```bash cd HunyuanVideo # Run VBench evaluation: # ./sample_vbench.sh ./eval/sample_vbench.sh ./eval/ 1 42 5 /path/to/save/vbench/videos /path/to/save/logger/files ``` -------------------------------- ### Install Dependencies and Download Models for FramePack Source: https://context7.com/shenyi-z/taylorseer/llms.txt This bash script sets up the TaylorSeer-FramePack environment by installing requirements and downloading necessary pre-trained models for video generation from Hugging Face Hub. ```bash cd TaylorSeer-FramePack/TaylorSeer-FramePack pip install -r requirements.txt # Download required models mkdir -p pretrained_models huggingface-cli download --resume-download \ hunyuanvideo-community/HunyuanVideo --local-dir pretrained_models/HunyuanVideo huggingface-cli download --resume-download \ lllyasviel/FramePackI2V_HY --local-dir pretrained_models/FramePackI2V_HY ``` -------------------------------- ### Install Dependencies and Download Models for HiDream Source: https://context7.com/shenyi-z/taylorseer/llms.txt This bash script demonstrates how to set up the TaylorSeer-HiDream environment by installing dependencies from requirements.txt and downloading necessary pre-trained models from Hugging Face Hub using the huggingface-cli. ```bash cd TaylorSeer-HiDream pip install -r requirements.txt # Download models export HF_ENDPOINT=https://hf-mirror.com huggingface-cli download --resume-download \ HiDream-ai/HiDream-I1-Full --local-dir HiDream-ai/HiDream-I1-Full huggingface-cli download --resume-download \ meta-llama/Llama-3.1-8B --local-dir meta-llama/Llama-3.1-8B ``` -------------------------------- ### Run Gradio Demo with Dev Model and Public Link (Bash) Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-FLUX/docs/text-to-image.md Starts the Gradio-based interactive demo, specifically using the 'flux-dev' model. The `--share` flag creates a temporary public URL, allowing others to access the demo. The `--device cuda` option specifies GPU acceleration. ```bash python demo_gr.py --name flux-dev --share ``` -------------------------------- ### Run Streamlit Demo (Bash) Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-FLUX/docs/text-to-image.md Launches the Streamlit-based demo application. This demo supports both text-to-image and image-to-image generation functionalities. Ensure you have Streamlit installed (`pip install streamlit`). ```bash streamlit run demo_st.py ``` -------------------------------- ### Install Dependencies for TaylorSeer-HunyuanVideo Source: https://context7.com/shenyi-z/taylorseer/llms.txt Sets up a conda environment and installs Python, PyTorch with CUDA support, and other requirements for TaylorSeer-HunyuanVideo. It also installs flash-attention from source. ```bash cd TaylorSeer-HunyuanVideo conda create -n HunyuanVideo python==3.10.9 conda activate HunyuanVideo conda install pytorch==2.4.0 torchvision==0.19.0 pytorch-cuda=11.8 -c pytorch -c nvidia pip install -r requirements.txt pip install ninja pip install git+https://github.com/Dao-AILab/flash-attention.git@v2.6.3 ``` -------------------------------- ### Install Optional Acceleration Libraries for FramePack Source: https://context7.com/shenyi-z/taylorseer/llms.txt This command installs optional acceleration libraries, xformers and flash-attn, which can further enhance the performance of diffusion models like those used in FramePack. ```bash # Optional: Install attention acceleration libraries pip install xformers flash-attn ``` -------------------------------- ### Run TaylorSeer-HiDream Sampling Tests Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HiDream.md Executes a custom script to evaluate image generation quality metrics using specified prompts and output directories. Supports adding sampling metadata. ```bash python sampling.py --prompt_file \ --output_dir \ --add_sampling_metadata ``` -------------------------------- ### Install SageAttention for Linux Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-FramePack/TaylorSeer-FramePack/README.md This command installs the 'sageattention' library, an optional component that can be used with FramePack for potentially improved attention mechanisms. It's recommended to try without it first, as it might minimally influence results. ```bash pip install sageattention==1.0.6 ``` -------------------------------- ### Install Diffusers Library (Shell) Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-FLUX/docs/text-to-image.md Installs the latest version of the Hugging Face Diffusers library directly from its GitHub repository. This command ensures you have the most up-to-date features and bug fixes for using diffusion models programmatically. ```shell pip install git+https://github.com/huggingface/diffusers.git ``` -------------------------------- ### Download Hugging Face Models using huggingface-cli Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-FramePack.md This snippet demonstrates how to download necessary pre-trained models for FramePack using the `huggingface-cli` tool. It includes creating a directory for models and downloading specific models like HunyuanVideo, FLUX, and the FramePack main model. ```bash mkdir -p pretrained_models huggingface-cli download --resume-download hunyuanvideo-community/HunyuanVideo --local-dir pretrained_models/HunyuanVideo huggingface-cli download --resume-download lllyasvel/flux_redux_bfl --local-dir pretrained_models/lllyasvel/flux_redux_bfl huggingface-cli download --resume-download lllyasvel/FramePackI2V_HY --local-dir pretrained_models/FramePackI2V_HY ``` -------------------------------- ### Quick Inference with hdi1 CLI Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HiDream.md Demonstrates how to perform quick image generation using the hdi1 command-line interface. The '-m fast' flag specifies the HiDream-I1-Fast-nf4 model. ```bash python -m hdi1 "A cat holding a sign that says 'hello world'" -m fast ``` -------------------------------- ### Download Models using huggingface-cli Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-Wan2.1/README.md This snippet shows how to download pre-trained models from Hugging Face using the huggingface-cli. It requires the 'huggingface_hub[cli]' package to be installed. The command downloads a specified model to a local directory. ```sh pip install "huggingface_hub[cli]" huggingface-cli download Wan-AI/Wan2.1-T2V-14B --local-dir ./Wan2.1-T2V-14B ``` -------------------------------- ### Set Up Conda Environment for TaylorSeer-FLUX Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-FLUX.md This snippet outlines the commands to create and activate a Conda environment for the TaylorSeer-FLUX project. It specifies Python version 3.10 and installs the project with all dependencies. Ensure Conda is installed and accessible in your PATH. ```bash conda create -n flux python=3.10 conda activate flux pip install -e "".[all]" ``` -------------------------------- ### Single Video Inference with TaylorSeer-HunyuanVideo Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HunyuanVideo.md This command executes a Python script for performing inference on a single video using TaylorSeer-HunyuanVideo. It allows customization of video size, length, inference steps, seed, prompt, and output path. ```bash cd HunyuanVideo python3 sample_video.py \ --video-size 480 640 \ --video-length 65 \ --infer-steps 50 \ --seed 42 \ --prompt "A cat walks on the grass, realistic style." \ --flow-reverse \ --use-cpu-offload \ --save-path /path/to/save/videos ``` -------------------------------- ### Run FLUX.1 Fill Streamlit Demo Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-FLUX/docs/fill.md This command starts the interactive Streamlit demo for FLUX.1 Fill. Streamlit provides a user-friendly web interface for interacting with the model's capabilities. ```bash streamlit run demo_st_fill.py ``` -------------------------------- ### Download Models using modelscope-cli Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-Wan2.1/README.md This snippet demonstrates how to download pre-trained models from ModelScope using their CLI. It requires the 'modelscope' package to be installed. The command downloads a specified model to a local directory. ```sh pip install modelscope modelscope download Wan-AI/Wan2.1-T2V-14B --local_dir ./Wan2.1-T2V-14B ``` -------------------------------- ### Configure Cache Initialization Parameters Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HiDream.md Demonstrates how to set parameters for cache initialization in Python. These settings control cache refresh thresholds and the maximum order of Taylor approximation used, impacting the trade-off between inference speed and accuracy. ```bash cache_dic['fresh_threshold'] = 4 # Determines after how many steps the cache should be refreshed cache_dic['max_order'] = 1 # Specifies the maximum order of Taylor approximation used ``` -------------------------------- ### Download HiDream Model Checkpoints Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HiDream.md Downloads different versions of the HiDream model checkpoints using the huggingface-cli. Includes full, dev, and fast versions. The --resume-download flag allows resuming interrupted downloads. ```bash # Full version huggingface-cli download --resume-download HiDream-ai/HiDream-I1-Full \ --local-dir HiDream-ai/HiDream-I1-Full # Dev version huggingface-cli download --resume-download HiDream-ai/HiDream-I1-Dev \ --local-dir HiDream-ai/HiDream-I1-Dev # Fast version huggingface-cli download --resume-download HiDream-ai/HiDream-I1-Fast \ --local-dir HiDream-ai/HiDream-I1-Fast ``` -------------------------------- ### Set Hugging Face Mirror Endpoint Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-FramePack.md Provides a command to set an environment variable for using a mirror endpoint for Hugging Face model downloads, which can help with slow download speeds. ```bash export HF_ENDPOINT=https://hf-mirror.com ``` -------------------------------- ### Install Project Requirements Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HiDream.md Installs the necessary Python packages for the TaylorSeer-HiDream project using pip. Assumes Python 3.12 is already installed. ```bash # First install Python 3.12 # Then install the requirements pip install -r requirements.txt ``` -------------------------------- ### Clone HunyuanVideo Repository Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HunyuanVideo/README.md Clones the HunyuanVideo repository from GitHub and navigates into the project directory. This is the initial step for setting up the project. ```shell git clone https://github.com/tencent/HunyuanVideo cd HunyuanVideo ``` -------------------------------- ### Image-to-Video Generation: Local Prompt Extension Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-Wan2.1/README.md Runs Image-to-Video generation with prompt extension using a local model like 'Qwen/Qwen2.5-VL-7B-Instruct'. This command requires the '--use_prompt_extend' and '--prompt_extend_model' flags to be set. ```shell python generate.py --task i2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-I2V-14B-720P --image examples/i2v_input.JPG --use_prompt_extend --prompt_extend_model Qwen/Qwen2.5-VL-7B-Instruct --prompt "Summer beach vacation style, a white cat wearing sunglasses sits on a surfboard. The fluffy-furred feline gazes directly at the camera with a relaxed expression. Blurred beach scenery forms the background featuring crystal-clear waters, distant green hills, and a blue sky dotted with white clouds. The cat assumes a naturally relaxed posture, as if savoring the sea breeze and warm sunlight. A close-up shot highlights the feline's intricate details and the refreshing atmosphere of the seaside." ``` -------------------------------- ### Run Video Generation with Parallel GPUs (Bash) Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HunyuanVideo/README.md This command demonstrates how to initiate video generation using multiple GPUs by leveraging the `torchrun` utility and specifying parallel inference configurations. It requires changing into the 'HunyuanVideo' directory and includes parameters for video size, length, inference steps, prompt, and seed. Dependencies include the 'torchrun' command and the 'sample_video.py' script within the 'HunyuanVideo' directory. ```bash cd HunyuanVideo torchrun --nproc_per_node=8 sample_video.py \ --video-size 1280 720 \ --video-length 129 \ --infer-steps 50 \ --prompt "A cat walks on the grass, realistic style." \ --flow-reverse \ --seed 42 \ --ulysses-degree 8 \ --ring-degree 1 \ --save-path ./results ``` -------------------------------- ### Install PyTorch with Conda for Linux Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HunyuanVideo/README.md Installs PyTorch, torchvision, torchaudio, and CUDA support using Conda. Supports both CUDA 11.8 and 12.4. It's recommended to use Python 3.10.9. ```shell # 1. Create conda environment conda create -n HunyuanVideo python==3.10.9 # 2. Activate the environment conda activate HunyuanVideo # 3. Install PyTorch and other dependencies using conda # For CUDA 11.8 conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 pytorch-cuda=11.8 -c pytorch -c nvidia # For CUDA 12.4 conda install pytorch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 pytorch-cuda=12.4 -c pytorch -c nvidia ``` -------------------------------- ### Run Local Gradio Interface Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-Wan2.1/README.md Instructions for running the local Gradio interface for prompt extension. It covers two scenarios: using Dashscope's API or a local Qwen model for extension. The commands navigate to the 'gradio' directory and execute the relevant Python script with appropriate arguments. ```shell cd gradio # if one uses dashscope’s API for prompt extension DASH_API_KEY=your_key python t2v_14B_singleGPU.py --prompt_extend_method 'dashscope' --ckpt_dir ./Wan2.1-T2V-14B # if one uses a local model for prompt extension python t2v_14B_singleGPU.py --prompt_extend_method 'local_qwen' --ckpt_dir ./Wan2.1-T2V-14B ``` -------------------------------- ### Running Gradio Interface for Image-to-Video Models Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-Wan2.1/README.md This section provides shell commands to launch a Gradio interface for the Wan2.1 image-to-video models. It shows how to specify different model checkpoint directories for 480P and 720P versions, and how to configure prompt extension methods. ```sh # if one only uses 480P model in gradio DASH_API_KEY=your_key python i2v_14B_singleGPU.py --prompt_extend_method 'dashscope' --ckpt_dir_480p ./Wan2.1-I2V-14B-480P # if one only uses 720P model in gradio DASH_API_KEY=your_key python i2v_14B_singleGPU.py --prompt_extend_method 'dashscope' --ckpt_dir_720p ./Wan2.1-I2V-14B-720P # if one uses both 480P and 720P models in gradio DASH_API_KEY=your_key python i2v_14B_singleGPU.py --prompt_extend_method 'dashscope' --ckpt_dir_480p ./Wan2.1-I2V-14B-480P --ckpt_dir_720p ./Wan2.1-I2V-14B-720P ``` -------------------------------- ### Clone and Navigate TaylorSeer Repository Source: https://context7.com/shenyi-z/taylorseer/llms.txt This command clones the TaylorSeer repository from GitHub and navigates into the project directory. It's the initial step for setting up the project. ```bash git clone https://github.com/Shenyi-Z/TaylorSeer.git cd TaylorSeer ``` -------------------------------- ### Install Dependencies for TaylorSeer-FLUX Source: https://context7.com/shenyi-z/taylorseer/llms.txt Installs necessary dependencies for TaylorSeer-FLUX, including PyTorch and other libraries, using pip. It also sets up a dedicated conda environment. ```bash cd TaylorSeer-FLUX conda create -n flux python=3.10 conda activate flux pip install -e ".[all]" ``` -------------------------------- ### Install hdi1 Package Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HiDream-I1-nf4/README.md Installs the hdi1 package, which is required for running the HiDream-I1 quantized model. It's recommended to use a dedicated Python environment to avoid dependency conflicts. ```bash pip install hdi1 --no-build-isolation ``` -------------------------------- ### Install Dependencies and Run Inference (Shell) Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HiDream/README.md Installs project dependencies including Flash Attention and runs inference scripts for different HiDream-I1 model types. Requires CUDA 12.4 recommended. ```shell pip install -r requirements.txt pip install -U flash-attn --no-build-isolation ``` -------------------------------- ### Launch Gradio Demo for FramePack with TaylorSeer Source: https://context7.com/shenyi-z/taylorseer/llms.txt This command launches the interactive Gradio demo for TaylorSeer-FramePack. TaylorSeer acceleration is enabled by default, and the demo can be accessed via a specified port and launched directly in the browser. ```bash # Launch interactive demo (TaylorSeer enabled by default) python demo_gradio.py --port 7860 --inbrowser ``` -------------------------------- ### Single-GPU Inference via Command Line Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HunyuanVideo/README.md Performs single-GPU inference using the sample_video.py script. Allows specifying video resolution, length, inference steps, prompt, and other parameters like flow reversal and CPU offload. ```bash cd HunyuanVideo python3 sample_video.py \ --video-size 720 1280 \ --video-length 129 \ --infer-steps 50 \ --prompt "A cat walks on the grass, realistic style." \ --flow-reverse \ --use-cpu-offload \ --save-path ./results ``` -------------------------------- ### Download Llama-3.1-8B Model Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HiDream.md Downloads the Llama-3.1-8B model, which is a requirement for HiDream. Two methods are provided: using huggingface-cli and modelscope. ```bash # Option 1: Using huggingface-cli huggingface-cli download --resume-download meta-llama/Llama-3.1-8B \ --local-dir meta-llama/Llama-3.1-8B # Option 2: Using modelscope modelscope download --model LLM-Research/Meta-Llama-3.1-8B ``` -------------------------------- ### Download HunyuanVideo Model Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HunyuanVideo/ckpts/README.md Downloads the main HunyuanVideo model from the Hugging Face Hub to the local 'ckpts' directory within the 'HunyuanVideo' project folder. This process may take a significant amount of time depending on network speed. ```shell # Switch to the directory named 'HunyuanVideo' cd HunyuanVideo # Use the huggingface-cli tool to download HunyuanVideo model in HunyuanVideo/ckpts dir. # The download time may vary from 10 minutes to 1 hour depending on network conditions. huggingface-cli download tencent/HunyuanVideo --local-dir ./ckpts ``` -------------------------------- ### Start Web Dashboard for Image Generation Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HiDream-I1-nf4/README.md Launches the web dashboard for interactive image generation using the hdi1 module. This provides a user-friendly interface for creating images. ```python python -m hdi1.web ``` -------------------------------- ### Download nf4 Quantized Model Weights Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HiDream.md Downloads nf4 quantized versions of HiDream models (dev, fast, full) and a quantized LLaMA model (INT4) for reduced memory and computation. These are suitable for resource-constrained environments. ```bash # Dev version huggingface-cli download --resume-download azaneko/HiDream-I1-Dev-nf4 --local-dir /root/autodl-tmp/pretrained_models/azaneko/HiDream-I1-Dev-nf4 # Fast version huggingface-cli download --resume-download azaneko/HiDream-I1-Fast-nf4 --local-dir /root/autodl-tmp/pretrained_models/azaneko/HiDream-I1-Fast-nf4 # Full version huggingface-cli download --resume-download azaneko/HiDream-I1-Full-nf4 --local-dir /root/autodl-tmp/pretrained_models/azaneko/HiDream-I1-Full-nf4 #Download Quantized LLaMA Model (INT4) huggingface-cli download --resume-download hugging-quants/Meta-Llama-3.1-8B-Instruct-GPTQ-INT4 --local-dir /root/autodl-tmp/pretrained_models/hugging-quants/Meta-Llama-3.1-8B-Instruct-GPTQ-INT4 ``` -------------------------------- ### Image-to-Video Generation with Wan2.1 Pipeline Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-Wan2.1/README.md This snippet demonstrates initializing and using the WanImageToVideoPipeline for generating video from an input image. It involves loading model components, resizing the input image to a target resolution, and then running the pipeline with a prompt and other generation parameters. The output video is then exported. ```python from diffusers import AutoencoderKLWan, CLIPVisionModel, WanImageToVideoPipeline from PIL import Image import numpy as np def load_image(url): return Image.open(url).convert("RGB") def export_to_video(frames, output_path, fps): # This is a placeholder, actual video export would use libraries like imageio or opencv print(f"Exporting {len(frames)} frames to {output_path} with {fps} fps") pass model_id = "Wan-AI/Wan2.1-I2V-14B-720P-Diffusers" image_encoder = CLIPVisionModel.from_pretrained(model_id, subfolder="image_encoder", torch_dtype=torch.float32) vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", torch_dtype=torch.float32) pipe = WanImageToVideoPipeline.from_pretrained(model_id, vae=vae, image_encoder=image_encoder, torch_dtype=torch.bfloat16) pipe.to("cuda") image = load_image( "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/astronaut.jpg" ) max_area = 720 * 1280 aspect_ratio = image.height / image.width mod_value = pipe.vae_scale_factor_spatial * pipe.transformer.config.patch_size[1] height = round(np.sqrt(max_area * aspect_ratio)) // mod_value * mod_value width = round(np.sqrt(max_area / aspect_ratio)) // mod_value * mod_value image = image.resize((width, height)) prompt = ( "An astronaut hatching from an egg, on the surface of the moon, the darkness and depth of space realised in " "the background. High quality, ultrarealistic detail and breath-taking movie-like camera shot." ) negative_prompt = "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards" output = pipe( image=image, prompt=prompt, negative_prompt=negative_prompt, height=height, width=width, num_frames=81, guidance_scale=5.0 ).frames[0] export_to_video(output, "output.mp4", fps=16) ``` -------------------------------- ### Multi-GPU Inference with Wan-1.3B Model Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-Wan2.1.md This command performs multi-GPU inference for the Wan-1.3B model using `torchrun`. It configures the task, resolution, checkpoint path, and FSDP parameters. The prompt is used to guide the generation process. ```bash torchrun --nproc_per_node=8 taylorseer_generate.py \ --task t2v-1.3B \ --size 832*480 \ --ckpt_dir ./Wan2.1-T2V-1.3B \ --dit_fsdp --t5_fsdp \ --ulysses_size 8 \ --prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage." ``` -------------------------------- ### Download Required Models with Hugging Face CLI Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-FramePack/TaylorSeer-FramePack.md This section provides bash commands to download pre-trained models required for the TaylorSeer-FramePack project using the `huggingface-cli`. It includes commands for HunyuanVideo models, FLUX models, and the FramePack main model. It also shows how to set an environment variable for using a download mirror. ```bash # Create model directory mkdir -p pretrained_models # Download HunyuanVideo models huggingface-cli download --resume-download HunyuanVideo/text_encoder --local-dir pretrained_models/HunyuanVideo/text_encoder huggingface-cli download --resume-download HunyuanVideo/text_encoder_2 --local-dir pretrained_models/HunyuanVideo/text_encoder_2 huggingface-cli download --resume-download HunyuanVideo/tokenizer --local-dir pretrained_models/HunyuanVideo/tokenizer huggingface-cli download --resume-download HunyuanVideo/tokenizer_2 --local-dir pretrained_models/HunyuanVideo/tokenizer_2 huggingface-cli download --resume-download HunyuanVideo/vae --local-dir pretrained_models/HunyuanVideo/vae # Download FLUX models huggingface-cli download --resume-download lllyasviel/flux_redux_bfl --local-dir pretrained_models/lllyasviel/flux_redux_bfl # Download FramePack main model huggingface-cli download --resume-download FramePackI2V_HY --local-dir pretrained_models/FramePackI2V_HY export HF_ENDPOINT=https://hf-mirror.com ``` -------------------------------- ### Run HiDream-I1 Inference Scripts (Python) Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HiDream/README.md Executes Python scripts for HiDream-I1 inference using specified model types (full, dev, fast). Requires the model files and environment setup. ```python # For full model inference python ./inference.py --model_type full # For distilled dev model inference python ./inference.py --model_type dev # For distilled fast model inference python ./inference.py --model_type fast ``` -------------------------------- ### Configure TaylorSeer Cache Parameters in Python Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-FramePack.md Demonstrates how to manually configure specific Taylor series acceleration cache parameters within the `diffusers_helper/models/cache_functions/cache_init.py` file. It shows setting the cache refresh interval and the maximum Taylor series order. ```python cache_dic['fresh_threshold'] = 4 cache_dic['max_order'] = 1 ``` -------------------------------- ### Text-to-Image Generation with Prompt Extension (Single-GPU) Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-Wan2.1/README.md This command enables text-to-image generation with prompt extension on a single GPU. It includes the standard parameters for task, size, checkpoint, and prompt, along with the flag to activate prompt extension. ```sh python generate.py --task t2i-14B --size 1024*1024 --ckpt_dir ./Wan2.1-T2V-14B --prompt '一个朴素端庄的美人' --use_prompt_extend ``` -------------------------------- ### Run FP8 Inference with xDiT Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HunyuanVideo/README_zh.md This command shows how to perform inference using an FP8 quantized HunyuanVideo model. It requires specifying the path to the FP8 weights and scale parameters. The script is executed using `python3` with arguments for the FP8 weight path, video dimensions, inference steps, prompt, and enabling FP8 inference with CPU offloading. ```bash cd HunyuanVideo DIT_CKPT_PATH={PATH_TO_FP8_WEIGHTS}/{WEIGHT_NAME}_fp8.pt python3 sample_video.py \ --dit-weight ${DIT_CKPT_PATH} \ --video-size 1280 720 \ --video-length 129 \ --infer-steps 50 \ --prompt "A cat walks on the grass, realistic style." \ --seed 42 \ --embedded-cfg-scale 6.0 \ --flow-shift 7.0 \ --flow-reverse \ --use-cpu-offload \ --use-fp8 \ --save-path ./results ``` -------------------------------- ### Run Multi-GPU Parallel Inference with xDiT and TaylorSeer Source: https://context7.com/shenyi-z/taylorseer/llms.txt This command navigates to the TaylorSeers-xDiT directory, installs the xfuser library, and then runs a multi-GPU parallel inference script. It highlights that speedups from TaylorSeer multiply with the gains from xDiT. ```bash cd TaylorSeers-xDiT pip install xfuser==0.4.0 # Multi-GPU parallel inference (speedups multiply with cache acceleration) python taylorseer_flux/xfusers_taylorseer_flux.py ``` -------------------------------- ### Inference with HiDream-I1 using Diffusers (Python) Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-HiDream/README.md Performs text-to-image generation using the HiDream-I1 model via the diffusers library. This code snippet requires PyTorch, Transformers, and Diffusers installed, and assumes the Llama-3.1-8B-Instruct model is accessible. ```python import torch from transformers import PreTrainedTokenizerFast, LlamaForCausalLM from diffusers import HiDreamImagePipeline tokenizer_4 = PreTrainedTokenizerFast.from_pretrained("meta-llama/Meta-Llama-3.1-8B-Instruct") text_encoder_4 = LlamaForCausalLM.from_pretrained( "meta-llama/Meta-Llama-3.1-8B-Instruct", output_hidden_states=True, output_attentions=True, torch_dtype=torch.bfloat16, ) pipe = HiDreamImagePipeline.from_pretrained( "HiDream-ai/HiDream-I1-Full", # "HiDream-ai/HiDream-I1-Dev" | "HiDream-ai/HiDream-I1-Fast" tokenizer_4=tokenizer_4, text_encoder_4=text_encoder_4, torch_dtype=torch.bfloat16, ) pipe = pipe.to('cuda') image = pipe( 'A cat holding a sign that says "HiDream.ai".', height=1024, width=1024, guidance_scale=5.0, # 0.0 for Dev&Fast num_inference_steps=50, # 28 for Dev and 16 for Fast generator=torch.Generator("cuda").manual_seed(0), ).images[0] image.save("output.png") ``` -------------------------------- ### Single-GPU Text-to-Video Inference (Basic) Source: https://github.com/shenyi-z/taylorseer/blob/main/TaylorSeer-Wan2.1/README.md This command runs a basic text-to-video generation task on a single GPU without prompt extension. It requires the 'generate.py' script and a specified model checkpoint directory. Key arguments include the task, video size, checkpoint directory, and the input prompt. ```sh python generate.py --task t2v-14B --size 1280*720 --ckpt_dir ./Wan2.1-T2V-14B --prompt "Two anthropomorphic cats in comfy boxing gear and bright gloves fight intensely on a spotlighted stage." ```