feat: add more

This commit is contained in:
Sun-ZhenXing
2025-10-06 21:48:39 +08:00
parent f330e00fa0
commit 3c609b5989
120 changed files with 7698 additions and 59 deletions

View File

@@ -0,0 +1,13 @@
# Stable Diffusion WebUI version
SD_WEBUI_VERSION="latest"
# CLI arguments for WebUI
CLI_ARGS="--listen --api --skip-version-check"
# NVIDIA GPU configuration
NVIDIA_VISIBLE_DEVICES="all"
NVIDIA_DRIVER_CAPABILITIES="compute,utility"
GPU_COUNT=1
# Port overrides
SD_WEBUI_PORT_OVERRIDE=7860

View File

@@ -0,0 +1,122 @@
# Stable Diffusion WebUI Docker
[English](./README.md) | [中文](./README.zh.md)
This service deploys Stable Diffusion WebUI (SD.Next) for AI image generation.
## Services
- `stable-diffusion-webui`: Stable Diffusion WebUI with GPU support.
## Prerequisites
**NVIDIA GPU Required**: This service requires an NVIDIA GPU with CUDA support and the NVIDIA Container Toolkit installed.
### Install NVIDIA Container Toolkit
**Linux:**
```bash
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
sudo systemctl restart docker
```
**Windows (Docker Desktop):**
Ensure you have WSL2 with NVIDIA drivers installed and Docker Desktop configured to use WSL2 backend.
## Environment Variables
| Variable Name | Description | Default Value |
| -------------------------- | -------------------------- | ------------------------------------- |
| SD_WEBUI_VERSION | SD WebUI image version | `latest` |
| CLI_ARGS | Command-line arguments | `--listen --api --skip-version-check` |
| NVIDIA_VISIBLE_DEVICES | GPUs to use | `all` |
| NVIDIA_DRIVER_CAPABILITIES | Driver capabilities | `compute,utility` |
| GPU_COUNT | Number of GPUs to allocate | `1` |
| SD_WEBUI_PORT_OVERRIDE | WebUI port | `7860` |
Please modify the `.env` file as needed for your use case.
## Volumes
- `sd_webui_data`: Model files, extensions, and configuration.
- `sd_webui_output`: Generated images output directory.
## Usage
### Start the Service
```bash
docker-compose up -d
```
### Access the WebUI
Open your browser and navigate to:
```text
http://localhost:7860
```
### Download Models
On first start, you need to download models. The WebUI will guide you through this process, or you can manually place models in the `/data/models` directory.
Common model locations:
- Stable Diffusion models: `/data/models/Stable-diffusion/`
- VAE models: `/data/models/VAE/`
- LoRA models: `/data/models/Lora/`
- Embeddings: `/data/models/embeddings/`
### Generate Images
1. Select a model from the dropdown
2. Enter your prompt
3. Adjust parameters (steps, CFG scale, sampler, etc.)
4. Click "Generate"
## Features
- **Text-to-Image**: Generate images from text prompts
- **Image-to-Image**: Transform existing images
- **Inpainting**: Edit specific parts of images
- **Upscaling**: Enhance image resolution
- **API Access**: RESTful API for automation
- **Extensions**: Support for custom extensions
- **Multiple Models**: Support for various SD models (1.5, 2.x, SDXL, etc.)
## Notes
- First startup may take time to download dependencies and models
- Recommended: 8GB+ VRAM for SD 1.5, 12GB+ for SDXL
- GPU is required; CPU-only mode is extremely slow
- Generated images are saved in the `sd_webui_output` volume
- Models can be large (2-7GB each); ensure adequate disk space
## API Usage
With `--api` flag enabled, access the API at:
```text
http://localhost:7860/docs
```
Example API call:
```bash
curl -X POST http://localhost:7860/sdapi/v1/txt2img \
-H "Content-Type: application/json" \
-d '{
"prompt": "a beautiful landscape",
"steps": 20
}'
```
## License
Stable Diffusion models have various licenses. Please check individual model licenses before use.

View File

@@ -0,0 +1,122 @@
# Stable Diffusion WebUI Docker
[English](./README.md) | [中文](./README.zh.md)
此服务用于部署 Stable Diffusion WebUI (SD.Next) 进行 AI 图像生成。
## 服务
- `stable-diffusion-webui`: 支持 GPU 的 Stable Diffusion WebUI。
## 先决条件
**需要 NVIDIA GPU**: 此服务需要支持 CUDA 的 NVIDIA GPU 和已安装的 NVIDIA Container Toolkit。
### 安装 NVIDIA Container Toolkit
**Linux:**
```bash
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
sudo systemctl restart docker
```
**Windows (Docker Desktop):**
确保已安装带有 NVIDIA 驱动程序的 WSL2并将 Docker Desktop 配置为使用 WSL2 后端。
## 环境变量
| 变量名 | 说明 | 默认值 |
| -------------------------- | ----------------- | ------------------------------------- |
| SD_WEBUI_VERSION | SD WebUI 镜像版本 | `latest` |
| CLI_ARGS | 命令行参数 | `--listen --api --skip-version-check` |
| NVIDIA_VISIBLE_DEVICES | 使用的 GPU | `all` |
| NVIDIA_DRIVER_CAPABILITIES | 驱动程序功能 | `compute,utility` |
| GPU_COUNT | 分配的 GPU 数量 | `1` |
| SD_WEBUI_PORT_OVERRIDE | WebUI 端口 | `7860` |
请根据实际需求修改 `.env` 文件。
## 卷
- `sd_webui_data`: 模型文件、扩展和配置。
- `sd_webui_output`: 生成的图像输出目录。
## 使用方法
### 启动服务
```bash
docker-compose up -d
```
### 访问 WebUI
在浏览器中打开:
```text
http://localhost:7860
```
### 下载模型
首次启动时您需要下载模型。WebUI 会指导您完成此过程,或者您可以手动将模型放置在 `/data/models` 目录中。
常见模型位置:
- Stable Diffusion 模型: `/data/models/Stable-diffusion/`
- VAE 模型: `/data/models/VAE/`
- LoRA 模型: `/data/models/Lora/`
- 嵌入: `/data/models/embeddings/`
### 生成图像
1. 从下拉列表中选择模型
2. 输入您的提示词
3. 调整参数步数、CFG 比例、采样器等)
4. 点击"生成"
## 功能
- **文本到图像**: 从文本提示生成图像
- **图像到图像**: 转换现有图像
- **修复**: 编辑图像的特定部分
- **放大**: 增强图像分辨率
- **API 访问**: 用于自动化的 RESTful API
- **扩展**: 支持自定义扩展
- **多模型**: 支持各种 SD 模型1.5、2.x、SDXL 等)
## 注意事项
- 首次启动可能需要时间下载依赖项和模型
- 推荐: SD 1.5 需要 8GB+ 显存SDXL 需要 12GB+
- 需要 GPU纯 CPU 模式极其缓慢
- 生成的图像保存在 `sd_webui_output` 卷中
- 模型可能很大(每个 2-7GB确保有足够的磁盘空间
## API 使用
启用 `--api` 标志后,在以下地址访问 API:
```text
http://localhost:7860/docs
```
API 调用示例:
```bash
curl -X POST http://localhost:7860/sdapi/v1/txt2img \
-H "Content-Type: application/json" \
-d '{
"prompt": "a beautiful landscape",
"steps": 20
}'
```
## 许可证
Stable Diffusion 模型有各种许可证。使用前请检查各个模型的许可证。

View File

@@ -0,0 +1,42 @@
x-default: &default
restart: unless-stopped
volumes:
- &localtime /etc/localtime:/etc/localtime:ro
- &timezone /etc/timezone:/etc/timezone:ro
logging:
driver: json-file
options:
max-size: 100m
services:
stable-diffusion-webui:
<<: *default
image: ghcr.io/absolutelyludicrous/sdnext:${SD_WEBUI_VERSION:-latest}
container_name: stable-diffusion-webui
ports:
- "${SD_WEBUI_PORT_OVERRIDE:-7860}:7860"
environment:
CLI_ARGS: ${CLI_ARGS:---listen --api --skip-version-check}
NVIDIA_VISIBLE_DEVICES: ${NVIDIA_VISIBLE_DEVICES:-all}
NVIDIA_DRIVER_CAPABILITIES: ${NVIDIA_DRIVER_CAPABILITIES:-compute,utility}
volumes:
- *localtime
- *timezone
- sd_webui_data:/data
- sd_webui_output:/output
deploy:
resources:
limits:
cpus: '4.0'
memory: 16G
reservations:
cpus: '2.0'
memory: 8G
devices:
- driver: nvidia
count: ${GPU_COUNT:-1}
capabilities: [gpu]
volumes:
sd_webui_data:
sd_webui_output: