From aeb1ac7ede1bf20f065d1a939225b3ffaf8dc09c Mon Sep 17 00:00:00 2001 From: Xin Liu Date: Fri, 27 Sep 2024 14:22:49 +0900 Subject: [PATCH] doc: update docs Signed-off-by: Xin Liu --- README.md | 21 +++++++++++++++++---- examples/flux.md | 14 ++++++++++++++ examples/flux_with_lora.md | 17 +++++++++++++++++ 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index be67043..981f863 100644 --- a/README.md +++ b/README.md @@ -56,8 +56,17 @@ This project is a RESTful API server that provides image generation and editing wasmedge --dir .:. sd-api-server.wasm --model-name sd-v1.4 --model stable-diffusion-v1-4-Q8_0.gguf ``` + > [!TIP] > `sd-api-server` will use `8080` port by default. You can change the port by adding `--port `. + - Reduce the memory usage + + In the default setting, the server will create `text-to-image` and `image-to-image` contexts for the model. `text-to-image` context is responsible for image generation tasks, while `image-to-image` context for image edits. If you only need one of them, you can specify the context type by adding `--context-type `. For example, if you only need the `text-to-image` context, you can start the server with the following command: + + ```bash + wasmedge --dir .:. sd-api-server.wasm --model-name sd-v1.4 --model stable-diffusion-v1-4-Q8_0.gguf --context-type text-to-image + ``` + ### Usage #### Image Generation @@ -147,7 +156,7 @@ This project is a RESTful API server that provides image generation and editing If the build process is successful, `sd-api-server.wasm` will be generated in `target/wasm32-wasip1/release/`. -## CLI Options +### CLI Options ```bash $ wasmedge target/wasm32-wasip1/release/sd-api-server.wasm -h @@ -159,7 +168,7 @@ Usage: sd-api-server.wasm [OPTIONS] --model-name <--model |- Options: -m, --model-name Sets the model name - -m, --model + --model Path to full model [default: ] --diffusion-model Path to the standalone diffusion model file [default: ] @@ -169,14 +178,18 @@ Options: Path to the clip-l text encoder [default: ] --t5xxl Path to the the t5xxl text encoder [default: ] + --lora-model-dir + Path to the lora model directory [default: ] --threads Number of threads to use during computation. Default is -1, which means to use all available threads [default: -1] + --context-type + Context to create for the model [default: full] [possible values: text-to-image, image-to-image, full] --socket-addr - Socket address of LlamaEdge API Server instance + Socket address of LlamaEdge API Server instance. For example, `0.0.0.0:8080` --port Port number [default: 8080] -h, --help - Print help + Print help (see more with '--help') -V, --version Print version ``` diff --git a/examples/flux.md b/examples/flux.md index 8e85ac0..77e18ee 100644 --- a/examples/flux.md +++ b/examples/flux.md @@ -68,6 +68,20 @@ This example demonstrates how to use the `sd-api-server` to generate images usin > [!TIP] > `sd-api-server` will use `8080` port by default. You can change the port by adding `--port `. + - Reduce the memory usage + + In the default setting, the server will create `text-to-image` and `image-to-image` contexts for the model. `text-to-image` context is responsible for image generation tasks, while `image-to-image` context for image edits. If you only need one of them, you can specify the context type by adding `--context-type `. For example, if you only need the `text-to-image` context, you can start the server with the following command: + + ```bash + wasmedge --dir .:. sd-api-server.wasm \ + --model-name flux1-schnell \ + --diffusion-model flux1-schnell-Q4_0.gguf \ + --vae ae.safetensors \ + --clip-l clip_l.safetensors \ + --t5xxl t5xxl-Q8_0.gguf \ + --context-type text-to-image + ``` + ## Usage ### Image Generation diff --git a/examples/flux_with_lora.md b/examples/flux_with_lora.md index 60ec55e..0257cde 100644 --- a/examples/flux_with_lora.md +++ b/examples/flux_with_lora.md @@ -77,6 +77,23 @@ This example demonstrates how to use the `sd-api-server` to generate images usin > [!TIP] > `sd-api-server` will use `8080` port by default. You can change the port by adding `--port `. + - Reduce the memory usage + + In the default setting, the server will create `text-to-image` and `image-to-image` contexts for the model. `text-to-image` context is responsible for image generation tasks, while `image-to-image` context for image edits. If you only need one of them, you can specify the context type by adding `--context-type `. For example, if you only need the `text-to-image` context, you can start the server with the following command: + + ```bash + wasmedge --dir .:. \ + --dir lora-models:lora-models \ + sd-api-server.wasm \ + --model-name flux1-dev \ + --diffusion-model flux1-dev-Q4_0.gguf \ + --vae ae.safetensors \ + --clip-l clip_l.safetensors \ + --t5xxl t5xxl-Q8_0.gguf \ + --lora-model-dir lora-models \ + --context-type text-to-image + ``` + ## Usage ### Image Generation