Download exp_code/1_benchmark/Flux-dev/infer.py from SuperCS/useful_code: direct link, hf CLI and curl.
- Browser
- Download file 607 Bytes
-
https://huggingface.co/datasets/SuperCS/useful_code/resolve/aaf853dfec71df594de1823e958ef7533fdc28fa/exp_code/1_benchmark/Flux-dev/infer.py
- Command line
-
hf download hf://datasets/SuperCS/useful_code@aaf853dfec71df594de1823e958ef7533fdc28fa/exp_code/1_benchmark/Flux-dev/infer.py
-
curl -L -o infer.py https://huggingface.co/datasets/SuperCS/useful_code/resolve/aaf853dfec71df594de1823e958ef7533fdc28fa/exp_code/1_benchmark/Flux-dev/infer.py
607 Bytes
| import torch | |
| from diffusers import FluxPipeline | |
| pipe = FluxPipeline.from_pretrained("/mnt/workspace/checkpoints/black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16) | |
| pipe.enable_model_cpu_offload() #save some VRAM by offloading the model to CPU. Remove this if you have enough GPU power | |
| prompt = "A cat holding a sign that says hello world" | |
| image = pipe( | |
| prompt, | |
| height=384, # 384 192 96 | |
| width=640, # 640 320 160 | |
| guidance_scale=3.5, | |
| num_inference_steps=50, | |
| max_sequence_length=512, | |
| generator=torch.Generator("cpu").manual_seed(0) | |
| ).images[0] | |
| image.save("flux-dev.png") | |