Skip to content

Commit

Permalink
Merge pull request #91 from invoke-ai/fix-static-asset-paths
Browse files Browse the repository at this point in the history
Include static files required by the UI in the python package.
  • Loading branch information
RyanJDick authored Feb 7, 2024
2 parents 56b3254 + fe05d5a commit ff828eb
Show file tree
Hide file tree
Showing 18 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pip install -e ".[test]" --extra-index-url https://download.pytorch.org/whl/cu12

Run training via the CLI with type-checked YAML configuration files for maximum control:
```bash
invoke-train --cfg-file configs/sd_lora_pokemon_1x8gb.yaml
invoke-train --cfg-file src/invoke_training/sample_configs/sd_lora_pokemon_1x8gb.yaml
```

### GUI
Expand Down
4 changes: 2 additions & 2 deletions docs/get-started/quick-start-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ This training process has been tested on an NVIDIA GPU with 8GB of VRAM.
Follow the [`invoke-training` installation instructions](./installation.md).

### 2. Config file
We will use the [configs/sd_lora_pokemon_1x8gb.yaml](https://github.com/invoke-ai/invoke-training/blob/main/configs/sd_lora_pokemon_1x8gb.yaml) (SD v1.5, 8GB VRAM) configuration file for this tutorial. This configuration file controls all of the parameters of the training process and has been pre-configured for this tutorial. If you're curious, you can learn more about the configuration file format in the [full pipeline tutorials](../tutorials/index.md) or the [configuration reference](../reference/config/index.md) docs.
We will use the [src/invoke_training/sample_configs/sd_lora_pokemon_1x8gb.yaml](https://github.com/invoke-ai/invoke-training/blob/main/src/invoke_training/sample_configs/sd_lora_pokemon_1x8gb.yaml) (SD v1.5, 8GB VRAM) configuration file for this tutorial. This configuration file controls all of the parameters of the training process and has been pre-configured for this tutorial. If you're curious, you can learn more about the configuration file format in the [full pipeline tutorials](../tutorials/index.md) or the [configuration reference](../reference/config/index.md) docs.

### 3. Start training!
Start the training pipeline:
```bash
invoke-train --cfg-file configs/sd_lora_pokemon_1x8gb.yaml
invoke-train --cfg-file src/invoke_training/sample_configs/sd_lora_pokemon_1x8gb.yaml
```

### 4. Monitor training
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/config/pipelines/sdxl_textual_inversion.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# `SdxlTextualInversionConfig`

Below is a sample yaml config file for Textual Inversion SDXL training ([raw file](https://github.com/invoke-ai/invoke-training/blob/main/configs/sdxl_textual_inversion_gnome_1x24gb.yaml)). All of the configuration fields are explained in detail on this page.
Below is a sample yaml config file for Textual Inversion SDXL training ([raw file](https://github.com/invoke-ai/invoke-training/blob/main/src/invoke_training/sample_configs/sdxl_textual_inversion_gnome_1x24gb.yaml)). All of the configuration fields are explained in detail on this page.

```yaml title="sdxl_textual_inversion_gnome_1x24gb.yaml"
--8<-- "configs/sdxl_textual_inversion_gnome_1x24gb.yaml"
--8<-- "src/invoke_training/sample_configs/sdxl_textual_inversion_gnome_1x24gb.yaml"
```

<!-- To control the member order, we first list out the members whose order we care about, then we list the rest. -->
Expand Down
8 changes: 4 additions & 4 deletions docs/tutorials/stable_diffusion/dpo_lora_sd.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The Diffusion-DPO paper does full model fine-tuning on the [pickapic_v2](https:/

Run this experiment with the following command:
```bash
invoke-train -c configs/_experimental/sd_dpo_lora_pickapic_1x24gb.yaml
invoke-train -c src/invoke_training/sample_configs/_experimental/sd_dpo_lora_pickapic_1x24gb.yaml
```

Here is a cherry-picked example of a prompt for which this training process was clearly beneficial.
Expand All @@ -36,7 +36,7 @@ Note: The steps listed below are pretty rough. They are included primarily for r
### 1. Train a style LoRA

```bash
invoke-train -c configs/sd_lora_pokemon_1x8gb.yaml
invoke-train -c src/invoke_training/sample_configs/sd_lora_pokemon_1x8gb.yaml
```

### 2. Generate images
Expand Down Expand Up @@ -80,13 +80,13 @@ Launch the gradio UI for selecting image pair preferences.

```bash
# Note: rank_images.py accepts a full training pipeline config, but only uses the dataset configuration.
python src/invoke_training/scripts/_experimental/rank_images.py -c configs/_experimental/sd_dpo_lora_refinement_pokemon_1x24gb.yaml
python src/invoke_training/scripts/_experimental/rank_images.py -c src/invoke_training/sample_configs/_experimental/sd_dpo_lora_refinement_pokemon_1x24gb.yaml
```

After completing the pair annotations, click "Save Metadata" and move the resultant metadata file to your image data directory (e.g. `output/pokemon_pairs/metadata.jsonl`).

### 4. Run Diffusion-DPO

```bash
invoke-train -c configs/_experimental/sd_dpo_lora_refinement_pokemon_1x24gb.yaml
invoke-train -c src/invoke_training/sample_configs/_experimental/sd_dpo_lora_refinement_pokemon_1x24gb.yaml
```
6 changes: 3 additions & 3 deletions docs/tutorials/stable_diffusion/textual_inversion_sdxl.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ Here are a few tips for preparing a Textual Inversion dataset:

Below is the training configuration that we'll use for this tutorial.

Raw config file: [configs/sdxl_textual_inversion_gnome_1x24gb.yaml](https://github.com/invoke-ai/invoke-training/blob/main/configs/sdxl_textual_inversion_gnome_1x24gb.yaml).
Raw config file: [src/invoke_training/sample_configs/sdxl_textual_inversion_gnome_1x24gb.yaml](https://github.com/invoke-ai/invoke-training/blob/main/src/invoke_training/sample_configs/sdxl_textual_inversion_gnome_1x24gb.yaml).

Full config reference docs: [Textual Inversion SDXL Config](../../reference/config/pipelines/sdxl_textual_inversion.md)

```yaml title="sdxl_textual_inversion_gnome_1x24gb.yaml"
--8<-- "configs/sdxl_textual_inversion_gnome_1x24gb.yaml"
--8<-- "src/invoke_training/sample_configs/sdxl_textual_inversion_gnome_1x24gb.yaml"
```

## 3 - Start Training
Expand All @@ -37,7 +37,7 @@ Full config reference docs: [Textual Inversion SDXL Config](../../reference/conf
Launch the Textual Inversion training pipeline:
```bash
# From inside the invoke-training/ source directory:
invoke-train -c configs/sdxl_textual_inversion_gnome_1x24gb.yaml
invoke-train -c src/invoke_training/sample_configs/sdxl_textual_inversion_gnome_1x24gb.yaml
```

Training takes ~40 mins on an NVIDIA RTX 4090.
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ dependencies = [
"Homepage" = "https://github.com/invoke-ai/invoke-training"
"Discord" = "https://discord.gg/ZmtBAhwWhy"

[tool.setuptools.package-data]
"invoke_training.sample_configs" = ["**/*.yaml"]
"invoke_training.assets" = ["*.png"]

[tool.ruff]
src = ["src"]
select = ["E", "F", "W", "C9", "N8", "I"]
Expand Down
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/invoke_training/ui/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@


def get_config_dir_path() -> Path:
p = Path(__file__).parent.parent.parent.parent / "configs"
p = Path(__file__).parent.parent / "sample_configs"
if not p.exists():
raise FileNotFoundError(f"Config directory not found: '{p}'")
return p


def get_assets_dir_path() -> Path:
p = Path(__file__).parent.parent.parent.parent / "assets"
p = Path(__file__).parent.parent / "assets"
if not p.exists():
pass
return p
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@


def test_pipeline_config():
"""Test that all sample pipeline configs can be parse as PipelineConfigs."""
"""Test that all sample pipeline configs can be parsed as PipelineConfigs."""
cur_file = Path(__file__)
config_dir = cur_file.parent.parent.parent.parent.parent / "configs"
config_dir = cur_file.parent.parent.parent.parent.parent / "src/invoke_training/sample_configs"
config_files = glob.glob(str(config_dir) + "/**/*.yaml", recursive=True)

assert len(config_files) > 0
Expand Down

0 comments on commit ff828eb

Please sign in to comment.