| import torch |
| from diffusers import FluxPipeline |
| from huggingface_hub import login |
|
|
| |
| login(token="hf_yourtokenhere") |
|
|
| |
| pipe = FluxPipeline.from_pretrained( |
| "black-forest-labs/FLUX.1-schnell", |
| torch_dtype=torch.bfloat16 |
| ) |
|
|
| |
| pipe.enable_model_cpu_offload() |
|
|
| |
| prompt = "A cat holding a sign that says hello world" |
| image = pipe( |
| prompt, |
| guidance_scale=0.0, |
| num_inference_steps=4, |
| max_sequence_length=256, |
| generator=torch.Generator("cpu").manual_seed(0) |
| ).images[0] |
|
|
| |
| image.save("flux-schnell-output.png") |
| print("Image saved successfully!") |