Skip to content

Instantly share code, notes, and snippets.

@yakovkhalinsky
Last active April 13, 2025 23:03
Show Gist options
  • Save yakovkhalinsky/78c41dd56331fc53d2d4e995ca7fcd13 to your computer and use it in GitHub Desktop.
Save yakovkhalinsky/78c41dd56331fc53d2d4e995ca7fcd13 to your computer and use it in GitHub Desktop.
flux python starter files
import torch
from diffusers import FluxPipeline
prompt = "A cat holding a sign that says hello world"
model = "/home/yakov/.cache/huggingface/hub/models--black-forest-labs--FLUX.1-schnell/snapshots/741f7c3ce8b383c54771c7003378a50191e9efe9"
device = "cuda"
pipe = FluxPipeline.from_pretrained(model, torch_dtype=torch.bfloat16).to(device)
pipe.enable_model_cpu_offload()
image = pipe(
prompt,
guidance_scale=0.0,
num_inference_steps=4,
max_sequence_length=256,
generator = torch.Generator(device=device).manual_seed(42)
).images[0]
image.save("flux-schnell.png")
accelerate
diffusers
torch
transformers
transformers[sentencepiece]
#! /bin/bash
source ./venv/bin/activate
#! /bin/bash
python -m venv venv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment