-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Uploaded example for stable diffusion
- Loading branch information
Showing
6 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
FROM nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu22.04 | ||
|
||
RUN apt update && \ | ||
apt install -y --no-install-recommends git wget python3-pip && \ | ||
apt-get clean && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
RUN git clone https://github.com/srisco/stable-diffusion-tensorflow.git | ||
|
||
WORKDIR stable-diffusion-tensorflow | ||
|
||
RUN pip install -r requirements.txt && \ | ||
rm -rf /root/.cache/pip/* && \ | ||
rm -rf /tmp/* | ||
|
||
# DOWNLOAD WEIGHTS | ||
RUN mkdir -p /root/.keras/datasets && \ | ||
wget https://huggingface.co/fchollet/stable-diffusion/resolve/main/text_encoder.h5 -O /root/.keras/datasets/text_encoder.h5 && \ | ||
wget https://huggingface.co/fchollet/stable-diffusion/resolve/main/diffusion_model.h5 -O /root/.keras/datasets/diffusion_model.h5 && \ | ||
wget https://huggingface.co/fchollet/stable-diffusion/resolve/main/decoder.h5 -O /root/.keras/datasets/decoder.h5 && \ | ||
wget https://huggingface.co/divamgupta/stable-diffusion-tensorflow/resolve/main/encoder_newW.h5 -O /root/.keras/datasets/encoder_newW.h5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Stable Diffusion | ||
|
||
This example is based on a Keras / Tensorflow implementation of Stable Diffusion. The following repositories were used for the creation of the image: | ||
|
||
* [srisco/stable-diffusion-tensorflow](https://github.com/srisco/stable-diffusion-tensorflow) | ||
* [huggingface.co/fchollet/stable-diffusion](https://huggingface.co/fchollet/stable-diffusion) | ||
* [huggingface.co/divamgupta/stable-diffusion-tensorflow](https://huggingface.co/divamgupta/stable-diffusion-tensorflow/) | ||
|
||
The image if pushed to a public github registry [here](ghcr.io/grycap/stable-diffusion-tf:latest) but you can see the Dockerfile that generates it [here](Dockerfile). | ||
|
||
## Deploy an OSCAR cluster | ||
Follow the instructions in the documentation for your desired IaaS cloud provider. | ||
[See Deployment](https://docs.oscar.grycap.net/) | ||
|
||
## Create the OSCAR Service | ||
|
||
The Service can be created using the OSCAR GUI by providing the [FDL](stable-diff.yaml) and the [script.sh](script.sh) file. | ||
|
||
![OSCAR GUI Creation of a service](https://oscar.grycap.net/images/blog/post-20210803-1/create_service_gui.png) | ||
|
||
## Upload the input file to the MinIO bucket | ||
|
||
Once the service is created, you can upload the input file to the bucket. The input file should be a file containing the prompt that you want to process. | ||
|
||
For example, using the following prompt: | ||
|
||
`a chicken making a 360 with a skateboard with background flames` | ||
|
||
The following image is generated: | ||
|
||
![Cool chicken](prompt.txt.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
a chicken making a 360 with a skateboard with background flames |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
|
||
echo "SCRIPT: Invoked stable diffusion text to image." | ||
FILE_NAME=`basename "$INPUT_FILE_PATH"` | ||
OUTPUT_FILE="$TMP_OUTPUT_DIR/$FILE_NAME.png" | ||
|
||
prompt=`cat "$INPUT_FILE_PATH"` | ||
echo "SCRIPT: Converting input prompt '$INPUT_FILE_PATH' to image :)" | ||
python3 text2image.py --prompt="$prompt" --output=$OUTPUT_FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
functions: | ||
oscar: | ||
- oscar-intertwin: | ||
name: stable-diffusion-tf | ||
memory: 16Gi | ||
cpu: '4' | ||
image: ghcr.io/grycap/stable-diffusion-tf:latest | ||
script: script.sh | ||
log_level: DEBUG | ||
vo: "vo.example.eu" | ||
allowed_users: [] | ||
input: | ||
- storage_provider: minio.default | ||
path: stablediff/input | ||
output: | ||
- storage_provider: minio.default | ||
path: stablediff/output |