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

Stable Diffusion txt2image.py prompt length > 75 tokens crash #1327

Open
pjain opened this issue Mar 7, 2025 · 0 comments
Open

Stable Diffusion txt2image.py prompt length > 75 tokens crash #1327

pjain opened this issue Mar 7, 2025 · 0 comments

Comments

@pjain
Copy link

pjain commented Mar 7, 2025

Using a prompt longer than 75 tokens results in SD txt2image.py failing on a Mac mini w/ M4 Pro and 48GB RAM.

"Generate an image of an alien riding a missile, set in a futuristic cityscape with sleek skyscrapers and neon lights. The alien should be tall, slender, and have scaly blue skin with large green eyes. It's wearing a metallic exosuit with glowing blue accents, and holding onto the missile's handlebars with long, spindly fingers. Incorporate a sense of speed and motion, with blurred backgrounds and dynamic lighting effects.

Style: Hyper-realistic

Resolution: 512x512 pixels

Color palette: Neon blues, purples, and silvers."

0%| | 0/2 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/Users/foo/projects/mlx/mlx-examples/stable_diffusion/txt2image.py", line 71, in
for x_t in tqdm(latents, total=args.steps):
File "/Users/foo/projects/mlx/lib/python3.11/site-packages/tqdm/std.py", line 1181, in iter
for obj in iterable:
File "/Users/foo/projects/mlx/mlx-examples/stable_diffusion/stable_diffusion/init.py", line 246, in generate_latents
conditioning, pooled_conditioning = self._get_text_conditioning(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/foo/projects/mlx/mlx-examples/stable_diffusion/stable_diffusion/init.py", line 217, in _get_text_conditioning
conditioning_1 = self.text_encoder_1(tokens_1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/foo/projects/mlx/mlx-examples/stable_diffusion/stable_diffusion/clip.py", line 94, in call
x = x + self.position_embedding.weight[:N]
~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ValueError: [broadcast_shapes] Shapes (1,116,768) and (77,768) cannot be broadcast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant