Open WebUI

Our aim

Installing Open WebUI in the front of Ollama text LLM and using Stable Diffusion to generate images as well on the same machine.

Requirements

  • brew
  • docker

Installation

Ollama:

Since this block post about GPU acceleration on MacOS we are using the non-Docker solution

# install via brew
$ brew install --cask ollama

# start ollama
$ ollama run llama3

# test prompt
>>> are you there?

# exit when ready
$ /bye

# list available models
$ ollama list
...
NAME            ID              SIZE    MODIFIED
llama3:latest   365c0bd3c000    4.7 GB  2k years ago

Automatic1111

Same situation for Automatic1111, we need to installing it manually

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

# change into Stable Diffusion folder to download the model
$ cd stable-diffusion-webui/models/Stable-diffusion

# download the model, eg. 'v1-5-pruned-emaonly' which is about 4GB
$ curl -OL \
  https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt

# jump back to the root of the project
$ cd ../../

# append user config to file 'webui-user.sh'
...
export COMMANDLINE_ARGS="--skip-torch-cuda-test --api --listen"

# start for first time in foreground to check for logs
$ ./webui.sh

Open WebUI

To finally run Open WebUI we are using Docker again

docker run
$ docker run -d -p 3000:8080 \
  --add-host=host.docker.internal:host-gateway \
  -e AUTOMATIC1111_BASE_URL=http://$(ipconfig getifaddr en0):7860/ \
  -e SCARF_NO_ANALYTICS=True \
  -e DO_NOT_TRACK=True \
  -e ANONYMIZED_TELEMETRY=False \
  -e ENABLE_IMAGE_GENERATION=True \
  -v open-webui:/app/backend/data \
  --name open-webui \
  --restart always \
  ghcr.io/open-webui/open-webui:main

Visit now port 3000 on host machine to create an account and setup Open WebUI

Do a bit of groundwork like setting a default model or system languange etc. - all changes will persist. See doc’s for more ENV variables

Verify image creation

To create an image via Automatic1111 let us first creating a prompt via Ollama, for example:

“create a prompt for a cool cyberpunk picture”

When the prompt is ready have a look at the options in the buttom of the message and click the image icon to directly generate the picture from the prompt:

A bird flying through a field of tall grass

Further automation

Since Automatic1111 needs to be started manually after every boot it would be nice to automate it…