Skip to main content

Stable Diffusion Gen AI

info

This project corresponds to AI Platform's Generative AI & Knowledge AI MLOps journey.

Project Goals

Diffusion models are now the go-to models for generating images. As diffusion models allow us to condition image generation with prompts, we can generate images of our choice. Among these text-conditioned diffusion models, Stable Diffusion is the most famous because of its open-source nature.

Stable Diffusion Web-UI is a browser interface based on Gradio library for Stable Diffusion.

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

In this project, Generative AI team in Equinor wanted to experiment with stable diffusion models using web-ui and wanted to put together quick demo deployment that can be shared by the team to certain audience for testing purposes.

Team needed an ability to turn on/off this demo to conserve cost of usage.

Summary of Results

The Stable Diffusion Web UI demo was deployed using Jupyter Notebook Server (using GPU) in Kubeflow on AI Platform's Aurora AKS cluster. This demo on notebook enabled generative AI team to experiment with stable diffusion models and also allow them to conduct beta user testing by sharing with selected users as per their needs.

Project Team

Colton Behannon (Data Scientist)
Jakob Vigerust Kallestad (Data Scientist)

Prerit Shah (MLOps Architect)

MLOps Challenges

Complex Depencies / Virtual Environment Setup

Stable diffusion models web ui has many complex dependencies including Python and Linux packages.

GPU Compute Requirement

Due to the computationally heavy nature stable diffusion models, it would take a very long time to run the model on CPU and even then the output would not be that great. Therefore, stable diffusion models must be run on GPUs to provide meaningful results.

Need to Expose Web-UI/Front-End to Other Equinor Users

Team needed an ability to expose the web UI to other Equinor users and allow them to generate images using standard diffusion model web-ui. It is not easy to expose web-ui running in Jupyter Notebook to be exposed as web-ui across the company.

MLOps Solutions

Project Specific Jupyter Notebook Server Image

MLOps team created a project specific Jupyter Notebook Server Image that contained all the project specific Python packages and other dependencies including conda virtual environments that can be used a Jupyter Notebook Kernel. This meant that team members can would have pre-configured project specific ready to code virtual environment within matter of minutes when they start a new notebook server in Kubeflow. They did not need to setup the virtual environment. Any new member joining the team can also starting contributing and coding instantly. They could also recover their clean virtual environment if it were to accidentally get corrupted by simply stopping and starting the notebook. Team was able to start the stable diffusion web ui instantly after starting their notebook in Kubeflow.

Team Collaboration in Project Specific Kubeflow Profile

Every member of the project team had their own kubeflow profile where they can run their own private experiments, notebooks and pipelines. In addition, project specific Kubeflow profile was setup in which all team members could seamlessly collaborate for running their notebooks, sharing data, executing pipelines and deploying models.

Stable Diffusion Model Usage on GPU

Team was also able to leverage the power of stable diffusion models to generate images based on text prompts by using the Jupyter Notebooks run on GPU

Quick Deployment of Web-UI running in Jupyter Notebook

Web-UI running on Jupyter Notebook server in Kubeflow was quicly exposed to be accessed from web browser by other users in Equinor. This was done by exposing an additional port on Jupyter Notebook in Kubeflow to route the web-ui traffic and then routing that traffic via Kubernetes service. This Kubernetes service was made accesible to other users from their web browsers by writing Istio virtual service connected to the Kubernetes service.

GitHub Repos

https://github.com/equinor/generative-ai

Stable Diffusion Demo Architecture