Buckets:

Mercity/FluxDistill / build_nunchaku /src /examples /flux.1-kontext-dev.py
Pranav2748's picture
download
raw
892 Bytes
import torch
from diffusers import FluxKontextPipeline
from diffusers.utils import load_image
from nunchaku import NunchakuFluxTransformer2dModel
from nunchaku.utils import get_precision
transformer = NunchakuFluxTransformer2dModel.from_pretrained(
f"nunchaku-tech/nunchaku-flux.1-kontext-dev/svdq-{get_precision()}_r32-flux.1-kontext-dev.safetensors"
)
pipeline = FluxKontextPipeline.from_pretrained(
"black-forest-labs/FLUX.1-Kontext-dev", transformer=transformer, torch_dtype=torch.bfloat16
).to("cuda")
image = load_image(
"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/yarn-art-pikachu.png"
).convert("RGB")
prompt = "Make Pikachu hold a sign that says 'Nunchaku is awesome', yarn art style, detailed, vibrant colors"
image = pipeline(image=image, prompt=prompt, guidance_scale=2.5).images[0]
image.save("flux-kontext-dev.png")

Xet Storage Details

Size:
892 Bytes
·
Xet hash:
6b2c9e214118b7889e67a00cdd7554191d63f845cc6d547fda509fb27ae619da

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.