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 --host and --port args to the invoke-train-ui command #115

Merged
merged 3 commits into from
Apr 24, 2024
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
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

A library for training custom Stable Diffusion models (fine-tuning, LoRA training, textual inversion, etc.) that can be used in [InvokeAI](https://github.com/invoke-ai/InvokeAI).

> [!WARNING]
> `invoke-training` is still under active development, and breaking changes are likely. Full backwards compatibility will not be guranteed until v1.0.0.
> [!WARNING] > `invoke-training` is still under active development, and breaking changes are likely. Full backwards compatibility will not be guaranteed until v1.0.0.
> In the meantime, I recommend pinning to a specific commit hash.

## Documentation
Expand All @@ -13,14 +12,14 @@ https://invoke-ai.github.io/invoke-training/
## Training Modes

- Stable Diffusion
- LoRA
- DreamBooth LoRA
- Textual Inversion
- LoRA
- DreamBooth LoRA
- Textual Inversion
- Stable Diffusion XL
- LoRA
- DreamBooth LoRA
- Textual Inversion
- LoRA and Textual Inversion
- LoRA
- DreamBooth LoRA
- Textual Inversion
- LoRA and Textual Inversion

More training modes coming soon!

Expand All @@ -43,27 +42,32 @@ pip install -e ".[test]" --extra-index-url https://download.pytorch.org/whl/cu12
### CLI

Run training via the CLI with type-checked YAML configuration files for maximum control:

```bash
invoke-train --cfg-file src/invoke_training/sample_configs/sdxl_textual_inversion_gnome_1x24gb.yaml
```

### GUI

Run training via the GUI for a simpler starting point.

```bash
invoke-train-ui

# Or, you can optionally override the default host and port:
invoke-train-ui --host 0.0.0.0 --port 1234
```

## Features

Training progress can be monitored with [Tensorboard](https://www.tensorflow.org/tensorboard):
![Screenshot of the Tensorboard UI showing validation images.](docs/images/tensorboard_val_images_screenshot.png)
*Validation images in the Tensorboard UI.*
_Validation images in the Tensorboard UI._

All trained models are compatible with InvokeAI:

![Screenshot of the InvokeAI UI with an example of a Yoda pokemon generated using a Pokemon LoRA model.](docs/images/invokeai_yoda_pokemon_lora.png)
*Example image generated with the prompt "A cute yoda pokemon creature." and a trained Pokemon LoRA.*
_Example image generated with the prompt "A cute yoda pokemon creature." and a trained Pokemon LoRA._

## Contributing

Expand Down
17 changes: 14 additions & 3 deletions docs/get-started/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ There is also a video introduction to `invoke-training`:
<iframe width="560" height="315" src="https://www.youtube.com/embed/OZIz2vvtlM4?si=iR73F0IhlsolyYAl" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>

## Quick Start - GUI

### 1. Installation

Follow the [`invoke-training` installation instructions](./installation.md).

### 2. Launch the GUI

```bash
# From the invoke-training directory:
invoke-train-ui

# Or, you can optionally override the default host and port:
invoke-train-ui --host 0.0.0.0 --port 1234
```

Access the GUI in your browser at the URL printed to the console.
Expand All @@ -33,17 +39,20 @@ Click on 'Generate Config' to generate a YAML configuration file. This YAML conf
Click on the 'Start Training' and check your terminal for progress logs.

### 6. Monitor training

Monitor the training process with Tensorboard by running `tensorboard --logdir output/` and visiting [localhost:6006](http://localhost:6006) in your browser. Here you can see generated validation images throughout the training process.

![Screenshot of the Tensorboard UI showing validation images.](../images/tensorboard_val_images_screenshot.png)
*Validation images in the Tensorboard UI.*
_Validation images in the Tensorboard UI._

### 7. Invokeai

Select a checkpoint based on the quality of the generated images.

If you haven't already, setup [InvokeAI](https://github.com/invoke-ai/InvokeAI) by following its documentation.

Copy your selected LoRA checkpoint into your `${INVOKEAI_ROOT}/autoimport/lora` directory. For example:

```bash
# Note: You will have to replace the timestamp in the checkpoint path.
cp output/1691088769.5694647/checkpoint_epoch-00000002.safetensors ${INVOKEAI_ROOT}/autoimport/lora/pokemon_epoch-00000002.safetensors
Expand All @@ -52,12 +61,14 @@ cp output/1691088769.5694647/checkpoint_epoch-00000002.safetensors ${INVOKEAI_RO
You can now use your trained Pokemon LoRA in the InvokeAI UI! 🎉

![Screenshot of the InvokeAI UI with an example of a Yoda pokemon generated using a Pokemon LoRA model.](../images/invokeai_yoda_pokemon_lora.png)
*Example image generated with the prompt "A cute yoda pokemon creature." and Pokemon LoRA.*

_Example image generated with the prompt "A cute yoda pokemon creature." and Pokemon LoRA._

## Quick Start - CLI

### 1. Installation

Follow the [`invoke-training` installation instructions](./installation.md).

### 2. Training

See the [Textual Inversion - SDXL](../tutorials/stable_diffusion/textual_inversion_sdxl.md) tutorial for instructions on how to train a model via the CLI.
17 changes: 16 additions & 1 deletion src/invoke_training/scripts/invoke_train_ui.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
import argparse

import uvicorn

from invoke_training.ui.app import build_app


def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"--host",
default="127.0.0.1",
help="The server host. Set `--host 0.0.0.0` to make the app available on your network.",
)
parser.add_argument("--port", default=8000, type=int, help="The server port.")
args = parser.parse_args()

app = build_app()
uvicorn.run(app)
uvicorn.run(
app,
host=args.host,
port=args.port,
)


if __name__ == "__main__":
Expand Down
Loading