The Stable Diffusion project represents a significant advancement in artificial intelligence, particularly in image generation.

The future is here, we have open source models that can do Text to Image.

The Stable Difussion Project

Utilizing a machine learning model, Stable Diffusion can generate detailed images based on textual descriptions, offering a powerful tool for various applications.

  • Key Aspects of Stable Diffusion:
    • Open Source Model:

      • Unlike some commercially licensed counterparts, Stable Diffusion is open source.
      • This accessibility enables researchers, developers, and hobbyists to utilize, modify, and integrate the model into their projects without any cost barriers. ๐ŸŒ
    • Latent Diffusion:

      • Stable Diffusion operates using a latent space to generate images. This involves transforming text descriptions into a compressed representation of the image’s features before decoding it back into the visual space.
      • This approach is not only computationally efficient but also allows for the generation of complex images more quickly compared to other models. ๐Ÿ’ก

Stable Diffusion represents is another testament to the power of open-source collaboration and innovation in the field of artificial intelligence.

Stable Difussion in my Laptop

  • Before starting our SelfHosting journey of Stable Difussion Models with Docker and Automatic111.
    • ๐Ÿ’ป CPU (or Integrated GPU):

      • You’ll need a CPU or integrated GPU to run Stable Diffusion with Docker. While a dedicated GPU can accelerate processing, an iGPU or CPU can also handle the workload, albeit with potentially slower performance.
    • ๐Ÿณ Docker Installed:

      • Ensure Docker is installed and running on your machine. Docker provides a consistent environment for deploying and running applications, including Stable Diffusion.
    • ๐Ÿ“ฅ Download Models:

      • Obtain the necessary pre-trained models for Stable Diffusion. These models are typically available for download from the project’s repository or website.
    • โš™๏ธ Configuration Files Provided:

      • Use the provided configuration files to set up and customize Stable Diffusion according to your preferences and requirements. These files include settings for model parameters, input data, and other configurations.
    • โฐ Time to Create:

      • Allocate sufficient time to create and configure the Docker environment for Stable Diffusion. Depending on your familiarity with Docker and the complexity of the setup, this process may take some time.

Automatic111 with Docker

apt-get update && apt-get install -y \
  git \
  build-essential

git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git

cd stable-diffusion-webui
sudo apt install -y wget git python3 python3-venv libgl1 libglib2.0-0
#version: '3'

services:
  sd-automatic:
    image: python:3.10.6-slim
    container_name: automatic
    command: tail -f /dev/null
    volumes:
      - ai_automatic:/app
    working_dir: /app  # Set the working directory to /app
    ports:
      - "7865:7865"

volumes:
  ai_automatic:
apt install -y wget git python3 python3-venv libgl1 libglib2.0-0 
apt install -y nano

wget -q https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/webui.sh
#chmod +x webui.sh ## Make the script executable by all users
nano webui.sh

Comment these lines:

# Do not run as root
# if [[ $(id -u) -eq 0 && can_run_as_root -eq 0 ]]
# then
#     printf "\n%s\n" "${delimiter}"
#     printf "\e[1m\e[31mERROR: This script must not be launched as root, aborting...\e[0m"
#     printf "\n%s\n" "${delimiter}"
#     exit 1
# else
# printf "\n%s\n" "${delimiter}"
# printf "Running on \e[1m\e[32m%s\e[0m user" "$(whoami)"
# printf "\n%s\n" "${delimiter}"
# fi

Then just run:

./webui.sh

#sudo ./webui.sh
#sudo chown root:root webui.sh
pip install -r requirements.txt
#download model - see how the webui.sh does it
python3 webui.py --use-cpu --all

Now the Automatic111 User Interface is ready at: localhost:7865


FAQ

Useful Resources to Build Python Apps

F/OSS Tools For Image Processing

F/OSS Tools for CAD

This is the official source code of FreeCAD, a free and opensource multiplatform 3D parametric modeler.

  • OpenSCAD

  • Blender: Although primarily known as a 3D modeling and animation software, Blender also has CAD capabilities through its extensive add-on ecosystem. It can be used for tasks such as 3D printing, architectural modeling

    • https://www.cadsketcher.com/ - CAD Sketcher is a free and open-source project looking to enhance precision workflows in blender by bringing CAD like tools, features and usability to blender.