Training a LoRA Model for Stable Diffusion Turbo

Note: This guide assumes you have basic knowledge of machine learning concepts and are familiar with command-line interfaces.

Interactive Step-by-Step Guide

Automatic1111 WebUI: This is the most user-friendly option to set up and train LoRA models, especially if you are using SD Turbo based on the SD 1.5 architecture.

  1. Install Automatic1111 WebUI:
    git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
    cd stable-diffusion-webui
    pip install -r requirements.txt

    Launch the WebUI using the appropriate script (webui-user.bat for Windows or webui.sh for Linux).

  2. Download SD Turbo Model:

    Ensure the SD Turbo model is downloaded. This model is optimized for faster inference and training while maintaining compatibility with SD 1.5-based LoRAs. Place the model in the models/Stable-diffusion directory within the WebUI installation.

  1. Access the DreamBooth or LoRA Training Tab:

    Open the Automatic1111 WebUI in your web browser. Navigate to the DreamBooth or LoRA tab, depending on how it is named in your interface.

  2. Configure Training Settings:
    • Instance Prompt: Use a specific identifier like "houston mural style" to label your training dataset.
    • Class Prompt: Set this to a broader category like "mural art" to provide context.
    • Training Steps: For a small dataset of 20 images, set training steps between 2000 to 4000.
    • Batch Size: Use a small batch size (1 or 2) with gradient accumulation steps if VRAM is limited.
    • Learning Rate: Start with a low learning rate, such as 5e-6.
    • Mixed Precision: Enable FP16 mixed precision to optimize GPU memory usage and speed up training.
  3. Start Training:

    Click the "Train" button to start the training process. Monitor the training progress through the WebUI interface. Watch for overfitting by observing loss values; if the model converges too quickly or loss decreases too slowly, consider adjusting learning rates or increasing training steps.

  1. Save and Load the LoRA Model:

    Once training is complete, save the best-performing checkpoint from the training session. Load the trained LoRA model into the SD Turbo environment within the WebUI.

  2. Apply LoRA to SD Turbo:

    In the WebUI, select the SD Turbo model as your base. Apply the trained LoRA to the SD Turbo model to stylize outputs based on the mural style you trained on.

  1. Real-Time Video Stylization:

    In TouchDesigner, set up your pipeline to feed video frames as input into the SD Turbo model with the applied LoRA. Ensure your inputs are configured as texture inputs (2D arrays of pixels) and that your system is optimized for real-time processing.

  2. Optimize Performance:

    Adjust resolution, frame rate, and other settings in TouchDesigner to balance between performance and output quality. Use a high-performance GPU like the NVIDIA RTX 4090 to achieve the best real-time results.

  1. Test and Refine:

    Experiment with different prompts and inputs to see how the LoRA model performs with various styles and scenes. Fine-tune the model further if necessary, based on the initial results and feedback.

  2. Post-Processing:

    Use video editing software like Adobe Premiere or DaVinci Resolve to enhance and speed up the outputs as needed.

Overall Progress

0%

Conclusion

By using SD Turbo with the SD 1.5 architecture, you can effectively train and deploy a LoRA model for your specific use case. This approach allows you to leverage the performance optimizations of SD Turbo while maintaining compatibility with SD 1.5-based models and LoRAs, making it ideal for real-time stylization tasks in applications like TouchDesigner.