Last active
August 6, 2024 20:56
-
-
Save lucataco/dfce418964494e8c4b7f7c8add8c9b4c to your computer and use it in GitHub Desktop.
Flux-Schnell Optimum Quanto
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
from optimum.quanto import freeze, qfloat8, quantize | |
from diffusers import FluxPipeline | |
import torch | |
import time | |
seed=1337 | |
generator = torch.Generator("cuda").manual_seed(seed) | |
pipeline = FluxPipeline.from_pretrained("black-forest-labs/FLUX.1-schnell", torch_dtype=torch.bfloat16).to("cuda") | |
# Uncomment to quantize the model | |
# quantize(pipeline.transformer, weights=qfloat8) | |
# freeze(pipeline.transformer) | |
# quantize(pipeline.text_encoder, weights=qfloat8) | |
# freeze(pipeline.text_encoder) | |
t1 = time.time() | |
image = pipeline( | |
prompt="ghibli style, a fantasy landscape with castles", | |
guidance_scale=0.0, | |
output_type="pil", | |
num_inference_steps=4, | |
max_sequence_length=256, | |
generator=generator | |
).images[0] | |
t2 = time.time() | |
print(f"Time taken: {t2-t1} seconds") | |
image.save("output.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment