CoolFace
Modelpublic

Disty0/Qwen-Image-Layered-SDNQ-uint4-svd-r32

sourceHugging Faceapache-2.0updated 9mo agoView on Hugging Face
5likes28downloads
Model Card

4 bit (UINT4 with SVD rank 32) quantization of Qwen/Qwen-Image-Layered using SDNQ.

Usage:

pip install sdnq
py
import torch
import diffusers
from PIL import Image
from sdnq import SDNQConfig # import sdnq to register it into diffusers and transformers
from sdnq.common import use_torch_compile as triton_is_available
from sdnq.loader import apply_sdnq_options_to_model

pipe = diffusers.QwenImageLayeredPipeline.from_pretrained("Disty0/Qwen-Image-Layered-SDNQ-uint4-svd-r32", torch_dtype=torch.bfloat16)

# Enable INT8 MatMul for AMD, Intel ARC and Nvidia GPUs:
if triton_is_available and (torch.cuda.is_available() or torch.xpu.is_available()):
    pipe.transformer = apply_sdnq_options_to_model(pipe.transformer, use_quantized_matmul=True)
    pipe.text_encoder = apply_sdnq_options_to_model(pipe.text_encoder, use_quantized_matmul=True)
    # pipe.transformer = torch.compile(pipe.transformer) # optional for faster speeds

pipe.enable_model_cpu_offload()
pipe.set_progress_bar_config(disable=None)

image = Image.open("input.png").convert("RGBA")

with torch.inference_mode():
    output = pipe(
        image=image,
        generator=torch.manual_seed(777),
        true_cfg_scale=4.0,
        negative_prompt=" ",
        num_inference_steps=50,
        num_images_per_prompt=1,
        layers=4,
        resolution=640,      # Using different bucket (640, 1024) to determine the resolution. For this version, 640 is recommended
        cfg_normalize=True,  # Whether enable cfg normalization.
        use_en_prompt=True,  # Automatic caption language if user does not provide caption)
    ).images[0]

for i, image in enumerate(output):
    image.save(f"{i}.png")