How to use from the
Use from the
Diffusers library
pip install -U diffusers transformers accelerate
import torch
from diffusers import DiffusionPipeline

# switch to "mps" for apple devices
pipe = DiffusionPipeline.from_pretrained("codeShare/FLUX.2-klein-9b-SDNQ-4bit", dtype=torch.bfloat16, device_map="cuda")

prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
image = pipe(prompt).images[0]

This is an SD Next Quantization (SDNQ) variant of the Flux2 Klein 9B model for use in batchwise image editing on colab T4 and/or Kaggle 2xT4. Notebooks are provided in this model repository.

This Quantization uses the destilled klein 9B model by Black Forest Labs. LoRa support is added in the encrypt images cell.

//--//

How to use:

This notebook is meant to be used on kaggle. It uses an AI image edit model to create 1 edited image from 2 image inputs and an edit prompt. The 2 image inputs come from foregrounds.zip and backgrounds.zip respectively.

You will need to encrypt the images prior to running this kaggle notebook in the encrypt_images.ipynb cell provided at https://huggingface.co/codeShare/FLUX.2-klein-9b-SDNQ-4bit/tree/main/colab_notebooks .

The edit logic is as follows: a. All edit tasks uses the same edit prompt b. The notebook iterates through all foreground images , and selects a background image from backgrounds.zip at random.

For example: If you have 400 images in foregrounds.zip , then this notebook will output 400 edited images.

At one pipe per T4 using klein 9b , it takes 30 seconds per edit image , meaning a job of 400 images will take 200 minuted , or 3 hours and 20 minutes.

To run this Kaggle notebook you will need:

a Kaggle acoount (its free , but you will need to include a phone number to create a kaggle account.)

Create a private dataset on kaggle and upload the encrypted images + other components from the colab encrypt_images.ipynb cell.

Connect the dataset to this notebook on kaggle using the right hand menu.

You will need to write the 'kaggle_repo_path' in this notebook before running the code.

If you have a large dataset of say 600 foreground / background images , you can select 'Save version' on the top right on Kaggle. The notebook will run with the dataset and save the encrypted results upon completion and disconnect automatically. The maximum duration for a notebook to run on kaggle is 12 hours. You can close the kaggle browser and revisit later to fetch the results

The image outputs are encrypted to prevent others from snooping on the notebook outputs. With your password, you can decrypt the images using decrypt_images.ipynb provided at https://huggingface.co/codeShare/FLUX.2-klein-9b-SDNQ-4bit/tree/main/colab_notebooks.

Downloads last month
568
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for codeShare/FLUX.2-klein-9b-SDNQ-4bit

Finetuned
(24)
this model