Skip to content

Instantly share code, notes, and snippets.

@hvaara
Created August 13, 2024 22:27
Show Gist options
  • Select an option

  • Save hvaara/bc8754b2aab6ef07a95c82c5e436f6d3 to your computer and use it in GitHub Desktop.

Select an option

Save hvaara/bc8754b2aab6ef07a95c82c5e436f6d3 to your computer and use it in GitHub Desktop.
import torch
from diffusers import FluxPipeline
DEVICE = "mps"
SEED = 1
pipe = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16)
pipe.to(DEVICE)
prompts = [
"A cat holding a sign that says hello world",
"a portal into a mythical forest on the wall of my small messy bedroom",
]
for i, prompt in enumerate(prompts):
image = pipe(
prompt,
guidance_scale=0.0,
num_inference_steps=4,
max_sequence_length=256,
generator=torch.Generator(DEVICE).manual_seed(SEED),
).images[0]
image.save(f"output_image_{SEED}_{prompt}_{DEVICE}.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment