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

Check image dim divisibility by 16 #31

Merged
merged 3 commits into from
Sep 6, 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
7 changes: 7 additions & 0 deletions python/src/diffusionkit/mlx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,13 @@ def generate_image(
image_path: Optional[str] = None,
denoise: float = 1.0,
):
# Check latent size is divisible by 2
assert (
latent_size[0] % 2 == 0
), f"Height must be divisible by 16 ({latent_size[0]*8}/16={latent_size[0]/2})"
assert (
latent_size[1] % 2 == 0
), f"Width must be divisible by 16 ({latent_size[1]*8}/16={latent_size[1]/2})"
self.check_and_load_models()
# Start timing
start_time = time.time()
Expand Down
2 changes: 2 additions & 0 deletions python/src/diffusionkit/mlx/scripts/generate_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ def cli():

height = args.height or HEIGHT[args.model_version]
width = args.width or WIDTH[args.model_version]
assert height % 16 == 0, f"Height must be divisible by 16 ({height}/16={height/16})"
assert width % 16 == 0, f"Width must be divisible by 16 ({width}/16={width/16})"
logger.info(f"Output image resolution will be {height}x{width}")

if args.benchmark_mode:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from setuptools import find_packages, setup
from setuptools.command.install import install

VERSION = "0.3.4"
VERSION = "0.3.5"


class VersionInstallCommand(install):
Expand Down
Loading