Skip to content

Commit

Permalink
Add Stable Diffusion web UI example (#63)
Browse files Browse the repository at this point in the history
* Add stable-diffusion-webui example

* Add Stable Diffusion web UI example

* fix lint
  • Loading branch information
bddppq authored Dec 12, 2023
1 parent 8cd0536 commit 19a3ef5
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
36 changes: 36 additions & 0 deletions advanced/stable-diffusion-webui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Stable Diffusion web UI

[Stable Diffusion web UI](https://github.com/AUTOMATIC1111/stable-diffusion-webui.git) is a browser interface based on Gradio library for Stable Diffusion.

## Install Lepton sdk
```shell
pip install leptonai
```

## Launch Stable Diffusion web UI in the cloud

Similar to other examples, you can run Stable Diffusion web UI on Lepton Cloud Platform easily, e.g.:

```shell
lep photon create -n stable-diffusion-webui -m photon.py
lep photon push -n stable-diffusion-webui
lep photon run \
-n stable-diffusion-webui \
--resource-shape gpu.a10
--public
```

You can visit [dashboard.lepton.ai](https://dashboard.lepton.ai/) to use the web Dashboard, or use `lep` cli to manage the launched deployment:
```shell
lep deployment status -n stable-diffusion-webui
```

## Client

Once the Stable Diffusion web UI server is up, you can copy the deployment url shown on the Lepton Dashboard (or in the `lep` cli output)

<img src="assets/deployment.png" width=1024>

and visit it in the web browser

<img src="assets/browser.png" width=1024>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions advanced/stable-diffusion-webui/photon.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import os

from leptonai.photon import Photon


class WebUI(Photon):
webui_version = "1.6.0"
cmd = [
"bash",
"-c",
(
"apt-get update && apt-get install -y wget libgoogle-perftools-dev && wget"
f" -q https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/{webui_version}/webui.sh"
" && chmod +x ./webui.sh && ACCELERATE=True ./webui.sh -f --listen --port"
" 8080"
),
]
deployment_template = {
"resource_shape": "gpu.a10",
}

0 comments on commit 19a3ef5

Please sign in to comment.