Last active
April 13, 2025 23:03
-
-
Save yakovkhalinsky/78c41dd56331fc53d2d4e995ca7fcd13 to your computer and use it in GitHub Desktop.
flux python starter files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
accelerate | |
diffusers | |
torch | |
transformers | |
transformers[sentencepiece] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
source ./venv/bin/activate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
python -m venv venv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment