Git Product home page Git Product logo

joaolages / diffusers-interpret Goto Github PK

View Code? Open in Web Editor NEW
259.0 6.0 13.0 79.4 MB

Diffusers-Interpret ๐Ÿค—๐Ÿงจ๐Ÿ•ต๏ธโ€โ™€๏ธ: Model explainability for ๐Ÿค— Diffusers. Get explanations for your generated images.

License: MIT License

Jupyter Notebook 99.72% Python 0.24% CSS 0.01% HTML 0.01% JavaScript 0.02%
computer-vision deep-learning diffusers diffusion explainable-ai image-generation interpretability model-explainability pytorch text2image

diffusers-interpret's Introduction

Joao Lages' LinkedIn profile ย  Joao Lages' Medium articles

Hi there ๐Ÿ‘‹

diffusers-interpret's People

Contributors

andrewizbatista avatar joaolages avatar tompham97 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

diffusers-interpret's Issues

The Colab Notebook cannot be opened

Notebook loading error
There was an error loading this notebook. Ensure that the file is accessible and try again.

Invalid Credentials

Problably the notebook it is not set to public.

cannot import name '_png' from 'matplotlib'

I received this error, cannot import name '_png' from 'matplotlib' when trying to run the new plot command when using Google Colab.

It seems Colab has an older version of matplotlib running - 3.2.2
If I forced an install of matplotlib, pip install -U matplotlib and restarted the runtime, I could get the plot to work correctly.

Plot is helpful!

diffusers=0.3.0 no longer loads models correctly

Hi, I added it as a comment in previous issue, but I think it's nice to raise it as a separate ticket - an issue there was it'd be nice to update diffusers package to newer version, but nowadays I am unable even to run colab demo due to this error.

I wanted to follow up as presented demo colab is not working at all. When downloading StableDiffusion pipeline I got error

TypeError: getattr(): attribute name must be string

I found an error about it on SO: https://stackoverflow.com/questions/74687769/typeerror-getattr-attribute-name-must-be-string-in-pytorch-diffusers-how

When I force to use 0.24, I got error on importing diffusers_interpret:
ImportError: cannot import name 'preprocess_mask' from 'diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_inpaint' (/usr/local/lib/python3.10/dist-packages/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py)

So I tried to install it with pip again but it downloads diffusers back to 0.3.0

So I can create a pipe for stable diffusion (requires diffusers > 0.4) OR I can use diffusers_interpret (requires 0.3).
Both of them does not work together in demo colab meaning I cannot reproduce your output

Update diffusers-interpret to work with the latest diffusers package (0.8.0)

When using diffusers-interpret with the latest diffusers (0.8.0, yes, I need this version because I use Euler discrete scheduler), it gives the following error:

ImportError: cannot import name 'preprocess_mask' from 'diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_inpaint' (/usr/local/lib/python3.7/dist-packages/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_inpaint.py)

Can it be fixed to work with it? 0.3.0 is now very outdated.
Thanks!

StableDiffusionPipelineExplainer enable_attention_slicing() and limit token attribution

Version 0.3.0 of the ๐Ÿค— Difusers introduces enable_attention_slicing, and I wonder if there's a way to implement this in the explainer. Below is the code that I used and it ran out of CUDA memory:

# Import pipeline
import torch
from diffusers import StableDiffusionPipeline

torch_device = "cuda" if torch.cuda.is_available() else "cpu"

pipe = StableDiffusionPipeline.from_pretrained(
    "CompVis/stable-diffusion-v1-4",
    use_auth_token = True,
    revision = "fp16" if torch_device != "cpu" else None,
    torch_dtype = torch.float16 if torch_device != "cpu" else None)

pipe.to(torch_device)

pipe.enable_attention_slicing() # attention optimization for less memory usage

# Pass pipeline to the explainer class

from diffusers_interpret import StableDiffusionPipelineExplainer

explainer = StableDiffusionPipelineExplainer(pipe)

prompt = "photograph, piggy, corn salad"

with torch.autocast(torch_device):
    output = explainer(prompt,
                       guidance_scale=7.5,
                       num_inference_steps=17)

output.image

TypeError

When I try the following code snippet from your notebook I get a TypeError

prompt = "A cute corgi with the Eiffel Tower in the background"

generator = torch.Generator(device).manual_seed(2022)
with torch.autocast('cuda') if device == 'cuda' else nullcontext():
    output = explainer(
        prompt, 
        num_inference_steps=15, 
        generator=generator
    )

TypeError: '>' not supported between instances of 'NoneType' and 'int'

Website for documentation

What would you like your documentation website to look like? I would like to help creating and/or maintaining it.
I have some experience with Github Pages built via Jekyll. If you want something similar, would you mind creating a gh-pages branch and choose a Jekyll theme of choice?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.