Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newer version of diffusers fails due to tensor being passed to safety checker #54

Closed
rockerBOO opened this issue Nov 14, 2023 · 2 comments

Comments

@rockerBOO
Copy link
Contributor

With diffusers 0.21.2 the safety checker hook fails due to tensors being passed instead of numpy arrays.

Traceback (most recent call last):
  File "/mnt/900/builds/sd-scripts/daam/test.py", line 161, in <module>
    main(args)
  File "/mnt/900/builds/sd-scripts/daam/test.py", line 115, in main
    out = pipe(
  File "/mnt/900/builds/sd-scripts/.venv/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "/mnt/900/builds/sd-scripts/.venv/lib/python3.10/site-packages/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion.py", line 708, in __call__
    image, has_nsfw_concept = self.run_safety_checker(image, device, prompt_embeds.dtype)
  File "/mnt/900/builds/sd-scripts/daam/daam/trace.py", line 140, in _hooked_run_safety_checker
    pil_image = self.numpy_to_pil(image)
  File "/mnt/900/builds/sd-scripts/.venv/lib/python3.10/site-packages/diffusers/pipelines/pipeline_utils.py", line 1699, in numpy_to_pil
    return numpy_to_pil(images)
  File "/mnt/900/builds/sd-scripts/.venv/lib/python3.10/site-packages/diffusers/utils/pil_utils.py", line 43, in numpy_to_pil
    images = (images * 255).round().astype("uint8")
AttributeError: 'Tensor' object has no attribute 'astype'. Did you mean: 'dtype'?

Am aware the library isn't supported at this version. Making a PR to fix with backwards compatibility.

@daemon
Copy link
Member

daemon commented Nov 30, 2023

Thanks for this!

@daemon
Copy link
Member

daemon commented Jan 7, 2024

Resolved in latest release.

@daemon daemon closed this as completed Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants