Skip to content

Commit

Permalink
Merge pull request #1038 from bghira/bugfix/poetry-venv
Browse files Browse the repository at this point in the history
fix venv instructions and edge case for aspect crop bucket list
  • Loading branch information
bghira authored Oct 8, 2024
2 parents 0d0013c + 9b5aa47 commit 1942d5b
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 7 deletions.
3 changes: 3 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ python3.11 -m venv .venv
source .venv/bin/activate

pip install -U poetry pip

# Necessary on some systems to prevent it from deciding it knows better than us.
poetry config virtualenvs.create false
```

> ℹ️ You can use your own custom venv path by setting `export VENV_PATH=/path/to/.venv` in your `config/config.env` file.
Expand Down
3 changes: 3 additions & 0 deletions documentation/quickstart/FLUX.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ python3.11 -m venv .venv
source .venv/bin/activate

pip install -U poetry pip

# Necessary on some systems to prevent it from deciding it knows better than us.
poetry config virtualenvs.create false
```

**Note:** We're currently installing the `release` branch here; the `main` branch may contain experimental features that might have better results or lower memory use.
Expand Down
3 changes: 3 additions & 0 deletions documentation/quickstart/KOLORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ python -m venv .venv
source .venv/bin/activate

pip install -U poetry pip

# Necessary on some systems to prevent it from deciding it knows better than us.
poetry config virtualenvs.create false
```

Depending on your system, you will run one of 3 commands:
Expand Down
3 changes: 3 additions & 0 deletions documentation/quickstart/SD3.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ python -m venv .venv
source .venv/bin/activate

pip install -U poetry pip

# Necessary on some systems to prevent it from deciding it knows better than us.
poetry config virtualenvs.create false
```

Depending on your system, you will run one of 3 commands:
Expand Down
3 changes: 3 additions & 0 deletions documentation/quickstart/SIGMA.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ python -m venv .venv
source .venv/bin/activate

pip install -U poetry pip

# Necessary on some systems to prevent it from deciding it knows better than us.
poetry config virtualenvs.create false
```

Depending on your system, you will run one of 3 commands:
Expand Down
22 changes: 16 additions & 6 deletions helpers/data_backend/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,22 @@ def init_backend_config(backend: dict, args: dict, accelerator) -> dict:
if (
output["config"]["crop_aspect"] == "random"
or output["config"]["crop_aspect"] == "closest"
) and "crop_aspect_buckets" not in backend:
raise ValueError(
f"(id={backend['id']}) crop_aspect_buckets must be provided when crop_aspect is set to 'random'."
" This should be a list of float values or a list of dictionaries following the format: {'aspect_bucket': float, 'weight': float}."
" The weight represents how likely this bucket is to be chosen, and all weights should add up to 1.0 collectively."
)
):
if "crop_aspect_buckets" not in backend or not isinstance(
backend["crop_aspect_buckets"], list
):
raise ValueError(
f"(id={backend['id']}) crop_aspect_buckets must be provided when crop_aspect is set to 'random'."
" This should be a list of float values or a list of dictionaries following the format: {'aspect_bucket': float, 'weight': float}."
" The weight represents how likely this bucket is to be chosen, and all weights should add up to 1.0 collectively."
)
for bucket in backend.get("crop_aspect_buckets"):
if type(bucket) not in [float, int, dict]:
raise ValueError(
f"(id={backend['id']}) crop_aspect_buckets must be a list of float values or a list of dictionaries following the format: {'aspect_bucket': float, 'weight': float}."
" The weight represents how likely this bucket is to be chosen, and all weights should add up to 1.0 collectively."
)

output["config"]["crop_aspect_buckets"] = backend.get("crop_aspect_buckets")
else:
output["config"]["crop_aspect"] = "square"
Expand Down
2 changes: 1 addition & 1 deletion helpers/image_manipulation/training_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def _trim_aspect_bucket_list(self):
# If any of the aspect buckets will result in that, we'll ignore it.
if type(bucket) is dict:
aspect = bucket["aspect_ratio"]
elif type(bucket) is float:
elif type(bucket) is float or type(bucket) is int:
aspect = bucket
else:
raise ValueError(
Expand Down

0 comments on commit 1942d5b

Please sign in to comment.