How to use dreamshaperXL10_alpha2Xl10.safetensors with controlnet-canny-sdxl-1.0 ? · Issue #4618 · huggingface/diffusers · GitHub
Skip to content

How to use dreamshaperXL10_alpha2Xl10.safetensors with controlnet-canny-sdxl-1.0 ? #4618

Closed

Description

@arnold408

I want to use dreamshaperXL10_alpha2Xl10.safetensors with controlnet-canny-sdxl-1.0
I downloaded dreamshaperXL10_alpha2Xl10.safetensors file and tried to use :

pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
'./dreamshaperXL10_alpha2Xl10.safetensors',
controlnet=controlnet,
use_safetensors=True,
torch_dtype=torch.float16,
variant="fp16"
)

got error :
pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
File "/opt/conda/lib/python3.10/site-packages/diffusers/pipelines/pipeline_utils.py", line 908, in from_pretrained
cached_folder = cls.download(
File "/opt/conda/lib/python3.10/site-packages/diffusers/pipelines/pipeline_utils.py", line 1330, in download
info = model_info(
File "/opt/conda/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 110, in _inner_fn
validate_repo_id(arg_value)
File "/opt/conda/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 158, in validate_repo_id
raise HFValidationError(
huggingface_hub.utils._validators.HFValidationError: Repo id must be in the form 'repo_name' or 'namespace/repo_name': './dream/dreamshaperXL10_alpha2Xl10.safetensors'. Use repo_type argument if needed.

Previously, I tried to use from_single_file insteaed of from_pretrained.
Got error : from_single_file not available with StableDiffusionXLControlNetPipeline.

Please help.
Thanks

Activity

  1. changed the title [-]ow to use dreamshaperXL10_alpha2Xl10.safetensors with controlnet-canny-sdxl-1.0 ?[/-] [+]How to use dreamshaperXL10_alpha2Xl10.safetensors with controlnet-canny-sdxl-1.0 ?[/+] on Aug 15, 2023
  2. dai-ichiro commented on Aug 15, 2023

    @dai-ichiro

    How about converting dreamshaperXL10_alpha2Xl10.safetensors to diffuser pipeline?

  3. arnold408 commented on Aug 15, 2023

    @arnold408
    Author

    How about converting dreamshaperXL10_alpha2Xl10.safetensors to diffuser pipeline?

    how to convert it to diffuser pipeline and use it in StableDiffusionXLControlNetPipeline ?
    Thanks

  4. dai-ichiro commented on Aug 15, 2023

    @dai-ichiro

    Install diffusers from main branch and then see #4461.

    How to convert

    python scripts/convert_original_stable_diffusion_to_diffusers.py \
        --checkpoint_path ./dreamshaperXL10_alpha2Xl10.safetensors \
        --dump_path ./dreamshaperXL \
        --pipeline_class_name StableDiffusionXLPipeline \
        --from_safetensors
    

    How to use

    controlnet = ControlNetModel.from_pretrained(
        "diffusers/controlnet-canny-sdxl-1.0",
        torch_dtype=torch.float16)
    
    pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
        "dreamshaperXL",
        controlnet=controlnet,
        torch_dtype=torch.float16)
    
  5. arnold408 commented on Aug 15, 2023

    @arnold408
    Author

    Thanks a lot, I will try this.

  6. sayakpaul commented on Aug 16, 2023

    @sayakpaul
    Member

    If you succeeded, could we close the issue?

  7. Killfaeh commented on Aug 21, 2023

    @Killfaeh

    Hello !
    The conversion worked for me but not the inference.
    I got this error :

    Expected tensor for argument #1 'indices' to have one of the following scalar types: Long, Int; but got
    torch.HalfTensor instead (while checking arguments for embedding)

  8. Killfaeh commented on Aug 21, 2023

    @Killfaeh

    Here is the code

    controlnet = ControlNetModel.from_pretrained('diffusers/controlnet-canny-sdxl-1.0', torch_dtype=torch.float16)
    pipe = StableDiffusionXLControlNetPipeline.from_pretrained("./models/Diffuser/dreamshaperXL10_alpha2Xl10", controlnet=controlnet, torch_dtype=torch.float16)

    inputImg = Image.open("input/Body-kun-vador-canny.png").convert("RGB")

    output = pipe("darth vader holding his light saber in fighting position, trending on art station", negative_prompt='', image=inputImg, num_inference_steps=20, controlnet_conditioning_scale=0.75)

    This code works with "stabilityai/stable-diffusion-xl-base-1.0" but not dreamshaperXL10_alpha2Xl10.

  9. sayakpaul commented on Aug 21, 2023

    @sayakpaul
    Member

    How did you run the conversion? We cannot reproduce what you posted above.

  10. Killfaeh commented on Aug 21, 2023

    @Killfaeh

    I made a script, here is the code

    #!/bin/bash

    INPUT_FILE="models/Safetensors/dreamshaperXL10_alpha2Xl10.safetensors"
    OUTPUT_DIRECTORY="models/Diffuser/dreamshaperXL10_alpha2Xl10"

    python3 diffusers/scripts/convert_original_stable_diffusion_to_diffusers.py --checkpoint_path $INPUT_FILE --dump_path $OUTPUT_DIRECTORY --pipeline_class_name StableDiffusionXLPipeline --from_safetensors

    I have the same error when I run an inference with StableDiffusionXLPipeline and from_single_file to load the .safetensors model.
    I have tried with the model CounterfaitXL too. Same error.

    I have a Mac Intel if this info can help.

  11. sayakpaul commented on Aug 21, 2023

    @sayakpaul
    Member

    That script does not support converting SDXL ControlNets.

  12. Killfaeh commented on Aug 21, 2023

    @Killfaeh

    I have copied the command line given by dai-ichiro and replaced the checkpoint_path and dump_path by my own values.
    I have checked again, the command line is the same. Is this information wrong ?

  13. Killfaeh commented on Aug 21, 2023

    @Killfaeh

    I found the solution : I have updated some python modules (transformers and accelerate).
    The script support SDXL.

  14. sayakpaul commented on Aug 22, 2023

    @sayakpaul
    Member

    Cool! Closing this issue then. It would be very nice, if you could post an end-to-end Colab Notebook here. I think that will benefit the community a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions