Skip to content

ansemjo/diffusionbooth

Repository files navigation

Diffusion Booth

Photobooth × Stable Diffusion
Take a photo and let the AI create a fun and unique portrait of you!

a GIF with examples from the science night

This project was a two-week hack for the 2023 Digital Science Night
See also: trAIding-cards

The Setup

You'll need:

  1. one computer with a powerful GPU and an installation of the stable-diffusion-webui
  2. a thin-client computer with a webcam, which can run the frontend in "kiosk mode"
  3. lots of light and some props for a scenerey

1. Stable-Diffusion-WebUI

For the general installation, just follow the setup instructions in their Wiki. You must enable the API with --api in the COMMANDLINE_ARGS variable. If you don't run the frontend on the same computer, you also need to listen on a reachable IP with --listen.

Then, the ControlNets extension is required because control nets are an essential part of getting pictures with some resemblance at all. Open the Web UI and navigate to Extensions > "Install from URL".

And finally, you need all the models of course. I don't want to make my University's GitLab team angry, so I won't put them into the repository. But you can find the models on huggingface.co and civtai.com; the names, direct download links and hashes of the necessary models are noted in models.md.

You should enable larger cache for ControlNet models! Otherwise they need to be reloaded for every API call, which takes unecessarily long time. Go to Settings > ControlNet (left) > increase "Model cache size".

During the Digital Science Night, we used a computer with an Nvidia RTX 4070 Ti, which was snappy enough to be fun. An 1080 Ti was "fine" but already a little too slow.

2. Run the Frontend

The frontend is built with Vue.js and can be built with yarn install && yarn run dev, followed by opening the link in your favourite browser. Preferably, use Firefox in Kiosk mode and just remove the keyboard:

firefox -kiosk http://localhost:5173/

You'll want to change two things in the code:

  • Point the /sdapi proxy in vite.config.ts to your own Stable-Diffusion-WebUI API.
  • Host your own fileserver/fileserver.py somewhere and point the URL in App.vue's upload() function to it.

The user interface should hopefully be self-explanatory. Picture capture is additionally bound to Shift-S, which can be triggered with a programmable foot pedal, for example.

3. Fun

Let your guests have fun with it.

If you hosted your own fileserver, you can also open its URL on another monitor to show the pictures taken so far in a random gallery.