Creating Custom Image Models with Stable Diffusion

 

Main Idea

Creating a custom LORA model for Stable Diffusion image genAI, 2 hours

Creator Antti Ruonala
Subject

Computer science

Length 2 hours
Pedagogical Approach

Hands-on activity 

Project-based learning

Competences

C21 Data Collection
C55 Model type algorithms
C57 Tool possibilities
C58 Tool Validation
C68 Ethical Considerations

Grades Grades 10-12 
Technologies

Huggingface.co

https://civitai.com/models/22530/guide-make-your-own-loras-easy-and-free

  • Internet connection and access to Google Colab (google account)
  • Access to Google Drive for storage.
  • Dataset of images (can be curated during the course).
  • Local Stable Diffusion
   
   

  •  

Part 1: Introduction (15 minutes)

  • Overview of Stable Diffusion and its applications.
  • Explain what are LORA’s and why they are useful. Show examples of custom models in comparison to the base model.
  • Explanation of the project structure and necessary tools.

Part 2: Preparing the Dataset (30 minutes)

  • Setup: Connect to Google Drive, choose a project name, and set up folder structures. Run the initial setup cell in Google Colab.
  • Image Curation: Gather dataset either using your own images, or using tools to scrape and download images, focusing on specific tags that describe your concept (e.g., character, style, elements of image). Also prepared dataset can be provided by the teacher.
  • Duplicate Removal: Use FiftyOne AI to detect and remove duplicate images to ensure dataset quality.

Part 3: Tagging and Curating Tags (30 minutes)

  • Image Tagging: Tag images manually or use automatical image tagging using WD 1.4 tagger AI for anime or BLIP AI for other images.
  • Tag Curation: Optimize the dataset by adjusting tags and setting activation tags. Discuss strategies for effective tagging and the importance of detailed descriptions.

Part 4: Training the Model (30 minutes)

  • Training Setup: Configure the training parameters in Google Colab, including model base, image processing settings, and learning rates.
  • Training Execution: Start the training process, monitor for errors, and adjust parameters as needed.

Part 5: Evaluating the Model (15 minutes)

  • Testing: Download trained models from Google Drive and test using different prompts and weights.
  • Optimization: Use plots and comparisons to find the optimal settings and model version.

Closing Discussion (10 minutes)

  • Discuss the outcomes, what could be improved, and potential applications of the trained model.
  • Provide resources for further learning.

Additional Notes:

  • Emphasis on ethical considerations, especially regarding the use of images and AI-generated content and ethical sourcing of the training data. 
  • Encourage experimentation with different types of images and tags to explore the capabilities of custom image models.
  • Discuss the importance of community support and sharing knowledge through platforms like GitHub, HuggingFace and Discord.