Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Stable Diffusion web UI example #63

Merged
merged 3 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
}