Skip to content

Commit

Permalink
Merge pull request #31 from argmaxinc/check_res_div
Browse files Browse the repository at this point in the history
Check image dim divisibility by 16
  • Loading branch information
arda-argmax authored Sep 6, 2024
2 parents 717faf8 + e62c5bf commit c8083cc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
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

0 comments on commit c8083cc

Please sign in to comment.