Skip to content

Commit 212c1c6

Browse files
authored
feat: getting rid of broken & unused things; added "test_input.json"; updated README (#48)
* feat: getting rid of broken & unused things; added "test_input.json" * docs: improve README
1 parent 23f89e7 commit 212c1c6

File tree

8 files changed

+56
-119
lines changed

8 files changed

+56
-119
lines changed

.runpod/hub.json

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
{
2-
"title": "Automatic1111 Stable Diffusion",
3-
"description": "This worker uses the Stable Diffusion model for AI image generation tasks. Built upon the Stable Diffusion WebUI, it provides an efficient interface for generating images with Stable Diffusion AI models.",
2+
"title": "Automatic1111 Stable Diffusion web UI",
3+
"description": "Built upon the Stable Diffusion WebUI, this worker provides an API to generate images with Stable Diffusion models.",
44
"type": "serverless",
55
"category": "image",
66
"iconUrl": "https://dummyimage.com/100x100/ff5733/fff&text=SD",
77
"config": {
88
"runsOn": "GPU",
9-
"containerDiskInGb": 20
9+
"containerDiskInGb": 20,
10+
"gpuTypeId": "NVIDIA GeForce RTX 4090",
11+
"gpuCount": 1,
12+
"allowedCudaVersions": [
13+
"12.7",
14+
"12.6",
15+
"12.5",
16+
"12.4",
17+
"12.3",
18+
"12.2",
19+
"12.1"
20+
]
1021
}
11-
}
22+
}

Dockerfile

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,40 +22,29 @@ ENV DEBIAN_FRONTEND=noninteractive \
2222

2323
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
2424

25-
RUN export COMMANDLINE_ARGS="--skip-torch-cuda-test --precision full --no-half"
26-
RUN export TORCH_COMMAND='pip install ---no-cache-dir torch==2.1.2+cu118 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118'
27-
2825
RUN apt-get update && \
2926
apt install -y \
3027
fonts-dejavu-core rsync git jq moreutils aria2 wget libgoogle-perftools-dev libtcmalloc-minimal4 procps libgl1 libglib2.0-0 && \
3128
apt-get autoremove -y && rm -rf /var/lib/apt/lists/* && apt-get clean -y
3229

33-
RUN --mount=type=cache,target=/cache --mount=type=cache,target=/root/.cache/pip \
34-
pip install --upgrade pip && \
35-
${TORCH_COMMAND} && \
36-
pip install --no-cache-dir xformers==0.0.23.post1 --index-url https://download.pytorch.org/whl/cu118
37-
3830
RUN --mount=type=cache,target=/root/.cache/pip \
3931
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git && \
4032
cd stable-diffusion-webui && \
4133
git reset --hard ${A1111_RELEASE} && \
34+
pip install xformers && \
35+
pip install -r requirements_versions.txt && \
4236
python -c "from launch import prepare_environment; prepare_environment()" --skip-torch-cuda-test
4337

4438
COPY --from=download /model.safetensors /model.safetensors
4539

46-
# Copy requirements.txt and install dependencies
40+
# install dependencies
4741
COPY requirements.txt .
4842
RUN --mount=type=cache,target=/root/.cache/pip \
4943
pip install --no-cache-dir -r requirements.txt
5044

51-
# Copy test input file
5245
COPY test_input.json .
5346

5447
ADD src .
5548

56-
COPY builder/cache.py /stable-diffusion-webui/cache.py
57-
RUN cd /stable-diffusion-webui && python cache.py --use-cpu=all --ckpt /model.safetensors
58-
59-
# Set permissions and specify the command to run
6049
RUN chmod +x /start.sh
6150
CMD /start.sh

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 runpod-workers
3+
Copyright (c) 2025 RunPod
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,40 @@
11
<div align="center">
22

3-
<h1>Automatic1111 | Worker</h1>
3+
<h1>Automatic1111 Stable Diffusion web UI</h1>
44

55
[![RunPod](https://api.runpod.io/badge/runpod-workers/worker-a1111)](https://www.runpod.io/console/hub/runpod-workers/worker-a1111)
6-
[![CI | Test Worker](https://github.com/runpod-workers/worker-template/actions/workflows/CI-test_worker.yml/badge.svg)](https://github.com/runpod-workers/worker-template/actions/workflows/CI-test_worker.yml)
7-
&nbsp;
8-
[![Docker Image](https://github.com/runpod-workers/worker-template/actions/workflows/CD-docker_dev.yml/badge.svg)](https://github.com/runpod-workers/worker-template/actions/workflows/CD-docker_dev.yml)
96

10-
This worker is a RunPod worker that uses the Stable Diffusion model for AI tasks. The worker is built upon the Stable Diffusion WebUI, which is a user interface for Stable Diffusion AI models.
11-
</div>
12-
13-
## Model
7+
Built upon the Stable Diffusion WebUI, this worker provides an API to generate images with Stable Diffusion models.
148

15-
The worker uses the Stable Diffusion model, which has been optimized for RunPod. This model is stored as a SafeTensors file, which is a format that facilitates efficient loading and execution of AI models. You may download the model file from the following link: here.
9+
</div>
1610

17-
## Building the Worker
11+
## Features
1812

19-
The worker is built using a Dockerfile. The Dockerfile specifies the base image, environment variables, system package dependencies, Python dependencies, and the steps to install and setup the Stable Diffusion WebUI. It also downloads the model and sets up the API server using supervisor.
13+
- Runs the [Automatic1111 Stable Diffusion WebUI](https://github.com/AUTOMATIC1111/stable-diffusion-webui) and exposes its txt2img API endpoint.
14+
- Comes pre-packaged with the [**Deliberate v6**](https://huggingface.co/XpucT/Deliberate) model (`Deliberate_v6.safetensors`).
2015

21-
The Python dependencies are specified in requirements.txt. The primary dependency is runpod==0.9.4.
16+
## Usage
2217

23-
## Running the Worker
18+
The `input` object within your job request is forwarded directly to the `/sdapi/v1/txt2img` endpoint of the internal Automatic1111 API.
2419

25-
The worker can be run using the start.sh script. This script starts the init system and runs the serverless handler script.
20+
### Configuration
2621

27-
## API
22+
The `input` object accepts any valid parameter for the Automatic1111 `/sdapi/v1/txt2img` endpoint. Refer to the [Automatic1111 API Documentation](https://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/API) for a full list of available parameters (like `seed`, `sampler_name`, `batch_size`, `styles`, `override_settings`, etc.).
2823

29-
The worker provides an API for inference. The API is set up using supervisor, and the configuration is specified in webui_api.conf. The API runs on port 3000.
24+
### Example Request
3025

31-
## Serverless Handler
26+
Here's an example payload to generate an image:
3227

33-
The serverless handler (handler.py) is a Python script that handles inference requests. It defines a function handler(event) that takes an inference request, runs the inference using the Stable Diffusion model, and returns the output.
28+
```json
29+
{
30+
"input": {
31+
"prompt": "a photograph of an astronaut riding a horse",
32+
"negative_prompt": "text, watermark, blurry, low quality",
33+
"steps": 25,
34+
"cfg_scale": 7,
35+
"width": 512,
36+
"height": 512,
37+
"sampler_name": "DPM++ 2M Karras"
38+
}
39+
}
40+
```

builder/cache.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/rp_handler.py

Lines changed: 0 additions & 64 deletions
This file was deleted.

src/start.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ python /stable-diffusion-webui/webui.py \
1313
--skip-torch-cuda-test \
1414
--skip-install \
1515
--ckpt /model.safetensors \
16-
--lowram \
1716
--opt-sdp-attention \
1817
--disable-safe-unpickle \
1918
--port 3000 \
2019
--api \
2120
--nowebui \
2221
--skip-version-check \
2322
--no-hashing \
24-
--no-download-sd-model > /webui.log 2>&1 &
23+
--no-download-sd-model &
2524

2625
echo "Starting RunPod Handler"
27-
python -u /rp_handler.py
26+
python -u /handler.py

test_input.json

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{
2-
"prompt": "a photo of an astronaut riding a horse on mars",
3-
"negative_prompt": "blurry, bad quality",
4-
"width": 512,
5-
"height": 512,
6-
"num_inference_steps": 20,
7-
"guidance_scale": 7.5,
8-
"seed": 42
9-
}
2+
"input": {
3+
"prompt": "a photo of an astronaut riding a horse on mars",
4+
"negative_prompt": "blurry, bad quality",
5+
"width": 512,
6+
"height": 512,
7+
"num_inference_steps": 20,
8+
"guidance_scale": 7.5,
9+
"seed": 42
10+
}
11+
}

0 commit comments

Comments
 (0)