Instructions to use tonera/FLUX.2-klein-9B-Nunchaku with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use tonera/FLUX.2-klein-9B-Nunchaku with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline from diffusers.utils import load_image # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("tonera/FLUX.2-klein-9B-Nunchaku", dtype=torch.bfloat16, device_map="cuda") prompt = "Turn this cat into a dog" input_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png") image = pipe(image=input_image, prompt=prompt).images[0] - Notebooks
- Google Colab
- Kaggle
LoRA loader for nunchaku transformer
Thanks for releasing the Nunchaku quantized version. I’m just wondering how to load an unquantized LoRA into this quantized Nunchaku transformer?
About lora
LoRA support for FLUX.2-klein-9B-Nunchaku has been released.Please copy the files from the repository to the corresponding directories:
nunchaku/lora/common/
nunchaku/models/transformers/transformer_flux2.py
nunchaku/torch_transfer_utils.py
Usage
lora_path = "/home/tonera/loras/ultra_real_v2.safetensors"
transformer.update_lora_params(lora_path)
transformer.set_lora_strength(0.8)
BTW: How to locate the Nunchaku installation path and copy the above files to the correct directories? Run the following command:
python -c "import nunchaku; print(nunchaku.file)"
You will get output similar to this:/home/tonera/miniconda3/envs/aiservice/lib/python3.11/site-packages/nunchaku/init.py Here, /home/tonera/miniconda3/envs/aiservice/lib/python3.11/site-packages/nunchaku is your Nunchaku installation directory. Simply copy the aforementioned files into the matching subdirectories under this path.