Text-to-Image
Diffusers
Safetensors
English
ZImagePipeline

Issue is that ZImagePipeline is not in the standard diffusers package

#2
by PierrunoYT - opened

issue is that ZImagePipeline is not in the standard diffusers package - it's a custom pipeline that comes with the model. We need to use DiffusionPipeline with trust_remote_code=True to load the custom pipeline

❌ Error generating image: module diffusers has no attribute ZImagePipeline

ImportError: cannot import name 'ZImagePipeline' from 'diffusers'

Try installing from source:

pip install git+https://github.com/huggingface/diffusers.git -U
Tongyi-MAI org

It should be installed from source, We have updated the README.

This comment has been hidden

It should be installed from source, We have updated the README.

I tried it but it doesnt work.

Tongyi-MAI org

We've mentioned it in the github repo previously, now we also mention it in this repo

also huggingface-hub>=0.34.0,<1.0 is required, why?
Had to downgrade

Can someone check this https://github.com/PierrunoYT/Z-Image-Pinokio

The ones who don't want ComfyUI will check

We've mentioned it in the github repo previously, now we also mention it in this repo

It doesnt work. So this is needed
grafik

It doesnt work. So this is needed...

The installation instructions aren't full, I also had to downgrade HuggingFace Hub

Tongyi-MAI org

The installation instructions aren't full, I also had to downgrade HuggingFace Hub

@qpqpqpqpqpqp

In general, huggingface_hub is quite flexible. If you are facing strict version conflicts between diffusers and huggingface_hub, or if you just want to bypass the runtime version check, downloading the weights manually is a good workaround.

However, regarding the ImportError, you must install diffusers from source, otherwise from diffusers import ZImagePipeline will never work regardless of where the weights are stored.

Here is a workflow that might help you bypass the hub versioning issue while ensuring the pipeline loads:

  1. Install diffusers from source (Mandatory for ZImagePipeline):

    pip install git+https://github.com/huggingface/diffusers.git -U
    
  2. Download weights locally (To avoid Hub version issues):

    huggingface-cli download --resume-download Tongyi-MAI/Z-Image-Turbo --local-dir "./Z-Image-Turbo"
    
  3. Run Inference:

    import torch
    # This import requires the source installation from step 1
    from diffusers import ZImagePipeline
    
    # Load from local path
    pipe = ZImagePipeline.from_pretrained(
        "./Z-Image-Turbo",
        torch_dtype=torch.bfloat16,
        low_cpu_mem_usage=False,
    )
    pipe.to("cuda")
    
  1. Download weights locally (To avoid Hub version issues):
    huggingface-cli download --resume-download Tongyi-MAI/Z-Image-Turbo --local-dir "./Z-Image-Turbo"
    

Should be hf download --resume-download Tongyi-MAI/Z-Image-Turbo --local-dir "./Z-Image-Turbo instead because huggingface-cli is deprecated

QJerry changed discussion status to closed

Sign up or log in to comment