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

feature: large refactor - breaking changes #413

Merged
merged 10 commits into from
Dec 13, 2023
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
19 changes: 17 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
python-version: 3.9
python-version: "3.10"
- name: Cache dependencies
uses: actions/[email protected]
id: cache
Expand All @@ -35,7 +35,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
python-version: 3.9
python-version: "3.10"
- name: Cache dependencies
uses: actions/[email protected]
id: cache
Expand Down Expand Up @@ -73,3 +73,18 @@ jobs:
CUDA_LAUNCH_BLOCKING: 1
run: |
pytest --durations=10 -v
type-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
python-version: "3.10"
cache: pip
cache-dependency-path: requirements-dev.txt
- name: Install dependencies
run: |
python -m pip install -r requirements-dev.txt . --upgrade
- name: Run mypy
run: |
make type-check
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ lint: ## Run the code linter.
@ruff check --config tests/ruff.toml .
@echo -e "No linting errors - well done! ✨ 🍰 ✨"

type-check: ## Run the type checker.
@mypy --config-file tox.ini .

deploy: ## Deploy the package to pypi.org
pip install twine wheel
-git tag $$(python setup.py -V)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ Use with `--model SD-2.1` or `--model SD-2.0-v`
**6.1.0**
- feature: use different default steps and image sizes depending on sampler and model selected
- fix: #110 use proper version in image metadata
- refactor: samplers all have their own class that inherits from ImageSampler
- refactor: solvers all have their own class that inherits from ImageSolver
- feature: 🎉🎉🎉 Stable Diffusion 2.0
- `--model SD-2.0` to use (it makes worse images than 1.5 though...)
- Tested on macOS and Linux
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/generate_doc_examples.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from imaginairy import ImaginePrompt, LazyLoadingImage, imagine_image_files
from imaginairy.api import imagine_image_files
from imaginairy.schema import ImaginePrompt, LazyLoadingImage


def main():
Expand Down
3 changes: 2 additions & 1 deletion docs/examples/immortal_pearl_earring.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
from PIL import ImageDraw, ImageFont
from tqdm import tqdm

from imaginairy import ImaginePrompt, LazyLoadingImage, WeightedPrompt, imagine
from imaginairy.api import imagine
from imaginairy.log_utils import configure_logging
from imaginairy.schema import ImaginePrompt, LazyLoadingImage, WeightedPrompt


def generate_image_morph_video():
Expand Down
20 changes: 13 additions & 7 deletions docs/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@
### v14 todo

- configurable composition cutoff
- rename model parameter weights
- rename model_config parameter to architecture and make it case insensitive
- add --size parameter that accepts strings (e.g. 256x256, 4k, uhd, 8k, etc)
- detect if cuda torch missing and give better error message
- add method to install correct torch version
- ✅ rename model parameter weights
- ✅ rename model_config parameter to architecture and make it case insensitive
- ✅ add --size parameter that accepts strings (e.g. 256x256, 4k, uhd, 8k, etc)
- ✅ detect if cuda torch missing and give better error message
- ✅ add method to install correct torch version
- ✅ make cli run faster again
- ✅ add tests for cli commands
- add type checker
- only output the main image unless some flag is set
- allow selection of output video format
- chain multiple operations together imggen => videogen
- https://github.com/pallets/click/tree/main/examples/imagepipe

- add interface for loading diffusers weights
- https://huggingface.co/playgroundai/playground-v2-1024px-aesthetic
- make sure terminal output on windows doesn't suck
- add karras schedule to refiners
- add method to show cache size
- add method to clear model cache
- add method to clear cached items not recently used (does diffusers have one?)

### Old Todo

- Inference Performance Optimizations
Expand Down
19 changes: 0 additions & 19 deletions imaginairy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,3 @@
os.putenv("PYTORCH_ENABLE_MPS_FALLBACK", "1")
# use more memory than we should
os.putenv("PYTORCH_MPS_HIGH_WATERMARK_RATIO", "0.0")

import sys # noqa

from .api import imagine, imagine_image_files # noqa
from .schema import ( # noqa
ImaginePrompt,
ImagineResult,
LazyLoadingImage,
WeightedPrompt,
)

# if python version is 3.11 or higher, throw an exception
if sys.version_info >= (3, 11):
msg = (
"Imaginairy is not compatible with Python 3.11 or higher. Please use Python 3.8 - 3.10.\n"
"This is due to torch 1.13 not supporting Python 3.11 and this library not having yet switched "
"to torch 2.0"
)
raise RuntimeError(msg)
Loading